2021-02-24 00:01:36 +08:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
2024-01-14 13:03:08 +08:00
|
|
|
|
echo "在当前目录下创建 config 和 cron 文件夹"
|
2021-02-24 00:01:36 +08:00
|
|
|
|
mkdir -p config
|
2024-01-14 13:03:08 +08:00
|
|
|
|
mkdir -p cron
|
|
|
|
|
|
2024-01-14 14:39:18 +08:00
|
|
|
|
CONFIG_FILE="config/config.json"
|
|
|
|
|
CRONTAB_FILE="cron/crontab_list.sh"
|
2021-02-24 00:01:36 +08:00
|
|
|
|
|
2024-01-14 14:39:18 +08:00
|
|
|
|
if [ ! -f "$CONFIG_FILE" ]; then
|
|
|
|
|
echo "config.json 不存在. 开始下载默认文件..."
|
2024-02-23 17:42:47 +08:00
|
|
|
|
curl https://fastly.jsdelivr.net/gh/sitoi/dailycheckin@main/docker/config.template.json -o $CONFIG_FILE
|
2024-01-14 14:39:18 +08:00
|
|
|
|
else
|
|
|
|
|
echo "config.json 已存在. 跳过下载。"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ ! -f "$CRONTAB_FILE" ]; then
|
|
|
|
|
echo "crontab_list.sh 不存在. 开始下载默认文件..."
|
2024-02-23 17:42:47 +08:00
|
|
|
|
curl https://fastly.jsdelivr.net/gh/sitoi/dailycheckin@main/docker/crontab_list.sh -o $CRONTAB_FILE
|
2024-01-14 14:39:18 +08:00
|
|
|
|
else
|
|
|
|
|
echo "crontab_list.sh 已存在. 跳过下载。"
|
|
|
|
|
fi
|
2021-02-24 00:53:08 +08:00
|
|
|
|
|
2021-02-24 00:01:36 +08:00
|
|
|
|
|
2021-02-24 00:53:08 +08:00
|
|
|
|
docker --version
|
|
|
|
|
if [ $? -ne 0 ];then
|
|
|
|
|
echo "未安装 docker ,请先安装 docker 再运行脚本。"
|
|
|
|
|
else
|
|
|
|
|
echo "docker 环境存在,检测 docker-compose 环境是否安装..."
|
2024-03-08 09:49:25 +08:00
|
|
|
|
docker-compose --version || docker compose version && alias docker-compose="docker compose"
|
2021-02-24 00:53:08 +08:00
|
|
|
|
if [ $? -ne 0 ];then
|
|
|
|
|
echo "未安装 docker-compose,将使用 docker 命令启动容器..."
|
|
|
|
|
echo "开始通过 docker 命令创建容器"
|
2024-01-14 14:16:30 +08:00
|
|
|
|
docker pull sitoi/dailycheckin:latest
|
2021-02-24 00:53:08 +08:00
|
|
|
|
docker run -d -v $(pwd)/config:/dailycheckin/config \
|
|
|
|
|
-v $(pwd)/logs:/dailycheckin/logs \
|
2024-01-14 13:03:08 +08:00
|
|
|
|
-v $(pwd)/cron:/dailycheckin/cron \
|
2021-02-24 00:53:08 +08:00
|
|
|
|
--name dailycheckin \
|
|
|
|
|
--restart always \
|
|
|
|
|
sitoi/dailycheckin:latest
|
|
|
|
|
else
|
|
|
|
|
echo "docker-compose 环境存在,将使用 docker-compose 命令启动容器..."
|
|
|
|
|
echo "下载 docker-compose.yml 文件"
|
2024-02-23 17:42:47 +08:00
|
|
|
|
curl -O https://fastly.jsdelivr.net/gh/sitoi/dailycheckin@main/docker/docker-compose.yml
|
2021-02-24 00:53:08 +08:00
|
|
|
|
echo "开始通过 docker-compose 命令创建容器"
|
2024-01-14 14:16:30 +08:00
|
|
|
|
docker-compose pull
|
2021-02-24 00:53:08 +08:00
|
|
|
|
docker-compose up -d
|
|
|
|
|
fi
|
2024-03-08 09:49:25 +08:00
|
|
|
|
fi
|