Skip to content

Commit

Permalink
feat: rclone, obscure, rsync backup; fix
Browse files Browse the repository at this point in the history
  • Loading branch information
woniuzfb committed Mar 30, 2024
1 parent 35a78e3 commit 5b13358
Show file tree
Hide file tree
Showing 45 changed files with 1,495 additions and 375 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- [参数详解](#参数详解)
- [举例](#举例)
- [Alist](#alist)
- [Rclone](#rclone)
- [LianHuanHua](#lianhuanhua)
- [Dev](#dev)

Expand Down Expand Up @@ -257,6 +258,12 @@ wget https://woniuzfb.github.io/iptv/iptv.sh && bash iptv.sh
./debug ali
```

## Rclone

```bash
./debug rc
```

## LianHuanHua

```bash
Expand Down
2 changes: 1 addition & 1 deletion build
Original file line number Diff line number Diff line change
Expand Up @@ -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\" ]"
Expand Down
10 changes: 10 additions & 0 deletions core
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
210 changes: 196 additions & 14 deletions docs/iptv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ 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"
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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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' \
Expand All @@ -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
}

Expand Down Expand Up @@ -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' \
Expand All @@ -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
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -48089,6 +48091,8 @@ Usage()

`gettext \"pve 打开 Proxmox VE 管理面板\"`

`gettext \"tv backup 备份所有重要文件\"`

`gettext \"tv ed 选择默认编辑器\"`

`gettext \"tv a 设置自定义命令\"`
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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";;
Expand Down Expand Up @@ -52885,7 +53067,7 @@ else
H) flv_h265=true;;
T) flv_push_link="$OPTARG";;
L) flv_pull_link="$OPTARG";;
*) Usage;
h|*) Usage;
esac
done

Expand Down
Loading

0 comments on commit 5b13358

Please sign in to comment.