From 5b13358e3e33193eba067ea6e1c36d4c3918e288 Mon Sep 17 00:00:00 2001 From: woniuzfb <47843848+woniuzfb@users.noreply.github.com> Date: Tue, 26 Mar 2024 00:20:14 +0800 Subject: [PATCH] feat: rclone, obscure, rsync backup; fix --- README.md | 7 + build | 2 +- core | 10 + docs/iptv.sh | 210 ++++++++++++++- env | 15 +- iptv.sh | 210 ++++++++++++++- src/_4gtv/cron | 14 +- src/_4gtv/del_acc | 2 +- src/_4gtv/edit_acc | 2 +- src/_4gtv/list_accs | 2 +- src/_4gtv/login_acc | 10 +- src/_4gtv/reg_acc | 8 +- src/ali | 31 +-- src/alist/acc | 192 +++++++++++++ src/alist/act | 12 +- src/alist/add_acc | 70 ----- src/alist/add_app | 52 ---- src/alist/api | 2 +- src/alist/app | 299 +++++++++++++++++++++ src/alist/login_acc | 68 ----- src/alist/view_acc | 50 ---- src/alist/view_app | 18 -- src/iptv/cmd_add | 4 +- src/iptv/cmd_backup | 167 +++++++++++- src/iptv/menu_ts | 12 +- src/iptv/parse_stream | 2 +- src/iptv/start_channel | 2 +- src/iptv/usage | 2 + src/lhh | 3 + src/nginx/config_mmproxy | 3 +- src/rc | 46 ++++ src/rclone/remote | 184 +++++++++++++ src/service/base64 | 23 ++ src/{iptv/get_service => service/get_accs} | 48 +++- src/service/obscure | 25 ++ src/tv | 7 +- src/x | 2 +- utils/ffmpeg | 4 +- utils/i18n | 5 + utils/jq | 10 +- utils/mirror | 7 + utils/mongodb | 2 +- utils/openssl | 21 +- utils/shfile | 1 + utils/system | 4 +- 45 files changed, 1495 insertions(+), 375 deletions(-) create mode 100644 src/alist/acc delete mode 100644 src/alist/add_acc delete mode 100644 src/alist/add_app create mode 100644 src/alist/app delete mode 100644 src/alist/login_acc delete mode 100644 src/alist/view_acc delete mode 100644 src/alist/view_app create mode 100644 src/rc create mode 100644 src/rclone/remote create mode 100644 src/service/base64 rename src/{iptv/get_service => service/get_accs} (63%) create mode 100644 src/service/obscure diff --git a/README.md b/README.md index 6dbd261..c10b5b7 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ - [参数详解](#参数详解) - [举例](#举例) - [Alist](#alist) + - [Rclone](#rclone) - [LianHuanHua](#lianhuanhua) - [Dev](#dev) @@ -257,6 +258,12 @@ wget https://woniuzfb.github.io/iptv/iptv.sh && bash iptv.sh ./debug ali ``` +## Rclone + +```bash +./debug rc +``` + ## LianHuanHua ```bash diff --git a/build b/build index 6e012a2..e86b3b2 100644 --- a/build +++ b/build @@ -11,7 +11,7 @@ ReplaceInclude() echo "${2:-}if [ \"\$self\" == \"tv\" ] || [ \"\$self\" == \"iptv\" ]" echo "${2:-}then" ReplaceInclude src/tv " ${2:-}" - bins=(v2 x nx or pve arm ibm cf cx ali lhh) + bins=(v2 x nx or pve arm ibm cf cx ali lhh rc) for bin in "${bins[@]}" do echo "${2:-}elif [ \"\$self\" == \"$bin\" ]" diff --git a/core b/core index 8ee0b0b..74e59ff 100644 --- a/core +++ b/core @@ -197,6 +197,16 @@ GetRandomMac() echo $RANDOM|md5sum|sed 's/../&:/g'|cut -c 1-17 } +RemoveQuote() +{ + local text="${!1}" + if [[ "$text" =~ ^\"(.*)\"$ ]] || [[ "$text" =~ ^\'(.*)\'$ ]] + then + text="${BASH_REMATCH[1]}" + read -r ${1} <<< "$text" + fi +} + PrepTerm() { unset term_child_pid diff --git a/docs/iptv.sh b/docs/iptv.sh index b85ec62..5467c1e 100755 --- a/docs/iptv.sh +++ b/docs/iptv.sh @@ -34,6 +34,7 @@ IP_DENY="$IPTV_ROOT/ip.deny" IP_LOG="$IPTV_ROOT/ip.log" FFMPEG_LOG_ROOT="$IPTV_ROOT/ffmpeg" # create your own mirror: tv ffmpeg +BACKUP_ROOT="$HOME"/iptv_sh_backup FFMPEG_MIRROR_LINK="http://pngquant.com/ffmpeg" V2_FILE="/usr/local/bin/v2" V2_LINK="https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh" @@ -41,6 +42,7 @@ V2_LINK_FALLBACK="$FFMPEG_MIRROR_LINK/v2ray_install-release.sh" V2CTL_FILE="/usr/local/bin/v2ctl" V2_CONFIG="/usr/local/etc/v2ray/config.json" X_FILE="/usr/local/bin/x" +X_CONFIG="/usr/local/etc/xray/config.json" FFMPEG_MIRROR_ROOT="$IPTV_ROOT/ffmpeg" LIVE_ROOT="$IPTV_ROOT/live" SERVICES_FILE="$IPTV_ROOT/services.json" @@ -136,10 +138,10 @@ ArchCheck() if grep -Eqi "x86_64|amd64" <<< "$arch" then arch="x86_64" - elif grep -Eqi "i386|i686" <<< "$arch" + elif grep -Eqi "i386|i686|x86" <<< "$arch" then arch="i386" - elif grep -Eqi "aarch64|armv8" <<< "$arch" + elif grep -Eqi "aarch64|armv8|arm64" <<< "$arch" then arch="arm64" elif grep -qi "armv7" <<< "$arch" @@ -17052,7 +17054,7 @@ Reg4gtvAcc() | $JQ_FILE -r '[.Success,.ErrMessage]|join(" ")' ) || true - if [ "$result" = true ] + if [ "$result" = true ] || [ "$msg" = "String was not recognized as a valid DateTime." ] then if [ ! -s "$SERVICES_FILE" ] then @@ -17281,7 +17283,7 @@ Login4gtvAcc() fi done Println "$info 账号验证成功" - Println "$info 开启 7 天豪华套餐" + Println "$info 开启 30 天豪华套餐" IFS="^" read -r result msg < <(CurlFake -s -Lm 20 \ -H 'Origin: https://www.4gtv.tv' \ @@ -17293,9 +17295,9 @@ Login4gtvAcc() if [ "$result" = true ] then - Println "$info 7 天豪华套餐开启成功\n" + Println "$info 30 天豪华套餐开启成功\n" else - Println "$error 开启 7 天豪华套餐发生错误, 请重试\n\n$msg\n" + Println "$error 开启 30 天豪华套餐发生错误, 请重试\n\n$msg\n" fi } @@ -17595,7 +17597,7 @@ _4gtvCron() fi done Println "$info 账号验证成功" - Println "$info 开启 7 天豪华套餐" + Println "$info 开启 30 天豪华套餐" IFS="^" read -r result msg < <(CurlFake -s -Lm 20 \ -H 'Origin: https://www.4gtv.tv' \ @@ -17607,9 +17609,9 @@ _4gtvCron() if [ "$result" = true ] then - Println "$info 7 天豪华套餐开启成功\n" + Println "$info 30 天豪华套餐开启成功\n" else - Println "$error 开启 7 天豪华套餐发生错误, 请重试\n\n$msg\n" + Println "$error 开启 30 天豪华套餐发生错误, 请重试\n\n$msg\n" fi } @@ -32287,7 +32289,7 @@ gpgkey=https://www.mongodb.org/static/pgp/server-4.4.asc if [[ $(ps --no-headers -o comm 1) == "systemd" ]] then sed -i "s/LimitNOFILE=.*/LimitNOFILE=$file_max/" /lib/systemd/system/mongod.service - sed -i '/TasksAccounting=/a RestartSec=5\nStartLimitIntervalSec=0\nRestart=on-failure' /lib/systemd/system/mongod.service + sed -i '/TasksAccounting=/a StartLimitInterval=60s\nStartLimitBurst=5\nRestartSec=5\nRestart=on-failure' /lib/systemd/system/mongod.service systemctl daemon-reload sed -i "s/destination: file/destination: syslog/" /etc/mongod.conf sed -i "s/ logAppend: true/ #logAppend: true/" /etc/mongod.conf @@ -48089,6 +48091,8 @@ Usage() `gettext \"pve 打开 Proxmox VE 管理面板\"` + `gettext \"tv backup 备份所有重要文件\"` + `gettext \"tv ed 选择默认编辑器\"` `gettext \"tv a 设置自定义命令\"` @@ -49117,8 +49121,9 @@ Wants=network-online.target [Service] ExecStart=$HOME/go/bin/go-mmproxy --allowed-subnets $HOME/allowed-subnets.txt -l $mmproxy_listen -4 $mmproxy_target_v4 -6 $mmproxy_target_v6 +StartLimitInterval=60s +StartLimitBurst=5 RestartSec=5 -StartLimitIntervalSec=0 Restart=on-failure [Install] @@ -49364,7 +49369,7 @@ then V2_LINK="https://raw.githubusercontent.com/XTLS/Xray-install/main/install-release.sh" V2_LINK_FALLBACK="$FFMPEG_MIRROR_LINK/xray_install-release.sh" V2CTL_FILE="/usr/local/bin/xray" - V2_CONFIG="/usr/local/etc/xray/config.json" + V2_CONFIG="$X_CONFIG" elif [ -d /etc/v2ray/ ] then systemctl disable v2ray --now > /dev/null 2> /dev/null || true @@ -52421,6 +52426,13 @@ then Println "$error jq.json 下载出错, 无法连接 github ?" fi + if curl -s -L "https://api.github.com/repos/alist-org/alist/releases/latest" -o "$FFMPEG_MIRROR_ROOT/alist.json_tmp" + then + mv "$FFMPEG_MIRROR_ROOT/alist.json_tmp" "$FFMPEG_MIRROR_ROOT/alist.json" + else + Println "$error alist.json 下载出错, 无法连接 github ?" + fi + if curl -s -L "https://api.github.com/repos/v2fly/v2ray-core/releases/latest" -o "$FFMPEG_MIRROR_ROOT/v2ray.json_tmp" then mv "$FFMPEG_MIRROR_ROOT/v2ray.json_tmp" "$FFMPEG_MIRROR_ROOT/v2ray.json" @@ -52840,6 +52852,176 @@ then fi exit 0 ;; + b|backup) + IPTV_ROOT="${IPTV_ROOT%/}" + FFMPEG_MIRROR_ROOT="${FFMPEG_MIRROR_ROOT%/}" + LIVE_ROOT="${LIVE_ROOT%/}" + NODE_ROOT="${NODE_ROOT%/}" + + iptv_source="$IPTV_ROOT" + + iptv_excludes=( + /ffmpeg-git-'*' + /vip + node_modules/ + ) + + ffmpeg_excludes=( + /Amlogic_s905-kernel-master.zip + /builds + /c + /dnscrypt + /fontforge-20190413.tar.gz + /imgcat.zip + /jq-'*' + /releases + /v2ray + /xray + '*'.ipk + '*'.err + '*'.log + '*'.pid + ) + + if [[ "$FFMPEG_MIRROR_ROOT" =~ "$iptv_source"(.*) ]] + then + relative_path="${BASH_REMATCH[1]:-}" + relative_path="${relative_path#/}" + if [ -n "$relative_path" ] + then + for i in "${!ffmpeg_excludes[@]}" + do + if [[ "${ffmpeg_excludes[i]}" == /* ]] + then + ffmpeg_excludes[i]="/${relative_path}${ffmpeg_excludes[i]}" + else + ffmpeg_excludes[i]="/$relative_path/${ffmpeg_excludes[i]}" + fi + done + fi + iptv_excludes+=("${ffmpeg_excludes[@]}") + else + ffmpeg_source="$FFMPEG_MIRROR_ROOT" + fi + + if [[ "$LIVE_ROOT" =~ "$IPTV_ROOT"(.+) ]] + then + iptv_excludes+=("${BASH_REMATCH[1]}") + fi + + node_excludes=( + node_modules/ + ) + + if ! [[ "$NODE_ROOT" =~ "$IPTV_ROOT"(.*) ]] + then + node_source="$NODE_ROOT" + fi + + nginx_source=/usr/local/nginx + + nginx_includes=( + /conf/'***' + /html/'***' + /logs/'***' + ) + + nginx_excludes=( + /logs/'*'.gz + node_modules/ + ) + + openresty_source=/usr/local/openresty + + openresty_includes=( + /nginx/ + /nginx/conf/'***' + /nginx/html/'***' + /nginx/logs/'***' + /nginx/lua/'***' + ) + + openresty_excludes=( + /nginx/logs/'*'.gz + node_modules/ + ) + + v2ray_source="${V2_CONFIG%/*}" + + xray_source="${X_CONFIG%/*}" + + DistCheck + + if [ "$dist" == "mac" ] + then + systemd_source="$HOME"/iptv_sh_systemd + else + systemd_source=/etc/systemd/system + fi + + systemd_includes=( + /alist.service + /aria2.service + /dnscrypt-proxy.service + /mmproxy-'*'.service + /nginx.service + /openresty.service + /v2ray.service + /xray.service + ) + + DepInstall rsync + + mkdir -p "$BACKUP_ROOT" + + for backup in iptv nginx openresty v2ray xray ffmpeg node systemd + do + rsync_commands=() + source="${backup}_source" + + if [[ -z "${!source:-}" ]] + then + continue + fi + + source="${!source}" + + if [ ! -d "$source" ] + then + continue + fi + + excludes=("${backup}_excludes"[@]) + + if [[ -n "${!excludes:-}" ]] + then + excludes=("${!excludes}") + for exclude in "${excludes[@]}" + do + rsync_commands+=( --exclude="$exclude" ) + done + fi + + includes=("${backup}_includes"[@]) + + if [[ -n "${!includes:-}" ]] + then + includes=("${!includes}") + for include in "${includes[@]}" + do + rsync_commands+=( --include="$include" ) + done + + rsync_commands+=( --exclude='*' ) + fi + + rsync -avP --safe-links --del ${rsync_commands[@]+"${rsync_commands[@]}"} "$source/" "$BACKUP_ROOT/$backup/" + done + + Println "$info 已创建备份 $BACKUP_ROOT\n" + + exit 0 + ;; *) ;; esac @@ -52855,7 +53037,7 @@ then Menu fi else - while getopts "i:l:P:o:p:S:t:s:c:v:a:f:d:q:b:r:k:K:m:n:z:H:T:L:CRe" flag + while getopts "i:l:P:o:p:S:t:s:c:v:a:f:d:q:b:r:k:K:m:n:z:H:T:L:CReh" flag do case "$flag" in i) stream_link="$OPTARG";; @@ -52885,7 +53067,7 @@ else H) flv_h265=true;; T) flv_push_link="$OPTARG";; L) flv_pull_link="$OPTARG";; - *) Usage; + h|*) Usage; esac done diff --git a/env b/env index c9d46f2..52a92f6 100644 --- a/env +++ b/env @@ -32,6 +32,9 @@ FFMPEG_FILE=/usr/local/bin/ffmpeg FFPROBE_FILE=/usr/local/bin/ffprobe CURL_IMPERSONATE_FILE=/usr/local/bin/curl-impersonate +# backup +BACKUP_ROOT="$HOME"/iptv_sh_backup + # FFmpeg FFMPEG_ROOT="$HOME" @@ -54,7 +57,6 @@ XTREAM_CODES_EXAM="$IPTV_ROOT"/xtream_codes_exam IP_DENY="$IPTV_ROOT"/ip.deny IP_LOG="$IPTV_ROOT"/ip.log LIVE_ROOT="$IPTV_ROOT"/live -SERVICES_FILE="$IPTV_ROOT"/services.json VIP_FILE="$IPTV_ROOT"/vip.json VIP_CHANNELS_LINK="$FFMPEG_MIRROR_LINK"/vip_channels.json VIP_CHANNELS_FILE="$IPTV_ROOT"/vip_channels.json @@ -80,6 +82,7 @@ V2_CONFIG=/usr/local/etc/v2ray/config.json # xray X_FILE=/usr/local/bin/x +X_CONFIG=/usr/local/etc/xray/config.json # cloudflare CF_FILE=/usr/local/bin/cf @@ -98,8 +101,18 @@ IBM_FILE=/usr/local/bin/ibm IBM_APPS_ROOT="$HOME"/ibm_apps IBM_CONFIG="$HOME"/ibm.json +# Services +SERVICES_ROOT="$HOME"/iptv_sh_services +SERVICES_CONFIG="$SERVICES_ROOT"/config.json + # Alist ALIST_FILE=/usr/local/bin/ali +ALIST_ROOT="$SERVICES_ROOT"/alist +ALIST_LINK=https://github.com/alist-org/alist +ALIST_LINK_FALLBACK="$FFMPEG_MIRROR_LINK"/alist # LianHuanHua LIANHUANHUA_FILE=/usr/local/bin/lhh + +# Rclone +RCLONE_FILE=/usr/local/bin/rc diff --git a/iptv.sh b/iptv.sh index b85ec62..5467c1e 100755 --- a/iptv.sh +++ b/iptv.sh @@ -34,6 +34,7 @@ IP_DENY="$IPTV_ROOT/ip.deny" IP_LOG="$IPTV_ROOT/ip.log" FFMPEG_LOG_ROOT="$IPTV_ROOT/ffmpeg" # create your own mirror: tv ffmpeg +BACKUP_ROOT="$HOME"/iptv_sh_backup FFMPEG_MIRROR_LINK="http://pngquant.com/ffmpeg" V2_FILE="/usr/local/bin/v2" V2_LINK="https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh" @@ -41,6 +42,7 @@ V2_LINK_FALLBACK="$FFMPEG_MIRROR_LINK/v2ray_install-release.sh" V2CTL_FILE="/usr/local/bin/v2ctl" V2_CONFIG="/usr/local/etc/v2ray/config.json" X_FILE="/usr/local/bin/x" +X_CONFIG="/usr/local/etc/xray/config.json" FFMPEG_MIRROR_ROOT="$IPTV_ROOT/ffmpeg" LIVE_ROOT="$IPTV_ROOT/live" SERVICES_FILE="$IPTV_ROOT/services.json" @@ -136,10 +138,10 @@ ArchCheck() if grep -Eqi "x86_64|amd64" <<< "$arch" then arch="x86_64" - elif grep -Eqi "i386|i686" <<< "$arch" + elif grep -Eqi "i386|i686|x86" <<< "$arch" then arch="i386" - elif grep -Eqi "aarch64|armv8" <<< "$arch" + elif grep -Eqi "aarch64|armv8|arm64" <<< "$arch" then arch="arm64" elif grep -qi "armv7" <<< "$arch" @@ -17052,7 +17054,7 @@ Reg4gtvAcc() | $JQ_FILE -r '[.Success,.ErrMessage]|join(" ")' ) || true - if [ "$result" = true ] + if [ "$result" = true ] || [ "$msg" = "String was not recognized as a valid DateTime." ] then if [ ! -s "$SERVICES_FILE" ] then @@ -17281,7 +17283,7 @@ Login4gtvAcc() fi done Println "$info 账号验证成功" - Println "$info 开启 7 天豪华套餐" + Println "$info 开启 30 天豪华套餐" IFS="^" read -r result msg < <(CurlFake -s -Lm 20 \ -H 'Origin: https://www.4gtv.tv' \ @@ -17293,9 +17295,9 @@ Login4gtvAcc() if [ "$result" = true ] then - Println "$info 7 天豪华套餐开启成功\n" + Println "$info 30 天豪华套餐开启成功\n" else - Println "$error 开启 7 天豪华套餐发生错误, 请重试\n\n$msg\n" + Println "$error 开启 30 天豪华套餐发生错误, 请重试\n\n$msg\n" fi } @@ -17595,7 +17597,7 @@ _4gtvCron() fi done Println "$info 账号验证成功" - Println "$info 开启 7 天豪华套餐" + Println "$info 开启 30 天豪华套餐" IFS="^" read -r result msg < <(CurlFake -s -Lm 20 \ -H 'Origin: https://www.4gtv.tv' \ @@ -17607,9 +17609,9 @@ _4gtvCron() if [ "$result" = true ] then - Println "$info 7 天豪华套餐开启成功\n" + Println "$info 30 天豪华套餐开启成功\n" else - Println "$error 开启 7 天豪华套餐发生错误, 请重试\n\n$msg\n" + Println "$error 开启 30 天豪华套餐发生错误, 请重试\n\n$msg\n" fi } @@ -32287,7 +32289,7 @@ gpgkey=https://www.mongodb.org/static/pgp/server-4.4.asc if [[ $(ps --no-headers -o comm 1) == "systemd" ]] then sed -i "s/LimitNOFILE=.*/LimitNOFILE=$file_max/" /lib/systemd/system/mongod.service - sed -i '/TasksAccounting=/a RestartSec=5\nStartLimitIntervalSec=0\nRestart=on-failure' /lib/systemd/system/mongod.service + sed -i '/TasksAccounting=/a StartLimitInterval=60s\nStartLimitBurst=5\nRestartSec=5\nRestart=on-failure' /lib/systemd/system/mongod.service systemctl daemon-reload sed -i "s/destination: file/destination: syslog/" /etc/mongod.conf sed -i "s/ logAppend: true/ #logAppend: true/" /etc/mongod.conf @@ -48089,6 +48091,8 @@ Usage() `gettext \"pve 打开 Proxmox VE 管理面板\"` + `gettext \"tv backup 备份所有重要文件\"` + `gettext \"tv ed 选择默认编辑器\"` `gettext \"tv a 设置自定义命令\"` @@ -49117,8 +49121,9 @@ Wants=network-online.target [Service] ExecStart=$HOME/go/bin/go-mmproxy --allowed-subnets $HOME/allowed-subnets.txt -l $mmproxy_listen -4 $mmproxy_target_v4 -6 $mmproxy_target_v6 +StartLimitInterval=60s +StartLimitBurst=5 RestartSec=5 -StartLimitIntervalSec=0 Restart=on-failure [Install] @@ -49364,7 +49369,7 @@ then V2_LINK="https://raw.githubusercontent.com/XTLS/Xray-install/main/install-release.sh" V2_LINK_FALLBACK="$FFMPEG_MIRROR_LINK/xray_install-release.sh" V2CTL_FILE="/usr/local/bin/xray" - V2_CONFIG="/usr/local/etc/xray/config.json" + V2_CONFIG="$X_CONFIG" elif [ -d /etc/v2ray/ ] then systemctl disable v2ray --now > /dev/null 2> /dev/null || true @@ -52421,6 +52426,13 @@ then Println "$error jq.json 下载出错, 无法连接 github ?" fi + if curl -s -L "https://api.github.com/repos/alist-org/alist/releases/latest" -o "$FFMPEG_MIRROR_ROOT/alist.json_tmp" + then + mv "$FFMPEG_MIRROR_ROOT/alist.json_tmp" "$FFMPEG_MIRROR_ROOT/alist.json" + else + Println "$error alist.json 下载出错, 无法连接 github ?" + fi + if curl -s -L "https://api.github.com/repos/v2fly/v2ray-core/releases/latest" -o "$FFMPEG_MIRROR_ROOT/v2ray.json_tmp" then mv "$FFMPEG_MIRROR_ROOT/v2ray.json_tmp" "$FFMPEG_MIRROR_ROOT/v2ray.json" @@ -52840,6 +52852,176 @@ then fi exit 0 ;; + b|backup) + IPTV_ROOT="${IPTV_ROOT%/}" + FFMPEG_MIRROR_ROOT="${FFMPEG_MIRROR_ROOT%/}" + LIVE_ROOT="${LIVE_ROOT%/}" + NODE_ROOT="${NODE_ROOT%/}" + + iptv_source="$IPTV_ROOT" + + iptv_excludes=( + /ffmpeg-git-'*' + /vip + node_modules/ + ) + + ffmpeg_excludes=( + /Amlogic_s905-kernel-master.zip + /builds + /c + /dnscrypt + /fontforge-20190413.tar.gz + /imgcat.zip + /jq-'*' + /releases + /v2ray + /xray + '*'.ipk + '*'.err + '*'.log + '*'.pid + ) + + if [[ "$FFMPEG_MIRROR_ROOT" =~ "$iptv_source"(.*) ]] + then + relative_path="${BASH_REMATCH[1]:-}" + relative_path="${relative_path#/}" + if [ -n "$relative_path" ] + then + for i in "${!ffmpeg_excludes[@]}" + do + if [[ "${ffmpeg_excludes[i]}" == /* ]] + then + ffmpeg_excludes[i]="/${relative_path}${ffmpeg_excludes[i]}" + else + ffmpeg_excludes[i]="/$relative_path/${ffmpeg_excludes[i]}" + fi + done + fi + iptv_excludes+=("${ffmpeg_excludes[@]}") + else + ffmpeg_source="$FFMPEG_MIRROR_ROOT" + fi + + if [[ "$LIVE_ROOT" =~ "$IPTV_ROOT"(.+) ]] + then + iptv_excludes+=("${BASH_REMATCH[1]}") + fi + + node_excludes=( + node_modules/ + ) + + if ! [[ "$NODE_ROOT" =~ "$IPTV_ROOT"(.*) ]] + then + node_source="$NODE_ROOT" + fi + + nginx_source=/usr/local/nginx + + nginx_includes=( + /conf/'***' + /html/'***' + /logs/'***' + ) + + nginx_excludes=( + /logs/'*'.gz + node_modules/ + ) + + openresty_source=/usr/local/openresty + + openresty_includes=( + /nginx/ + /nginx/conf/'***' + /nginx/html/'***' + /nginx/logs/'***' + /nginx/lua/'***' + ) + + openresty_excludes=( + /nginx/logs/'*'.gz + node_modules/ + ) + + v2ray_source="${V2_CONFIG%/*}" + + xray_source="${X_CONFIG%/*}" + + DistCheck + + if [ "$dist" == "mac" ] + then + systemd_source="$HOME"/iptv_sh_systemd + else + systemd_source=/etc/systemd/system + fi + + systemd_includes=( + /alist.service + /aria2.service + /dnscrypt-proxy.service + /mmproxy-'*'.service + /nginx.service + /openresty.service + /v2ray.service + /xray.service + ) + + DepInstall rsync + + mkdir -p "$BACKUP_ROOT" + + for backup in iptv nginx openresty v2ray xray ffmpeg node systemd + do + rsync_commands=() + source="${backup}_source" + + if [[ -z "${!source:-}" ]] + then + continue + fi + + source="${!source}" + + if [ ! -d "$source" ] + then + continue + fi + + excludes=("${backup}_excludes"[@]) + + if [[ -n "${!excludes:-}" ]] + then + excludes=("${!excludes}") + for exclude in "${excludes[@]}" + do + rsync_commands+=( --exclude="$exclude" ) + done + fi + + includes=("${backup}_includes"[@]) + + if [[ -n "${!includes:-}" ]] + then + includes=("${!includes}") + for include in "${includes[@]}" + do + rsync_commands+=( --include="$include" ) + done + + rsync_commands+=( --exclude='*' ) + fi + + rsync -avP --safe-links --del ${rsync_commands[@]+"${rsync_commands[@]}"} "$source/" "$BACKUP_ROOT/$backup/" + done + + Println "$info 已创建备份 $BACKUP_ROOT\n" + + exit 0 + ;; *) ;; esac @@ -52855,7 +53037,7 @@ then Menu fi else - while getopts "i:l:P:o:p:S:t:s:c:v:a:f:d:q:b:r:k:K:m:n:z:H:T:L:CRe" flag + while getopts "i:l:P:o:p:S:t:s:c:v:a:f:d:q:b:r:k:K:m:n:z:H:T:L:CReh" flag do case "$flag" in i) stream_link="$OPTARG";; @@ -52885,7 +53067,7 @@ else H) flv_h265=true;; T) flv_push_link="$OPTARG";; L) flv_pull_link="$OPTARG";; - *) Usage; + h|*) Usage; esac done diff --git a/src/_4gtv/cron b/src/_4gtv/cron index cd320b6..168c57b 100644 --- a/src/_4gtv/cron +++ b/src/_4gtv/cron @@ -12,9 +12,9 @@ _4gtvCron() if [ "$result" = true ] then - if [ ! -s "$SERVICES_FILE" ] + if [ ! -s "$SERVICES_CONFIG" ] then - printf '{"%s":{"%s":[]}}' "4gtv" "accounts" > "$SERVICES_FILE" + printf '{"%s":{"%s":[]}}' "4gtv" "accounts" > "$SERVICES_CONFIG" fi new_acc=$( $JQ_FILE -n --arg email "$_4gtv_acc_email" --arg password "$_4gtv_acc_pass" \ @@ -24,7 +24,7 @@ _4gtvCron() }' ) jq_path='["4gtv","accounts"]' - JQ add "$SERVICES_FILE" "[$new_acc]" + JQ add "$SERVICES_CONFIG" "[$new_acc]" Println "$info 账号注册成功\n" else Println "$error 账号注册失败, 请重试\n\n$msg\n" @@ -79,7 +79,7 @@ _4gtvCron() map_string=true jq_path='["4gtv","accounts"]' jq_path2='["token"]' - JQ update "$SERVICES_FILE" email "$_4gtv_acc_email" "$token" + JQ update "$SERVICES_CONFIG" email "$_4gtv_acc_email" "$token" Println "$info 账号登录成功" Println "$info 验证账号..." @@ -102,7 +102,7 @@ _4gtvCron() fi done Println "$info 账号验证成功" - Println "$info 开启 7 天豪华套餐" + Println "$info 开启 30 天豪华套餐" IFS="^" read -r result msg < <(CurlFake -s -Lm 20 \ -H 'Origin: https://www.4gtv.tv' \ @@ -114,8 +114,8 @@ _4gtvCron() if [ "$result" = true ] then - Println "$info 7 天豪华套餐开启成功\n" + Println "$info 30 天豪华套餐开启成功\n" else - Println "$error 开启 7 天豪华套餐发生错误, 请重试\n\n$msg\n" + Println "$error 开启 30 天豪华套餐发生错误, 请重试\n\n$msg\n" fi } diff --git a/src/_4gtv/del_acc b/src/_4gtv/del_acc index 910c478..4b8c760 100644 --- a/src/_4gtv/del_acc +++ b/src/_4gtv/del_acc @@ -22,7 +22,7 @@ Del4gtvAcc() then _4gtv_accs_index=$((_4gtv_accs_num-1)) jq_path='["4gtv","accounts",'"$_4gtv_accs_index"']' - JQ delete "$SERVICES_FILE" + JQ delete "$SERVICES_CONFIG" Println "$info 账号删除成功\n" break else diff --git a/src/_4gtv/edit_acc b/src/_4gtv/edit_acc index a2fe6f8..6d639b3 100644 --- a/src/_4gtv/edit_acc +++ b/src/_4gtv/edit_acc @@ -32,7 +32,7 @@ Edit4gtvAcc() ) json=true jq_path='["4gtv","accounts",'"$_4gtv_accs_index"']' - JQ update "$SERVICES_FILE" "$new_acc" + JQ update "$SERVICES_CONFIG" "$new_acc" Println "$info 账号修改成功\n" break else diff --git a/src/_4gtv/list_accs b/src/_4gtv/list_accs index 92c246c..4852d9a 100644 --- a/src/_4gtv/list_accs +++ b/src/_4gtv/list_accs @@ -1,6 +1,6 @@ List4gtvAccs() { - GetServiceAccs 4gtv + ServiceGetAccs 4gtv _4gtv_accs_list="" for((i=0;i<_4gtv_accs_count;i++)); diff --git a/src/_4gtv/login_acc b/src/_4gtv/login_acc index ba8cadd..d338ccf 100644 --- a/src/_4gtv/login_acc +++ b/src/_4gtv/login_acc @@ -32,7 +32,7 @@ Login4gtvAcc() }' ) jq_path='["4gtv","accounts"]' - JQ add "$SERVICES_FILE" "[$new_acc]" + JQ add "$SERVICES_CONFIG" "[$new_acc]" Println "$info 账号添加成功\n" break ;; @@ -95,7 +95,7 @@ Login4gtvAcc() done jq_path='["4gtv","accounts",'"$_4gtv_accs_index"',"token"]' - JQ update "$SERVICES_FILE" "$token" + JQ update "$SERVICES_CONFIG" "$token" Println "$info 账号登录成功" Println "$info 验证账号..." for((i=0;i<3;i++)); @@ -117,7 +117,7 @@ Login4gtvAcc() fi done Println "$info 账号验证成功" - Println "$info 开启 7 天豪华套餐" + Println "$info 开启 30 天豪华套餐" IFS="^" read -r result msg < <(CurlFake -s -Lm 20 \ -H 'Origin: https://www.4gtv.tv' \ @@ -129,8 +129,8 @@ Login4gtvAcc() if [ "$result" = true ] then - Println "$info 7 天豪华套餐开启成功\n" + Println "$info 30 天豪华套餐开启成功\n" else - Println "$error 开启 7 天豪华套餐发生错误, 请重试\n\n$msg\n" + Println "$error 开启 30 天豪华套餐发生错误, 请重试\n\n$msg\n" fi } diff --git a/src/_4gtv/reg_acc b/src/_4gtv/reg_acc index 14227f7..b3461e2 100644 --- a/src/_4gtv/reg_acc +++ b/src/_4gtv/reg_acc @@ -10,11 +10,11 @@ Reg4gtvAcc() | $JQ_FILE -r '[.Success,.ErrMessage]|join(" ")' ) || true - if [ "$result" = true ] + if [ "$result" = true ] || [ "$msg" = "String was not recognized as a valid DateTime." ] then - if [ ! -s "$SERVICES_FILE" ] + if [ ! -s "$SERVICES_CONFIG" ] then - printf '{"%s":{"%s":[]}}' "4gtv" "accounts" > "$SERVICES_FILE" + printf '{"%s":{"%s":[]}}' "4gtv" "accounts" > "$SERVICES_CONFIG" fi new_acc=$( $JQ_FILE -n --arg email "$_4gtv_acc_email" --arg password "$_4gtv_acc_pass" \ @@ -24,7 +24,7 @@ Reg4gtvAcc() }' ) jq_path='["4gtv","accounts"]' - JQ add "$SERVICES_FILE" "[$new_acc]" + JQ add "$SERVICES_CONFIG" "[$new_acc]" Println "$info 账号注册成功\n" else Println "$error 账号注册失败, 请重试\n\n$msg\n" diff --git a/src/ali b/src/ali index 9654010..e2c8287 100644 --- a/src/ali +++ b/src/ali @@ -1,9 +1,6 @@ -Include src/iptv/get_service -Include src/alist/add_app -Include src/alist/view_app -Include src/alist/add_acc -Include src/alist/view_acc -Include src/alist/login_acc +Include src/service/get_accs +Include src/alist/app +Include src/alist/acc Include src/alist/api Include src/alist/act @@ -17,19 +14,19 @@ case $alist_options_index in ;; 1) echo - alist_app_options=( '查看' '添加' '安装' '修改' '删除' ) + alist_app_options=( '查看' '添加' '修改' '删除' '本地安装/升级' ) inquirer list_input_index "选择操作" alist_app_options alist_app_options_index case $alist_app_options_index in - 0) AlistViewApp + 0) AlistAppView ;; - 1) AlistAddApp + 1) AlistAppAdd ;; - 2) AlistInstallApp + 2) AlistAppEdit ;; - 3) AlistEditApp + 3) AlistAppDel ;; - 4) AlistDelApp + 4) AlistAppInstall ;; esac ;; @@ -39,15 +36,15 @@ case $alist_options_index in inquirer list_input_index "选择操作" alist_acc_options alist_acc_options_index case $alist_acc_options_index in - 0) AlistViewAcc + 0) AlistAccView ;; - 1) AlistAddAcc + 1) AlistAccAdd ;; - 2) AlistLoginAcc + 2) AlistAccLogin ;; - 3) AlistEditAcc + 3) AlistAccEdit ;; - 4) AlistDelAcc + 4) AlistAccDel ;; esac ;; diff --git a/src/alist/acc b/src/alist/acc new file mode 100644 index 0000000..3ceb2b7 --- /dev/null +++ b/src/alist/acc @@ -0,0 +1,192 @@ +AlistAccAdd() +{ + ServiceGetAccs alist + + if [ "$alists_count" -eq 0 ] + then + Println "$error 请先添加 Alist\n" + exit 1 + fi + + alists_options=() + for((i=0;i $alist_file_name\n" + Alist.fs.rename + done else echo alist_files_txt="" diff --git a/src/alist/add_acc b/src/alist/add_acc deleted file mode 100644 index 8d2effc..0000000 --- a/src/alist/add_acc +++ /dev/null @@ -1,70 +0,0 @@ -AlistAddAcc() -{ - GetServiceAccs alist - - if [ "$alists_count" -eq 0 ] - then - Println "$error 请先添加 Alist\n" - exit 1 - fi - - alists_options=() - for((i=0;i/dev/null || true + fi + + printf -v date '%(%m-%d-%H:%M:%S)T' -1 + alist_backup="$ALIST_ROOT-$date" + mv "$ALIST_ROOT" "$alist_backup" + else + echo + ExitOnText "设置 Alist admin 密码" alist_pass + fi + + if [ "$dist" == "mac" ] + then + alist_pack_name="alist-darwin" + else + alist_pack_name="alist-linux-musl" + fi + + ArchCheck + + if [ "$arch" == "x86_64" ] + then + alist_pack_name="${alist_pack_name}-amd64.tar.gz" + elif [ "$arch" == "s390x" ] + then + alist_pack_name="${alist_pack_name}-s390x.tar.gz" + else + alist_pack_name="${alist_pack_name}-arm64.tar.gz" + fi + + if ! TMP_DIR=$(mktemp -q -d) + then + printf -v TMP_DIR '%(%m-%d-%H:%M:%S)T' -1 + mkdir -p "$TMP_DIR" + fi + + trap ' + rm -rf "${TMP_DIR:-notfound}" + ' EXIT + + cd "$TMP_DIR" + + if ! curl -O -L "$ALIST_LINK/releases/latest/download/$alist_pack_name" && ! curl -O -L "$ALIST_LINK_FALLBACK/releases/latest/download/$alist_pack_name" + then + Println "$error 无法下载 Alist, 请稍后再试\n" + return 1 + fi + + mkdir "$ALIST_ROOT" + tar zxf "$TMP_DIR/$alist_pack_name" -C "$ALIST_ROOT"/ + + if [ -n "${alist_backup:-}" ] && [ -d "${alist_backup}/data" ] + then + cp -r "$alist_backup"/data "$ALIST_ROOT"/ + else + mkdir -p "$ALIST_ROOT"/data/log + alist_config=$( + $JQ_FILE -n --arg db_file "${ALIST_ROOT}/data/data.db" --arg bleve_dir "${ALIST_ROOT}/data/bleve" \ + --arg log "${ALIST_ROOT}/data/log/log.log" \ + '{ + "force": false, + "site_url": "", + "cdn": "", + "jwt_secret": "", + "token_expires_in": 48, + "database": { + "type": "sqlite3", + "host": "", + "port": 0, + "user": "", + "password": "", + "name": "", + "db_file": $db_file, + "table_prefix": "x_", + "ssl_mode": "", + "dsn": "" + }, + "meilisearch": { + "host": "http://localhost:7700", + "api_key": "", + "index_prefix": "" + }, + "scheme": { + "address": "127.0.0.1", + "http_port": 5244, + "https_port": -1, + "force_https": false, + "cert_file": "", + "key_file": "", + "unix_file": "", + "unix_file_perm": "" + }, + "temp_dir": "/tmp/alist", + "bleve_dir": $bleve_dir, + "dist_dir": "", + "log": { + "enable": true, + "name": $log, + "max_size": 10, + "max_backups": 5, + "max_age": 28, + "compress": false + }, + "delayed_start": 0, + "max_connections": 0, + "tls_insecure_skip_verify": true, + "tasks": { + "download": { + "workers": 5, + "max_retry": 1 + }, + "transfer": { + "workers": 5, + "max_retry": 2 + }, + "upload": { + "workers": 5, + "max_retry": 0 + }, + "copy": { + "workers": 5, + "max_retry": 2 + } + }, + "cors": { + "allow_origins": [ + "*" + ], + "allow_methods": [ + "*" + ], + "allow_headers": [ + "*" + ] + }, + "s3": { + "enable": false, + "port": 5246, + "ssl": false + } + }' + ) + + echo "$alist_config" > "$ALIST_ROOT"/data/config.json + cd "$ALIST_ROOT" + ./alist admin set "$alist_pass" + fi + + if [ "$dist" == "mac" ] + then + if [ ! -f "$HOME"/Library/LaunchAgents/com.aios.alist.plist ] + then +echo ' + + + + Label + com.aios.alist + ProgramArguments + + '"$ALIST_ROOT"'/alist + server + --data + '"${ALIST_ROOT}"'/data + + RunAtLoad + + KeepAlive + + +' > "$HOME"/Library/LaunchAgents/com.aios.alist.plist + fi + + launchctl load ~/Library/LaunchAgents/com.aios.alist.plist + else + if [ ! -f /etc/systemd/system/alist.service ] + then +echo "[Unit] +Description=Alist service +After=syslog.target network-online.target nss-lookup.target +Wants=network-online.target + +[Service] +ExecStart=${ALIST_ROOT}/alist server --data ${ALIST_ROOT}/data +StartLimitInterval=60s +StartLimitBurst=5 +RestartSec=5 +Restart=on-failure + +[Install] +WantedBy=multi-user.target" > "/etc/systemd/system/alist.service" + + systemctl daemon-reload + systemctl enable alist + systemctl start alist + else + systemctl start alist + fi + fi + + rm -rf "${TMP_DIR:-notfound}" + trap - EXIT + + Println "$info Alist 安装成功\n" +} diff --git a/src/alist/login_acc b/src/alist/login_acc deleted file mode 100644 index 32ada05..0000000 --- a/src/alist/login_acc +++ /dev/null @@ -1,68 +0,0 @@ -AlistLoginAcc() -{ - DepInstall curl - - GetServiceAccs alist - - if [ "$alists_count" -eq 0 ] - then - Println "$error 请先添加 Alist\n" - exit 1 - fi - - alists_options=() - for((i=0;i "$SERVICES_FILE" + mkdir -p "$SERVICES_ROOT" + if [ -f "$IPTV_ROOT"/services.json ] + then + mv "$IPTV_ROOT"/services.json "$SERVICES_CONFIG" + else + printf '{"%s":{"%s":[]}}' "$service_id" "accounts" > "$SERVICES_CONFIG" + fi fi SetDelimiters if [ "$service_id" == "4gtv" ] then - IFS=$'\003\t' read -r d_4gtv_proxy _4gtv_acc_email _4gtv_acc_pass _4gtv_acc_token < <(JQs flat "$SERVICES_FILE" '' ' + IFS=$'\003\t' read -r d_4gtv_proxy _4gtv_acc_email _4gtv_acc_pass _4gtv_acc_token < <(JQs flat "$SERVICES_CONFIG" '' ' [(."'"$service_id"'".proxy // "") + "\u0003"] + ((."'"$service_id"'".accounts | if (.|type == "string") then {} else . end) as $accounts | reduce ({email,password,token}|keys_unsorted[]) as $key ([]; $accounts[$key] as $val | if $val then @@ -29,7 +35,7 @@ GetServiceAccs() elif [ "$service_id" == "alist" ] then IFS=$'\004\t' read -r alist_name alist_url alist_acc_username \ - alist_acc_password alist_acc_token < <(JQs flat "$SERVICES_FILE" '' ' + alist_acc_password alist_acc_token < <(JQs flat "$SERVICES_CONFIG" '' ' (."'"$service_id"'" | if (.|type == "string") then {} else . end) as $alist | ($alist.accs // {} | if (.|type) == "string" then {} else . end) as $accs | reduce ({name,url}|keys_unsorted[]) as $key ([]; @@ -53,8 +59,38 @@ GetServiceAccs() IFS="${delimiters[2]}" read -r -a alists_acc_token <<< "$alist_acc_token" alists_count=${#alists_name[@]} + elif [ "$service_id" == "rclone" ] + then + IFS=$'\004\t' read -r m_remotes_name m_remotes_type m_remotes_url \ + m_remotes_vendor m_remotes_user m_remotes_pass m_remotes_path m_remotes_mount_path < <(JQs flat "$SERVICES_CONFIG" '.[0].rclone.remote' ' + (if (.|type == "string") then {} else . end) as $remote | + ($remote.mount // {} | if (.|type) == "string" then {} else . end) as $mount | + reduce ({name,type,url,vendor,user,pass}|keys_unsorted[]) as $key ([]; + $remote[$key] as $val | if $val then + . + [$val + "\u0002\u0004"] + else + . + ["\u0004"] + end + ) + reduce ({path,mount_path}|keys_unsorted[]) as $key ([]; + $mount[$key] as $val | if $val then + . + [$val + "\u0003\u0004"] + else + . + ["\u0004"] + end + )|@tsv' "${delimiters[@]}") + + IFS="${delimiters[1]}" read -r -a rclone_remotes_name <<< "$m_remotes_name" + IFS="${delimiters[1]}" read -r -a rclone_remotes_type <<< "$m_remotes_type" + IFS="${delimiters[1]}" read -r -a rclone_remotes_url <<< "$m_remotes_url" + IFS="${delimiters[1]}" read -r -a rclone_remotes_vendor <<< "$m_remotes_vendor" + IFS="${delimiters[1]}" read -r -a rclone_remotes_user <<< "$m_remotes_user" + IFS="${delimiters[1]}" read -r -a rclone_remotes_pass <<< "$m_remotes_pass" + IFS="${delimiters[2]}" read -r -a rclone_remotes_path <<< "$m_remotes_path" + IFS="${delimiters[2]}" read -r -a rclone_remotes_mount_path <<< "$m_remotes_mount_path" + + rclone_remotes_count=${#rclone_remotes_name[@]} else - IFS=$'\003\t' read -r m_user_name m_phone_number m_password m_access_token m_device_no m_device_id m_refresh < <(JQs flat "$SERVICES_FILE" '' ' + IFS=$'\003\t' read -r m_user_name m_phone_number m_password m_access_token m_device_no m_device_id m_refresh < <(JQs flat "$SERVICES_CONFIG" '' ' (."'"$service_id"'".accounts | if (.|type == "string") then {} else . end) as $accounts | reduce ({user_name,phone_number,password,access_token,device_no,device_id,refresh}|keys_unsorted[]) as $key ([]; $accounts[$key] as $val | if $val then diff --git a/src/service/obscure b/src/service/obscure new file mode 100644 index 0000000..ae6be27 --- /dev/null +++ b/src/service/obscure @@ -0,0 +1,25 @@ +Obscure() +{ + OpensslInstall + + local hexkey="9c935b48730a554d6bfd7c63c886a92bd390198eb8128afbf4de162b8b95f638" + local hexiv=$(openssl rand -hex 16) + local buff=$(echo "$1" | openssl enc -aes-256-ctr -K "$hexkey" -iv "$hexiv") + hexiv=$(echo -n "$hexiv" | xxd -r -p) # xxd -p + local encrypted=$(echo -n "$hexiv$buff" | Base64urlEncode) + + echo "$encrypted" +} + +Deobscure() +{ + OpensslInstall + + local hexkey="9c935b48730a554d6bfd7c63c886a92bd390198eb8128afbf4de162b8b95f638" + local decoded=$(echo -n "$1" | Base64urlDecode) + local hexiv=$(echo -n "$decoded" | head -c 16 | hexdump -v -e '/1 "%02x"') # xxd -p + local buff=$(echo -n "$decoded" | tail -c +17) + local decrypted=$(echo -n "$buff" | openssl enc -aes-256-ctr -d -K "$hexkey" -iv "$hexiv" -nopad) + + echo "$decrypted" +} diff --git a/src/tv b/src/tv index 9466134..b757686 100644 --- a/src/tv +++ b/src/tv @@ -1,6 +1,3 @@ -JQ_FILE="$IPTV_ROOT"/jq -FFMPEG_ROOT="$IPTV_ROOT" - Include utils/python "$@" Include utils/ffmpeg "$@" @@ -99,7 +96,7 @@ Include src/iptv/menu_monitor "$@" Include src/iptv/menu_edit_default "$@" -Include src/iptv/get_service "$@" +Include src/service/get_accs "$@" Include src/_4gtv/set_acc "$@" @@ -541,7 +538,7 @@ then curl) Include src/iptv/cmd_curl "$@" ;; - b) + b|backup) Include src/iptv/cmd_backup "$@" ;; *) diff --git a/src/x b/src/x index 49fba56..52d6ae7 100644 --- a/src/x +++ b/src/x @@ -323,6 +323,6 @@ V2_FILE="/usr/local/bin/x" V2_LINK="https://raw.githubusercontent.com/XTLS/Xray-install/main/install-release.sh" V2_LINK_FALLBACK="$FFMPEG_MIRROR_LINK/xray_install-release.sh" V2CTL_FILE="/usr/local/bin/xray" -V2_CONFIG="/usr/local/etc/xray/config.json" +V2_CONFIG="$X_CONFIG" Include src/v2ray/menu "$@" diff --git a/utils/ffmpeg b/utils/ffmpeg index 809af84..f728a22 100644 --- a/utils/ffmpeg +++ b/utils/ffmpeg @@ -4,9 +4,9 @@ FFmpegInstall() then FFMPEG_FILE="$FFMPEG_FILE_ROOT/ffmpeg" FFPROBE_FILE="$FFMPEG_FILE_ROOT/ffprobe" - elif [ "$FFMPEG_ROOT" != "$HOME" ] && FFMPEG_FILE_ROOT=$(find "$HOME"/ffmpeg-git-* -type d 2> /dev/null | head -1) + elif FFMPEG_FILE_ROOT=$(find "$IPTV_ROOT"/ffmpeg-git-* -type d 2> /dev/null | head -1) then - FFMPEG_ROOT="$HOME" + FFMPEG_ROOT="$IPTV_ROOT" FFMPEG_FILE="$FFMPEG_FILE_ROOT/ffmpeg" FFPROBE_FILE="$FFMPEG_FILE_ROOT/ffprobe" fi diff --git a/utils/i18n b/utils/i18n index 620c8de..9d2fe50 100644 --- a/utils/i18n +++ b/utils/i18n @@ -261,6 +261,11 @@ grep() ggrep "$@" } +base64() +{ + gbase64 "$@" +} + else TEXTDOMAINDIR=/usr/share/locale fi diff --git a/utils/jq b/utils/jq index 95b6aa8..770b474 100644 --- a/utils/jq +++ b/utils/jq @@ -2,7 +2,11 @@ JQInstall() { if [[ -x "$JQ_FILE" ]] then - return 0 + return + elif [[ -x "$IPTV_ROOT"/jq ]] + then + JQ_FILE="$IPTV_ROOT"/jq + return fi DepsCheck @@ -440,7 +444,7 @@ JQs() $JQ_FILE --arg d1 "$5" --arg d2 "${6:-$5}" --arg d3 "${7:-$5}" --arg d4 "${8:-$5}" --arg d5 "${9:-$5}" --arg d6 "${10:-$5}" -r -c -s ' def flat(a;b;c;d;e;f;g): - a as $a | (a[0]| type) as $type | if ($type == "object") then + (a // [{}]) as $a | (a[0]| type) as $type | if ($type == "object") then ([a[] | keys_unsorted[]] | unique) as $keys | reduce a[] as $item ({}; reduce($keys[]) as $key (.; $item[$key] as $val | ($val | type) as $type | (.[$key]) as $val2 | ($val2 | type) as $type2 | .[$key] = @@ -501,6 +505,8 @@ JQs() flat([flat(a[];b;c;d;e;f;g)];b;c;d;e;f;g) elif ($a == [""]) then "\"\"" + elif ($a == [{}]) then + {} else a|join(b) end; diff --git a/utils/mirror b/utils/mirror index 1919bb2..b789896 100644 --- a/utils/mirror +++ b/utils/mirror @@ -308,6 +308,13 @@ else Println "$error jq.json 下载出错, 无法连接 github ?" fi +if curl -s -L "https://api.github.com/repos/alist-org/alist/releases/latest" -o "$FFMPEG_MIRROR_ROOT/alist.json_tmp" +then + mv "$FFMPEG_MIRROR_ROOT/alist.json_tmp" "$FFMPEG_MIRROR_ROOT/alist.json" +else + Println "$error alist.json 下载出错, 无法连接 github ?" +fi + if curl -s -L "https://api.github.com/repos/v2fly/v2ray-core/releases/latest" -o "$FFMPEG_MIRROR_ROOT/v2ray.json_tmp" then mv "$FFMPEG_MIRROR_ROOT/v2ray.json_tmp" "$FFMPEG_MIRROR_ROOT/v2ray.json" diff --git a/utils/mongodb b/utils/mongodb index 2e1eb4d..690d6dc 100644 --- a/utils/mongodb +++ b/utils/mongodb @@ -66,7 +66,7 @@ gpgkey=https://www.mongodb.org/static/pgp/server-4.4.asc if [[ $(ps --no-headers -o comm 1) == "systemd" ]] then sed -i "s/LimitNOFILE=.*/LimitNOFILE=$file_max/" /lib/systemd/system/mongod.service - sed -i '/TasksAccounting=/a RestartSec=5\nStartLimitIntervalSec=0\nRestart=on-failure' /lib/systemd/system/mongod.service + sed -i '/TasksAccounting=/a StartLimitInterval=60s\nStartLimitBurst=5\nRestartSec=5\nRestart=on-failure' /lib/systemd/system/mongod.service systemctl daemon-reload sed -i "s/destination: file/destination: syslog/" /etc/mongod.conf sed -i "s/ logAppend: true/ #logAppend: true/" /etc/mongod.conf diff --git a/utils/openssl b/utils/openssl index 575d3e5..3dba914 100644 --- a/utils/openssl +++ b/utils/openssl @@ -5,24 +5,13 @@ OpensslInstall() return 0 fi - echo - ExitOnList y "`gettext \"是否安装 openssl\"`" - - Progress & - progress_pid=$! - trap ' - kill $progress_pid - wait $progress_pid 2> /dev/null - ' EXIT + DepInstall openssl if [ "$dist" == "rpm" ] then - yum -y install openssl openssl-devel >/dev/null 2>&1 - else - apt-get -y install openssl libssl-dev >/dev/null 2>&1 + DepInstall openssl-devel + elif [ "$dist" != "mac" ] + then + DepInstall libssl-dev fi - kill $progress_pid - wait $progress_pid 2> /dev/null || true - trap - EXIT - echo -n "...100%" && Println "`eval_gettext \"\\\$info openssl 安装完成\"`" } diff --git a/utils/shfile b/utils/shfile index 30aa976..e57594f 100644 --- a/utils/shfile +++ b/utils/shfile @@ -107,6 +107,7 @@ ShFileCheck() [ ! -e "$PVE_FILE" ] && ln -s "$SH_FILE" "$PVE_FILE" [ ! -e "$ALIST_FILE" ] && ln -s "$SH_FILE" "$ALIST_FILE" [ ! -e "$LIANHUANHUA_FILE" ] && ln -s "$SH_FILE" "$LIANHUANHUA_FILE" + [ ! -e "$RCLONE_FILE" ] && ln -s "$SH_FILE" "$RCLONE_FILE" return 0 } diff --git a/utils/system b/utils/system index 766d70a..2e4b37e 100644 --- a/utils/system +++ b/utils/system @@ -48,10 +48,10 @@ ArchCheck() if grep -Eqi "x86_64|amd64" <<< "$arch" then arch="x86_64" - elif grep -Eqi "i386|i686" <<< "$arch" + elif grep -Eqi "i386|i686|x86" <<< "$arch" then arch="i386" - elif grep -Eqi "aarch64|armv8" <<< "$arch" + elif grep -Eqi "aarch64|armv8|arm64" <<< "$arch" then arch="arm64" elif grep -qi "armv7" <<< "$arch"