mirror of
				https://github.com/whyour/qinglong.git
				synced 2025-11-04 02:56:07 +08:00 
			
		
		
		
	回退shell [
This commit is contained in:
		
							parent
							
								
									1b88853a8d
								
							
						
					
					
						commit
						62596f27ef
					
				| 
						 | 
					@ -6,7 +6,7 @@ get_token() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
add_cron_api() {
 | 
					add_cron_api() {
 | 
				
			||||||
    local currentTimeStamp=$(date +%s)
 | 
					    local currentTimeStamp=$(date +%s)
 | 
				
			||||||
    if [[ $# -eq 1 ]]; then
 | 
					    if [ $# -eq 1 ]; then
 | 
				
			||||||
        local schedule=$(echo "$1" | awk -F ":" '{print $1}')
 | 
					        local schedule=$(echo "$1" | awk -F ":" '{print $1}')
 | 
				
			||||||
        local command=$(echo "$1" | awk -F ":" '{print $2}')
 | 
					        local command=$(echo "$1" | awk -F ":" '{print $2}')
 | 
				
			||||||
        local name=$(echo "$1" | awk -F ":" '{print $3}')
 | 
					        local name=$(echo "$1" | awk -F ":" '{print $3}')
 | 
				
			||||||
| 
						 | 
					@ -39,7 +39,7 @@ add_cron_api() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
update_cron_api() {
 | 
					update_cron_api() {
 | 
				
			||||||
    local currentTimeStamp=$(date +%s)
 | 
					    local currentTimeStamp=$(date +%s)
 | 
				
			||||||
    if [[ $# -eq 1 ]]; then
 | 
					    if [ $# -eq 1 ]; then
 | 
				
			||||||
        local schedule=$(echo "$1" | awk -F ":" '{print $1}')
 | 
					        local schedule=$(echo "$1" | awk -F ":" '{print $1}')
 | 
				
			||||||
        local command=$(echo "$1" | awk -F ":" '{print $2}')
 | 
					        local command=$(echo "$1" | awk -F ":" '{print $2}')
 | 
				
			||||||
        local name=$(echo "$1" | awk -F ":" '{print $3}')
 | 
					        local name=$(echo "$1" | awk -F ":" '{print $3}')
 | 
				
			||||||
| 
						 | 
					@ -75,7 +75,7 @@ update_cron_api() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
update_cron_command_api() {
 | 
					update_cron_command_api() {
 | 
				
			||||||
    local currentTimeStamp=$(date +%s)
 | 
					    local currentTimeStamp=$(date +%s)
 | 
				
			||||||
    if [[ $# -eq 1 ]]; then
 | 
					    if [ $# -eq 1 ]; then
 | 
				
			||||||
        local command=$(echo "$1" | awk -F ":" '{print $1}')
 | 
					        local command=$(echo "$1" | awk -F ":" '{print $1}')
 | 
				
			||||||
        local id=$(echo "$1" | awk -F ":" '{print $2}')
 | 
					        local id=$(echo "$1" | awk -F ":" '{print $2}')
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,7 +11,7 @@ apk --no-cache add -f zlib-dev gcc jpeg-dev python3-dev musl-dev freetype-dev
 | 
				
			||||||
echo -e "\nbot依赖安装成功...\n"
 | 
					echo -e "\nbot依赖安装成功...\n"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
echo -e "2、下载bot所需文件...\n"
 | 
					echo -e "2、下载bot所需文件...\n"
 | 
				
			||||||
if [[ ! -d ${repo_path}/.git ]]; then
 | 
					if [ ! -d ${repo_path}/.git ]; then
 | 
				
			||||||
  rm -rf ${repo_path}
 | 
					  rm -rf ${repo_path}
 | 
				
			||||||
  git_clone_scripts ${url} ${repo_path} "main"
 | 
					  git_clone_scripts ${url} ${repo_path} "main"
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -27,7 +27,7 @@ remove_js_log() {
 | 
				
			||||||
remove_empty_dir() {
 | 
					remove_empty_dir() {
 | 
				
			||||||
    cd $dir_log
 | 
					    cd $dir_log
 | 
				
			||||||
    for dir in $(ls); do
 | 
					    for dir in $(ls); do
 | 
				
			||||||
        if [[ -d $dir ]] && [[ -z $(ls $dir) ]]; then
 | 
					        if [ -d $dir ] && [[ -z $(ls $dir) ]]; then
 | 
				
			||||||
            rm -rf $dir
 | 
					            rm -rf $dir
 | 
				
			||||||
        fi
 | 
					        fi
 | 
				
			||||||
    done
 | 
					    done
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -60,8 +60,8 @@ init_env() {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import_config() {
 | 
					import_config() {
 | 
				
			||||||
    [[ -f $file_config_user ]] && . $file_config_user
 | 
					    [ -f $file_config_user ] && . $file_config_user
 | 
				
			||||||
    [[ -f $file_env ]] && . $file_env
 | 
					    [ -f $file_env ] && . $file_env
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    command_timeout_time=${CommandTimeoutTime:-"1h"}
 | 
					    command_timeout_time=${CommandTimeoutTime:-"1h"}
 | 
				
			||||||
    github_proxy_url=${GithubProxyUrl:-""}
 | 
					    github_proxy_url=${GithubProxyUrl:-""}
 | 
				
			||||||
| 
						 | 
					@ -101,7 +101,7 @@ gen_random_num() {
 | 
				
			||||||
link_shell_sub() {
 | 
					link_shell_sub() {
 | 
				
			||||||
    local link_path="$1"
 | 
					    local link_path="$1"
 | 
				
			||||||
    local original_path="$2"
 | 
					    local original_path="$2"
 | 
				
			||||||
    if [[ ! -L $link_path ]] || [[ $(readlink -f $link_path) != $original_path ]]; then
 | 
					    if [ ! -L $link_path ] || [[ $(readlink -f $link_path) != $original_path ]]; then
 | 
				
			||||||
        rm -f $link_path 2>/dev/null
 | 
					        rm -f $link_path 2>/dev/null
 | 
				
			||||||
        ln -sf $original_path $link_path
 | 
					        ln -sf $original_path $link_path
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
| 
						 | 
					@ -110,7 +110,7 @@ link_shell_sub() {
 | 
				
			||||||
link_shell() {
 | 
					link_shell() {
 | 
				
			||||||
    if [[ $is_termux -eq 1 ]]; then
 | 
					    if [[ $is_termux -eq 1 ]]; then
 | 
				
			||||||
        local path="/data/data/com.termux/files/usr/bin/"
 | 
					        local path="/data/data/com.termux/files/usr/bin/"
 | 
				
			||||||
    elif [[ $PATH == */usr/local/bin* ]] && [[ -d /usr/local/bin ]]; then
 | 
					    elif [[ $PATH == */usr/local/bin* ]] && [ -d /usr/local/bin ]; then
 | 
				
			||||||
        local path="/usr/local/bin/"
 | 
					        local path="/usr/local/bin/"
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
        local path=""
 | 
					        local path=""
 | 
				
			||||||
| 
						 | 
					@ -127,14 +127,14 @@ define_cmd() {
 | 
				
			||||||
    local cmd_prefix cmd_suffix
 | 
					    local cmd_prefix cmd_suffix
 | 
				
			||||||
    if type task &>/dev/null; then
 | 
					    if type task &>/dev/null; then
 | 
				
			||||||
        cmd_suffix=""
 | 
					        cmd_suffix=""
 | 
				
			||||||
        if [[ -x "$dir_shell/task.sh" ]]; then
 | 
					        if [ -x "$dir_shell/task.sh" ]; then
 | 
				
			||||||
            cmd_prefix=""
 | 
					            cmd_prefix=""
 | 
				
			||||||
        else
 | 
					        else
 | 
				
			||||||
            cmd_prefix="bash "
 | 
					            cmd_prefix="bash "
 | 
				
			||||||
        fi
 | 
					        fi
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
        cmd_suffix=".sh"
 | 
					        cmd_suffix=".sh"
 | 
				
			||||||
        if [[ -x "$dir_shell/task.sh" ]]; then
 | 
					        if [ -x "$dir_shell/task.sh" ]; then
 | 
				
			||||||
            cmd_prefix="$dir_shell/"
 | 
					            cmd_prefix="$dir_shell/"
 | 
				
			||||||
        else
 | 
					        else
 | 
				
			||||||
            cmd_prefix="bash $dir_shell/"
 | 
					            cmd_prefix="bash $dir_shell/"
 | 
				
			||||||
| 
						 | 
					@ -155,55 +155,55 @@ fix_config() {
 | 
				
			||||||
    make_dir $dir_raw
 | 
					    make_dir $dir_raw
 | 
				
			||||||
    make_dir $dir_update_log
 | 
					    make_dir $dir_update_log
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if [[ ! -s $file_config_user ]]; then
 | 
					    if [ ! -s $file_config_user ]; then
 | 
				
			||||||
        echo -e "复制一份 $file_config_sample 为 $file_config_user,随后请按注释编辑你的配置文件:$file_config_user\n"
 | 
					        echo -e "复制一份 $file_config_sample 为 $file_config_user,随后请按注释编辑你的配置文件:$file_config_user\n"
 | 
				
			||||||
        cp -fv $file_config_sample $file_config_user
 | 
					        cp -fv $file_config_sample $file_config_user
 | 
				
			||||||
        echo
 | 
					        echo
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if [[ ! -f $file_env ]]; then
 | 
					    if [ ! -f $file_env ]; then
 | 
				
			||||||
        echo -e "检测到config配置目录下不存在env.sh,创建一个空文件用于初始化...\n"
 | 
					        echo -e "检测到config配置目录下不存在env.sh,创建一个空文件用于初始化...\n"
 | 
				
			||||||
        touch $file_env
 | 
					        touch $file_env
 | 
				
			||||||
        echo
 | 
					        echo
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if [[ ! -f $file_task_before ]]; then
 | 
					    if [ ! -f $file_task_before ]; then
 | 
				
			||||||
        echo -e "复制一份 $file_task_sample 为 $file_task_before\n"
 | 
					        echo -e "复制一份 $file_task_sample 为 $file_task_before\n"
 | 
				
			||||||
        cp -fv $file_task_sample $file_task_before
 | 
					        cp -fv $file_task_sample $file_task_before
 | 
				
			||||||
        echo
 | 
					        echo
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if [[ ! -f $file_task_after ]]; then
 | 
					    if [ ! -f $file_task_after ]; then
 | 
				
			||||||
        echo -e "复制一份 $file_task_sample 为 $file_task_after\n"
 | 
					        echo -e "复制一份 $file_task_sample 为 $file_task_after\n"
 | 
				
			||||||
        cp -fv $file_task_sample $file_task_after
 | 
					        cp -fv $file_task_sample $file_task_after
 | 
				
			||||||
        echo
 | 
					        echo
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if [[ ! -f $file_extra_shell ]]; then
 | 
					    if [ ! -f $file_extra_shell ]; then
 | 
				
			||||||
        echo -e "复制一份 $file_extra_sample 为 $file_extra_shell\n"
 | 
					        echo -e "复制一份 $file_extra_sample 为 $file_extra_shell\n"
 | 
				
			||||||
        cp -fv $file_extra_sample $file_extra_shell
 | 
					        cp -fv $file_extra_sample $file_extra_shell
 | 
				
			||||||
        echo
 | 
					        echo
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if [[ ! -s $file_auth_user ]]; then
 | 
					    if [ ! -s $file_auth_user ]; then
 | 
				
			||||||
        echo -e "复制一份 $file_auth_sample 为 $file_auth_user\n"
 | 
					        echo -e "复制一份 $file_auth_sample 为 $file_auth_user\n"
 | 
				
			||||||
        cp -fv $file_auth_sample $file_auth_user
 | 
					        cp -fv $file_auth_sample $file_auth_user
 | 
				
			||||||
        echo
 | 
					        echo
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if [[ ! -s $file_notify_py ]]; then
 | 
					    if [ ! -s $file_notify_py ]; then
 | 
				
			||||||
        echo -e "复制一份 $file_notify_py_sample 为 $file_notify_py\n"
 | 
					        echo -e "复制一份 $file_notify_py_sample 为 $file_notify_py\n"
 | 
				
			||||||
        cp -fv $file_notify_py_sample $file_notify_py
 | 
					        cp -fv $file_notify_py_sample $file_notify_py
 | 
				
			||||||
        echo
 | 
					        echo
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if [[ ! -s $file_notify_js ]]; then
 | 
					    if [ ! -s $file_notify_js ]; then
 | 
				
			||||||
        echo -e "复制一份 $file_notify_js_sample 为 $file_notify_js\n"
 | 
					        echo -e "复制一份 $file_notify_js_sample 为 $file_notify_js\n"
 | 
				
			||||||
        cp -fv $file_notify_js_sample $file_notify_js
 | 
					        cp -fv $file_notify_js_sample $file_notify_js
 | 
				
			||||||
        echo
 | 
					        echo
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if [[ -s /etc/nginx/conf.d/default.conf ]]; then
 | 
					    if [ -s /etc/nginx/conf.d/default.conf ]; then
 | 
				
			||||||
        echo -e "检测到默认nginx配置文件,清空...\n"
 | 
					        echo -e "检测到默认nginx配置文件,清空...\n"
 | 
				
			||||||
        cat /dev/null > /etc/nginx/conf.d/default.conf
 | 
					        cat /dev/null > /etc/nginx/conf.d/default.conf
 | 
				
			||||||
        echo
 | 
					        echo
 | 
				
			||||||
| 
						 | 
					@ -211,7 +211,7 @@ fix_config() {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
npm_install_sub() {
 | 
					npm_install_sub() {
 | 
				
			||||||
    if [[ $is_termux -eq 1 ]]; then
 | 
					    if [ $is_termux -eq 1 ]; then
 | 
				
			||||||
        npm install --production --no-bin-links --registry=https://registry.npm.taobao.org || npm install --production --no-bin-links
 | 
					        npm install --production --no-bin-links --registry=https://registry.npm.taobao.org || npm install --production --no-bin-links
 | 
				
			||||||
    elif ! type pnpm &>/dev/null; then
 | 
					    elif ! type pnpm &>/dev/null; then
 | 
				
			||||||
        npm install --production --registry=https://registry.npm.taobao.org || npm install --production
 | 
					        npm install --production --registry=https://registry.npm.taobao.org || npm install --production
 | 
				
			||||||
| 
						 | 
					@ -248,7 +248,7 @@ npm_install_2() {
 | 
				
			||||||
diff_and_copy() {
 | 
					diff_and_copy() {
 | 
				
			||||||
    local copy_source=$1
 | 
					    local copy_source=$1
 | 
				
			||||||
    local copy_to=$2
 | 
					    local copy_to=$2
 | 
				
			||||||
    if [[ ! -s $copy_to ]] || [[ $(diff $copy_source $copy_to) ]]; then
 | 
					    if [ ! -s $copy_to ] || [[ $(diff $copy_source $copy_to) ]]; then
 | 
				
			||||||
        cp -f $copy_source $copy_to
 | 
					        cp -f $copy_source $copy_to
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -256,7 +256,7 @@ diff_and_copy() {
 | 
				
			||||||
update_depend() {
 | 
					update_depend() {
 | 
				
			||||||
    local dir_current=$(pwd)
 | 
					    local dir_current=$(pwd)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if [[ ! -s $dir_scripts/package.json ]] || [[ $(diff $dir_sample/package.json $dir_scripts/package.json) ]]; then
 | 
					    if [ ! -s $dir_scripts/package.json ] || [[ $(diff $dir_sample/package.json $dir_scripts/package.json) ]]; then
 | 
				
			||||||
        cp -f $dir_sample/package.json $dir_scripts/package.json
 | 
					        cp -f $dir_sample/package.json $dir_scripts/package.json
 | 
				
			||||||
        npm_install_2 $dir_scripts
 | 
					        npm_install_2 $dir_scripts
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
| 
						 | 
					@ -296,7 +296,7 @@ reset_romote_url() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    [[ $branch ]] && local part_cmd="origin/${branch}"
 | 
					    [[ $branch ]] && local part_cmd="origin/${branch}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if [[ -d "$dir_work/.git" ]]; then
 | 
					    if [ -d "$dir_work/.git" ]; then
 | 
				
			||||||
        cd $dir_work
 | 
					        cd $dir_work
 | 
				
			||||||
        [[ -f ".git/index.lock" ]] && rm -f .git/index.lock >/dev/null
 | 
					        [[ -f ".git/index.lock" ]] && rm -f .git/index.lock >/dev/null
 | 
				
			||||||
        git remote set-url origin $url >/dev/null
 | 
					        git remote set-url origin $url >/dev/null
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -39,7 +39,7 @@ gen_array_scripts() {
 | 
				
			||||||
    local i="-1"
 | 
					    local i="-1"
 | 
				
			||||||
    cd $dir_scripts
 | 
					    cd $dir_scripts
 | 
				
			||||||
    for file in $(ls); do
 | 
					    for file in $(ls); do
 | 
				
			||||||
        if [[ -f $file ]] && [[ $file == *.js && $file != sendNotify.js ]]; then
 | 
					        if [ -f $file ] && [[ $file == *.js && $file != sendNotify.js ]]; then
 | 
				
			||||||
            let i++
 | 
					            let i++
 | 
				
			||||||
            array_scripts[i]=$(echo "$file" | perl -pe "s|$dir_scripts/||g")
 | 
					            array_scripts[i]=$(echo "$file" | perl -pe "s|$dir_scripts/||g")
 | 
				
			||||||
            array_scripts_name[i]=$(grep "new Env" $file | awk -F "'|\"" '{print $2}' | head -1)
 | 
					            array_scripts_name[i]=$(grep "new Env" $file | awk -F "'|\"" '{print $2}' | head -1)
 | 
				
			||||||
| 
						 | 
					@ -170,7 +170,7 @@ run_concurrent() {
 | 
				
			||||||
    for i in "${!array[@]}"; do
 | 
					    for i in "${!array[@]}"; do
 | 
				
			||||||
        single_log_path="$log_dir/${single_log_time}_$((i + 1)).log"
 | 
					        single_log_path="$log_dir/${single_log_time}_$((i + 1)).log"
 | 
				
			||||||
        eval cat $single_log_path $cmd
 | 
					        eval cat $single_log_path $cmd
 | 
				
			||||||
        [[ -f $single_log_path ]] && rm -f $single_log_path
 | 
					        [ -f $single_log_path ] && rm -f $single_log_path
 | 
				
			||||||
    done
 | 
					    done
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    eval . $file_task_after "$@" $cmd
 | 
					    eval . $file_task_after "$@" $cmd
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -12,12 +12,12 @@ diff_cron() {
 | 
				
			||||||
    local list_task="$2"
 | 
					    local list_task="$2"
 | 
				
			||||||
    local list_add="$3"
 | 
					    local list_add="$3"
 | 
				
			||||||
    local list_drop="$4"
 | 
					    local list_drop="$4"
 | 
				
			||||||
    if [[ -s $list_task ]]; then
 | 
					    if [ -s $list_task ]; then
 | 
				
			||||||
        grep -vwf $list_task $list_scripts >$list_add
 | 
					        grep -vwf $list_task $list_scripts >$list_add
 | 
				
			||||||
    elif [[ ! -s $list_task ]] && [[ -s $list_scripts ]]; then
 | 
					    elif [ ! -s $list_task ] && [ -s $list_scripts ]; then
 | 
				
			||||||
        cp -f $list_scripts $list_add
 | 
					        cp -f $list_scripts $list_add
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
    if [[ -s $list_scripts ]]; then
 | 
					    if [ -s $list_scripts ]; then
 | 
				
			||||||
        grep -vwf $list_scripts $list_task >$list_drop
 | 
					        grep -vwf $list_scripts $list_task >$list_drop
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
        cp -f $list_task $list_drop
 | 
					        cp -f $list_task $list_drop
 | 
				
			||||||
| 
						 | 
					@ -28,18 +28,18 @@ diff_cron() {
 | 
				
			||||||
detect_config_version() {
 | 
					detect_config_version() {
 | 
				
			||||||
    ## 识别出两个文件的版本号
 | 
					    ## 识别出两个文件的版本号
 | 
				
			||||||
    ver_config_sample=$(grep " Version: " $file_config_sample | perl -pe "s|.+v((\d+\.?){3})|\1|")
 | 
					    ver_config_sample=$(grep " Version: " $file_config_sample | perl -pe "s|.+v((\d+\.?){3})|\1|")
 | 
				
			||||||
    [[ -f $file_config_user ]] && ver_config_user=$(grep " Version: " $file_config_user | perl -pe "s|.+v((\d+\.?){3})|\1|")
 | 
					    [ -f $file_config_user ] && ver_config_user=$(grep " Version: " $file_config_user | perl -pe "s|.+v((\d+\.?){3})|\1|")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ## 删除旧的发送记录文件
 | 
					    ## 删除旧的发送记录文件
 | 
				
			||||||
    [[ -f $send_mark ]] && [[ $(cat $send_mark) != $ver_config_sample ]] && rm -f $send_mark
 | 
					    [ -f $send_mark ] && [[ $(cat $send_mark) != $ver_config_sample ]] && rm -f $send_mark
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ## 识别出更新日期和更新内容
 | 
					    ## 识别出更新日期和更新内容
 | 
				
			||||||
    update_date=$(grep " Date: " $file_config_sample | awk -F ": " '{print $2}')
 | 
					    update_date=$(grep " Date: " $file_config_sample | awk -F ": " '{print $2}')
 | 
				
			||||||
    update_content=$(grep " Update Content: " $file_config_sample | awk -F ": " '{print $2}')
 | 
					    update_content=$(grep " Update Content: " $file_config_sample | awk -F ": " '{print $2}')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ## 如果是今天,并且版本号不一致,则发送通知
 | 
					    ## 如果是今天,并且版本号不一致,则发送通知
 | 
				
			||||||
    if [[ -f $file_config_user ]] && [[ $ver_config_user != $ver_config_sample ]] && [[ $update_date == $(date "+%Y-%m-%d") ]]; then
 | 
					    if [ -f $file_config_user ] && [[ $ver_config_user != $ver_config_sample ]] && [[ $update_date == $(date "+%Y-%m-%d") ]]; then
 | 
				
			||||||
        if [[ ! -f $send_mark ]]; then
 | 
					        if [ ! -f $send_mark ]; then
 | 
				
			||||||
            local notify_title="配置文件更新通知"
 | 
					            local notify_title="配置文件更新通知"
 | 
				
			||||||
            local notify_content="更新日期: $update_date\n用户版本: $ver_config_user\n新的版本: $ver_config_sample\n更新内容: $update_content\n更新说明: 如需使用新功能请对照config.sample.sh,将相关新参数手动增加到你自己的config.sh中,否则请无视本消息。本消息只在该新版本配置文件更新当天发送一次。\n"
 | 
					            local notify_content="更新日期: $update_date\n用户版本: $ver_config_user\n新的版本: $ver_config_sample\n更新内容: $update_content\n更新说明: 如需使用新功能请对照config.sample.sh,将相关新参数手动增加到你自己的config.sh中,否则请无视本消息。本消息只在该新版本配置文件更新当天发送一次。\n"
 | 
				
			||||||
            echo -e $notify_content
 | 
					            echo -e $notify_content
 | 
				
			||||||
| 
						 | 
					@ -47,7 +47,7 @@ detect_config_version() {
 | 
				
			||||||
            [[ $? -eq 0 ]] && echo $ver_config_sample >$send_mark
 | 
					            [[ $? -eq 0 ]] && echo $ver_config_sample >$send_mark
 | 
				
			||||||
        fi
 | 
					        fi
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
        [[ -f $send_mark ]] && rm -f $send_mark
 | 
					        [ -f $send_mark ] && rm -f $send_mark
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -55,7 +55,7 @@ detect_config_version() {
 | 
				
			||||||
output_list_add_drop() {
 | 
					output_list_add_drop() {
 | 
				
			||||||
    local list=$1
 | 
					    local list=$1
 | 
				
			||||||
    local type=$2
 | 
					    local type=$2
 | 
				
			||||||
    if [[ -s $list ]]; then
 | 
					    if [ -s $list ]; then
 | 
				
			||||||
        echo -e "检测到有$type的定时任务:\n"
 | 
					        echo -e "检测到有$type的定时任务:\n"
 | 
				
			||||||
        cat $list
 | 
					        cat $list
 | 
				
			||||||
        echo
 | 
					        echo
 | 
				
			||||||
| 
						 | 
					@ -105,7 +105,7 @@ add_cron() {
 | 
				
			||||||
    cd $dir_scripts
 | 
					    cd $dir_scripts
 | 
				
			||||||
    for file in $(cat $list_add); do
 | 
					    for file in $(cat $list_add); do
 | 
				
			||||||
        local file_name=${file/${path}\_/}
 | 
					        local file_name=${file/${path}\_/}
 | 
				
			||||||
        if [[ -f $file ]]; then
 | 
					        if [ -f $file ]; then
 | 
				
			||||||
            cron_line=$(
 | 
					            cron_line=$(
 | 
				
			||||||
                perl -ne "{
 | 
					                perl -ne "{
 | 
				
			||||||
                        print if /.*([\d\*]*[\*-\/,\d]*[\d\*] ){4,5}[\d\*]*[\*-\/,\d]*[\d\*]( |,|\").*$file_name/
 | 
					                        print if /.*([\d\*]*[\*-\/,\d]*[\d\*] ){4,5}[\d\*]*[\*-\/,\d]*[\d\*]( |,|\").*$file_name/
 | 
				
			||||||
| 
						 | 
					@ -153,7 +153,7 @@ update_repo() {
 | 
				
			||||||
            [[ ! $url =~ "https://ghproxy.com" ]] && formatUrl="${github_proxy_url}${url}"
 | 
					            [[ ! $url =~ "https://ghproxy.com" ]] && formatUrl="${github_proxy_url}${url}"
 | 
				
			||||||
        fi
 | 
					        fi
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
    if [[ -d ${repo_path}/.git ]]; then
 | 
					    if [ -d ${repo_path}/.git ]; then
 | 
				
			||||||
        reset_romote_url ${repo_path} "${formatUrl}" "${branch}"
 | 
					        reset_romote_url ${repo_path} "${formatUrl}" "${branch}"
 | 
				
			||||||
        git_pull_scripts ${repo_path} "${branch}"
 | 
					        git_pull_scripts ${repo_path} "${branch}"
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
| 
						 | 
					@ -219,7 +219,7 @@ update_raw() {
 | 
				
			||||||
        fi
 | 
					        fi
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
        echo -e "下载 ${raw_file_name} 失败,保留之前正常下载的版本...\n"
 | 
					        echo -e "下载 ${raw_file_name} 失败,保留之前正常下载的版本...\n"
 | 
				
			||||||
        [[ -f "$dir_raw/${raw_file_name}.new" ]] && rm -f "$dir_raw/${raw_file_name}.new"
 | 
					        [ -f "$dir_raw/${raw_file_name}.new" ] && rm -f "$dir_raw/${raw_file_name}.new"
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -227,7 +227,7 @@ update_raw() {
 | 
				
			||||||
## 调用用户自定义的extra.sh
 | 
					## 调用用户自定义的extra.sh
 | 
				
			||||||
run_extra_shell() {
 | 
					run_extra_shell() {
 | 
				
			||||||
    if [[ ${EnableExtraShell} == true ]]; then
 | 
					    if [[ ${EnableExtraShell} == true ]]; then
 | 
				
			||||||
        if [[ -f $file_extra_shell ]]; then
 | 
					        if [ -f $file_extra_shell ]; then
 | 
				
			||||||
            echo -e "--------------------------------------------------------------\n"
 | 
					            echo -e "--------------------------------------------------------------\n"
 | 
				
			||||||
            . $file_extra_shell
 | 
					            . $file_extra_shell
 | 
				
			||||||
        else
 | 
					        else
 | 
				
			||||||
| 
						 | 
					@ -255,7 +255,7 @@ update_qinglong() {
 | 
				
			||||||
    patch_version
 | 
					    patch_version
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    local no_restart="$1"
 | 
					    local no_restart="$1"
 | 
				
			||||||
    [[ -f $dir_root/package.json ]] && ql_depend_old=$(cat $dir_root/package.json)
 | 
					    [ -f $dir_root/package.json ] && ql_depend_old=$(cat $dir_root/package.json)
 | 
				
			||||||
    reset_romote_url ${dir_root} "${github_proxy_url}https://github.com/whyour/qinglong.git" "master"
 | 
					    reset_romote_url ${dir_root} "${github_proxy_url}https://github.com/whyour/qinglong.git" "master"
 | 
				
			||||||
    git_pull_scripts $dir_root "master"
 | 
					    git_pull_scripts $dir_root "master"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -265,14 +265,14 @@ update_qinglong() {
 | 
				
			||||||
        detect_config_version
 | 
					        detect_config_version
 | 
				
			||||||
        update_depend
 | 
					        update_depend
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        [[ -f $dir_root/package.json ]] && ql_depend_new=$(cat $dir_root/package.json)
 | 
					        [ -f $dir_root/package.json ] && ql_depend_new=$(cat $dir_root/package.json)
 | 
				
			||||||
        [[ "$ql_depend_old" != "$ql_depend_new" ]] && npm_install_2 $dir_root
 | 
					        [[ "$ql_depend_old" != "$ql_depend_new" ]] && npm_install_2 $dir_root
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
        echo -e "\n更新$dir_root失败,请检查原因...\n"
 | 
					        echo -e "\n更新$dir_root失败,请检查原因...\n"
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    local url="${github_proxy_url}https://github.com/whyour/qinglong-static.git"
 | 
					    local url="${github_proxy_url}https://github.com/whyour/qinglong-static.git"
 | 
				
			||||||
    if [[ -d ${ql_static_repo}/.git ]]; then
 | 
					    if [ -d ${ql_static_repo}/.git ]; then
 | 
				
			||||||
        reset_romote_url ${ql_static_repo} ${url} "master"
 | 
					        reset_romote_url ${ql_static_repo} ${url} "master"
 | 
				
			||||||
        git_pull_scripts ${ql_static_repo} "master"
 | 
					        git_pull_scripts ${ql_static_repo} "master"
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
| 
						 | 
					@ -344,13 +344,13 @@ diff_scripts() {
 | 
				
			||||||
    local list_drop="$dir_list_tmp/${repo}_drop.list"
 | 
					    local list_drop="$dir_list_tmp/${repo}_drop.list"
 | 
				
			||||||
    diff_cron "$dir_list_tmp/${repo}_scripts.list" "$dir_list_tmp/${repo}_user.list" $list_add $list_drop
 | 
					    diff_cron "$dir_list_tmp/${repo}_scripts.list" "$dir_list_tmp/${repo}_user.list" $list_add $list_drop
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if [[ -s $list_drop ]]; then
 | 
					    if [ -s $list_drop ]; then
 | 
				
			||||||
        output_list_add_drop $list_drop "失效"
 | 
					        output_list_add_drop $list_drop "失效"
 | 
				
			||||||
        if [[ ${AutoDelCron} == true ]]; then
 | 
					        if [[ ${AutoDelCron} == true ]]; then
 | 
				
			||||||
            del_cron $list_drop $repo
 | 
					            del_cron $list_drop $repo
 | 
				
			||||||
        fi
 | 
					        fi
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
    if [[ -s $list_add ]]; then
 | 
					    if [ -s $list_add ]; then
 | 
				
			||||||
        output_list_add_drop $list_add "新"
 | 
					        output_list_add_drop $list_add "新"
 | 
				
			||||||
        if [[ ${AutoAddCron} == true ]]; then
 | 
					        if [[ ${AutoAddCron} == true ]]; then
 | 
				
			||||||
            add_cron $list_add $repo
 | 
					            add_cron $list_add $repo
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user