#!/bin/bash # 更新国内镜像源 sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup # 备份原有的 sources.list 文件 sudo cat > /etc/apt/sources.list </dev/null | grep -F "$cron_job") # 如果不存在,则添加定时任务 if [ -z "$existing_cron" ]; then (crontab -l 2>/dev/null; echo "$cron_job") | crontab - echo "续签任务已添加" else echo "续签任务已存在,无需添加" fi # 下载配置文件 wget -O /home/app/nginx.conf https://raw.githubusercontent.com/shakenny/containerized-stack/refs/heads/main/nginx.conf wget -O /home/app/conf.d/default.conf https://raw.githubusercontent.com/shakenny/containerized-stack/refs/heads/main/default.conf wget -O /home/app/mysql/conf.d/my.cnf https://raw.githubusercontent.com/shakenny/containerized-stack/refs/heads/main/my.cnf wget -O /home/app/mysql/conf.d/init.sql https://raw.githubusercontent.com/shakenny/containerized-stack/refs/heads/main/local/init_mysql.sql wget -O /home/app/redis/conf/redis.conf https://raw.githubusercontent.com/redis/redis/7.2/redis.conf wget -O /home/app/postgresql/init.sql https://raw.githubusercontent.com/shakenny/containerized-stack/refs/heads/main/local/init_postgres.sql # 修改Redis配置文件 sed -i "s/bind 127.0.0.1 -::1/bind 0.0.0.0/g" /home/app/redis/conf/redis.conf sed -i "s/# requirepass foobared/requirepass \!Ybw324\!/g" /home/app/redis/conf/redis.conf sed -i "s/appendonly no/appendonly yes/g" /home/app/redis/conf/redis.conf # 下载Docker Compose文件和Dockerfile wget -O /home/app/docker-compose.yml https://raw.githubusercontent.com/shakenny/containerized-stack/refs/heads/main/local/docker-compose.yml wget -O /home/app/Dockerfile https://raw.githubusercontent.com/shakenny/containerized-stack/refs/heads/main/local/Dockerfile echo "Initialization script completed successfully."