From 65ade4b99679b5d855ef4a7a2d7323588354711e Mon Sep 17 00:00:00 2001 From: whyour Date: Fri, 5 Nov 2021 23:39:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9shell=E8=AF=AD=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker/docker-entrypoint.sh | 6 +++--- sample/requirements.txt | 1 - shell/bot.sh | 9 ++++++++- shell/check.sh | 14 +++++++------- shell/share.sh | 10 ++-------- shell/task.sh | 8 ++++---- shell/update.sh | 14 +++++++------- 7 files changed, 31 insertions(+), 31 deletions(-) delete mode 100644 sample/requirements.txt diff --git a/docker/docker-entrypoint.sh b/docker/docker-entrypoint.sh index 6222f016..87179bdf 100755 --- a/docker/docker-entrypoint.sh +++ b/docker/docker-entrypoint.sh @@ -8,7 +8,7 @@ set -e echo -e "======================1. 检测配置文件========================\n" cp -fv $nginx_conf /etc/nginx/nginx.conf cp -fv $nginx_app_conf /etc/nginx/conf.d/front.conf -pm2 l >/dev/null 2>&1 +pm2 l &>/dev/null echo echo -e "======================2. 安装依赖========================\n" @@ -20,7 +20,7 @@ nginx -s reload 2>/dev/null || nginx -c /etc/nginx/nginx.conf echo -e "nginx启动成功...\n" echo -e "======================4. 启动控制面板========================\n" -if [[ $(pm2 info panel 2>/dev/null) ]]; then +if test -z "$(pm2 info panel 1>/dev/null)"; then pm2 reload panel --source-map-support --time else pm2 start $dir_root/build/app.js -n panel --source-map-support --time @@ -28,7 +28,7 @@ fi echo -e "控制面板启动成功...\n" echo -e "======================5. 启动定时任务========================\n" -if [[ $(pm2 info schedule 2>/dev/null) ]]; then +if test -z "$(pm2 info schedule 1>/dev/null)"; then pm2 reload schedule --source-map-support --time else pm2 start $dir_root/build/schedule.js -n schedule --source-map-support --time diff --git a/sample/requirements.txt b/sample/requirements.txt deleted file mode 100644 index 663bd1f6..00000000 --- a/sample/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -requests \ No newline at end of file diff --git a/shell/bot.sh b/shell/bot.sh index b8f4615e..ae795e5c 100644 --- a/shell/bot.sh +++ b/shell/bot.sh @@ -27,8 +27,15 @@ if [[ $PipMirror ]]; then pip3 config set global.index-url $PipMirror fi cp -f "$repo_path/jbot/requirements.txt" "$dir_root" + cd $dir_root -pip3 --default-timeout=100 install -r requirements.txt --no-cache-dir +cat requirements.txt | while read LREAD +do +if test ! -z "$(pip3 show "${LREAD%%=*}" 1>/dev/null)"; then + pip3 --default-timeout=100 install ${LREAD} +fi +done + echo -e "\npython3依赖安装成功...\n" echo -e "4、启动bot程序...\n" diff --git a/shell/check.sh b/shell/check.sh index 708b6363..c3277591 100644 --- a/shell/check.sh +++ b/shell/check.sh @@ -37,18 +37,18 @@ copy_dep() { } reload_pm2() { - pm2 l >/dev/null 2>&1 + pm2 l &>/dev/null - if [[ $(pm2 info panel 2>/dev/null) ]]; then - pm2 reload panel --source-map-support --time >/dev/null 2>&1 + if test -z "$(pm2 info panel 1>/dev/null)"; then + pm2 reload panel --source-map-support --time &>/dev/null else - pm2 start $dir_root/build/app.js -n panel --source-map-support --time >/dev/null 2>&1 + pm2 start $dir_root/build/app.js -n panel --source-map-support --time &>/dev/null fi - if [[ $(pm2 info schedule 2>/dev/null) ]]; then - pm2 reload schedule --source-map-support --time >/dev/null 2>&1 + if test -z "$(pm2 info schedule 1>/dev/null)"; then + pm2 reload schedule --source-map-support --time &>/dev/null else - pm2 start $dir_root/build/schedule.js -n schedule --source-map-support --time >/dev/null 2>&1 + pm2 start $dir_root/build/schedule.js -n schedule --source-map-support --time &>/dev/null fi } diff --git a/shell/share.sh b/shell/share.sh index 065dfe64..ecf28eb5 100755 --- a/shell/share.sh +++ b/shell/share.sh @@ -125,7 +125,7 @@ link_shell() { define_cmd() { local cmd_prefix cmd_suffix - if type task >/dev/null 2>&1; then + if type task &>/dev/null; then cmd_suffix="" if [[ -x "$dir_shell/task.sh" ]]; then cmd_prefix="" @@ -213,7 +213,7 @@ fix_config() { npm_install_sub() { if [[ $is_termux -eq 1 ]]; then npm install --production --no-save --no-bin-links --registry=https://registry.npm.taobao.org || npm install --production --no-bin-links --no-save - elif ! type pnpm >/dev/null 2>&1; then + elif ! type pnpm &>/dev/null; then npm install --production --no-save --registry=https://registry.npm.taobao.org || npm install --production --no-save else pnpm install --prod @@ -261,12 +261,6 @@ update_depend() { npm_install_2 $dir_scripts fi - if [[ ! -s $dir_scripts/requirements.txt ]] || [[ $(diff $dir_sample/requirements.txt $dir_scripts/requirements.txt) ]]; then - cp -f $dir_sample/requirements.txt $dir_scripts/requirements.txt - cd $dir_scripts - pip3 install -r $dir_scripts/requirements.txt - fi - cd $dir_current } diff --git a/shell/task.sh b/shell/task.sh index 9b26ce7b..5d85111b 100755 --- a/shell/task.sh +++ b/shell/task.sh @@ -88,7 +88,7 @@ run_normal() { log_dir_tmp="${first_param##*/}" log_dir="$dir_log/${log_dir_tmp%%.*}" log_path="$log_dir/$log_time.log" - cmd=">> $log_path 2>&1" + cmd="&>> $log_path" [[ "$show_log" == "true" ]] && cmd="" make_dir "$log_dir" @@ -141,7 +141,7 @@ run_concurrent() { log_dir_tmp="${first_param##*/}" log_dir="$dir_log/${log_dir_tmp%%.*}" log_path="$log_dir/$log_time.log" - cmd=">> $log_path 2>&1" + cmd="&>> $log_path" [[ "$show_log" == "true" ]] && cmd="" make_dir $log_dir @@ -196,7 +196,7 @@ run_designated() { log_dir_tmp="${file_param##*/}" log_dir="$dir_log/${log_dir_tmp%%.*}" log_path="$log_dir/$log_time.log" - cmd=">> $log_path 2>&1" + cmd="&>> $log_path" [[ "$show_log" == "true" ]] && cmd="" make_dir $log_dir @@ -242,7 +242,7 @@ run_else() { local log_dir_tmp="${1##*/}" local log_dir="$dir_log/${log_dir_tmp%%.*}" log_path="$log_dir/$log_time.log" - cmd=">> $log_path 2>&1" + cmd="&>> $log_path" [[ "$show_log" == "true" ]] && cmd="" make_dir "$log_dir" diff --git a/shell/update.sh b/shell/update.sh index d9795b44..a4a1dc27 100755 --- a/shell/update.sh +++ b/shell/update.sh @@ -305,7 +305,7 @@ patch_version() { echo fi - if ! type ts-node >/dev/null 2>&1; then + if ! type ts-node &>/dev/null; then pnpm i -g ts-node typescript tslib fi @@ -313,18 +313,18 @@ patch_version() { } reload_pm2() { - pm2 l >/dev/null 2>&1 + pm2 l &>/dev/null if [[ $(pm2 info panel 2>/dev/null) ]]; then - pm2 reload panel --source-map-support --time >/dev/null 2>&1 + pm2 reload panel --source-map-support --time &>/dev/null else - pm2 start $dir_root/build/app.js -n panel --source-map-support --time >/dev/null 2>&1 + pm2 start $dir_root/build/app.js -n panel --source-map-support --time &>/dev/null fi if [[ $(pm2 info schedule 2>/dev/null) ]]; then - pm2 reload schedule --source-map-support --time >/dev/null 2>&1 + pm2 reload schedule --source-map-support --time &>/dev/null else - pm2 start $dir_root/build/schedule.js -n schedule --source-map-support --time >/dev/null 2>&1 + pm2 start $dir_root/build/schedule.js -n schedule --source-map-support --time &>/dev/null fi } @@ -369,7 +369,7 @@ gen_list_repo() { local dependence="$5" local repo="${repo_path##*/}" - rm -f $dir_list_tmp/${repo}*.list >/dev/null 2>&1 + rm -f $dir_list_tmp/${repo}*.list &>/dev/null cd ${repo_path}