|
#!/bin/bash |
|
|
|
dir_shell=/ql/shell |
|
. $dir_shell/share.sh |
|
. $dir_shell/env.sh |
|
|
|
|
|
|
|
echo -e "======================初始化并更新GitHub储存库内容========================\n" |
|
|
|
|
|
GITHUB_TOKEN=$GITHUB_TOKEN |
|
|
|
|
|
REPO_URL="https://${GITHUB_TOKEN}@github.com/lang03383/hf_ql_his.git" |
|
|
|
|
|
if [ ! -d "/path/to/your/qinglong/project/.git" ]; then |
|
|
|
git clone $REPO_URL /path/to/your/qinglong/project |
|
else |
|
|
|
cd /path/to/your/qinglong/project |
|
git pull origin main |
|
fi |
|
|
|
echo -e "GitHub内容同步完成...\n" |
|
|
|
echo -e "======================写入rclone配置========================\n" |
|
echo "$RCLONE_CONF" > ~/.config/rclone/rclone.conf |
|
|
|
echo -e "======================1. 检测配置文件========================\n" |
|
import_config "$@" |
|
make_dir /etc/nginx/conf.d |
|
make_dir /run/nginx |
|
init_nginx |
|
fix_config |
|
|
|
pm2 l &>/dev/null |
|
|
|
echo -e "======================2. 安装依赖========================\n" |
|
patch_version |
|
|
|
echo -e "======================3. 启动nginx========================\n" |
|
nginx -s reload 2>/dev/null || nginx -c /etc/nginx/nginx.conf |
|
echo -e "nginx启动成功...\n" |
|
|
|
echo -e "======================4. 启动pm2服务========================\n" |
|
reload_update |
|
reload_pm2 |
|
|
|
if [[ $AutoStartBot == true ]]; then |
|
echo -e "======================5. 启动bot========================\n" |
|
nohup ql bot >$dir_log/bot.log 2>&1 & |
|
echo -e "bot后台启动中...\n" |
|
fi |
|
|
|
if [[ $EnableExtraShell == true ]]; then |
|
echo -e "====================6. 执行自定义脚本========================\n" |
|
nohup ql extra >$dir_log/extra.log 2>&1 & |
|
echo -e "自定义脚本后台执行中...\n" |
|
fi |
|
|
|
echo -e "====================7. 启动实时同步到GitHub========================\n" |
|
|
|
|
|
git remote set-url origin $REPO_URL |
|
|
|
|
|
inotifywait -m -r -e modify,attrib,close_write,move,create,delete /path/to/your/qinglong/project | |
|
while read -r directory events filename; do |
|
|
|
cd /path/to/your/qinglong/project |
|
git add . |
|
git commit -m "Automated commit for $filename on $(date)" |
|
git push origin main |
|
done & |
|
|
|
echo -e "##########写入登陆信息############" |
|
echo "{ \"username\": \"$ADMIN_USERNAME\", \"password\": \"$ADMIN_PASSWORD\" }" > /ql/data/config/auth.json |
|
|
|
|
|
tail -f /dev/null |
|
|
|
exec "$@" |