lowtime/qinglong
0
1#!/bin/bash2 3dir_shell=/ql/shell4. $dir_shell/share.sh5. $dir_shell/env.sh6 7echo -e "======================1. 检测配置文件========================\n"8import_config "$@"9make_dir /etc/nginx/conf.d10make_dir /run/nginx11init_nginx12fix_config13 14pm2 l &>/dev/null15 16echo -e "======================2. 安装依赖========================\n"17patch_version18 19echo -e "======================3. 启动nginx========================\n"20nginx -s reload 2>/dev/null || nginx -c /etc/nginx/nginx.conf21echo -e "nginx启动成功...\n"22 23echo -e "======================4. 启动pm2服务========================\n"24reload_update25reload_pm226 27if [[ $AutoStartBot == true ]]; then28 echo -e "======================5. 启动bot========================\n"29 nohup ql bot >$dir_log/bot.log 2>&1 &30 echo -e "bot后台启动中...\n"31fi32 33if [[ $EnableExtraShell == true ]]; then34 echo -e "====================6. 执行自定义脚本========================\n"35 nohup ql extra >$dir_log/extra.log 2>&1 &36 echo -e "自定义脚本后台执行中...\n"37fi38 39echo -e "======================7. 写入rclone配置========================\n"40echo "$RCLONE_CONF" > ~/.config/rclone/rclone.conf41 42echo -e "############################################################\n"43echo -e "容器启动成功..."44echo -e "############################################################\n"45 46 47echo -e "##########8. 写入登陆信息 ############"48echo "{ \"username\": \"$USERNAME\", \"password\": \"$PASSWORD\" }" > /ql/data/config/auth.json49 50echo -e "##########9. 同步备份信息 ############"51if [ -n "$RCLONE_CONF" ]; then52 echo -e "########## Synchronizing Backup ############"53 54 # Specify the remote folder path in the format remote:path55 REMOTE_FOLDER="huggingface:/qinglong"56 57 # Use rclone ls command to list folder contents, capturing output and errors58 OUTPUT=$(rclone ls "$REMOTE_FOLDER" 2>&1)59 60 # Get the exit status code of the rclone command61 EXIT_CODE=$?62 63 case $EXIT_CODE in64 0) 65 # rclone command executed successfully, check if the folder is empty66 if [ -z "$OUTPUT" ]; then67 echo "Initial installation"68 #rclone sync /ql/data $REMOTE_FOLDER69 else70 mkdir -p /ql/.tmp/data71 rclone sync "$REMOTE_FOLDER" /ql/.tmp/data && real_time=true ql reload data72 fi73 ;;74 1)75 # Handle other errors, check if it was a directory not found error76 if [[ "$OUTPUT" == *"directory not found"* ]]; then77 echo "Error: Folder does not exist"78 else79 echo "Error: $OUTPUT"80 fi81 ;;82 *)83 echo "Error: rclone command failed, exit code: $EXIT_CODE"84 ;;85 esac86else87 echo "No Rclone configuration detected"88fi89 90 91tail -f >/dev/null92 93exec "$@"94 