From 6c9e5df1d37748ead4148af813dc35765192a2a1 Mon Sep 17 00:00:00 2001 From: 233boy Date: Mon, 25 Feb 2019 13:54:52 +0800 Subject: [PATCH] update backup --- src/backup.sh | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++ v2ray.sh | 96 ++------------------------------------------------ 2 files changed, 99 insertions(+), 94 deletions(-) create mode 100644 src/backup.sh diff --git a/src/backup.sh b/src/backup.sh new file mode 100644 index 0000000..ce1fcda --- /dev/null +++ b/src/backup.sh @@ -0,0 +1,97 @@ +## backup config +_bakcup() { + for keys in $*; do + case $keys in + v2ray_transport) + sed -i "/v2ray_transport=$v2ray_transport/v2ray_transport=$v2ray_transport_opt/" $backup + ;; + v2ray_port) + sed -i "/v2ray_port=$v2ray_port/v2ray_port=$v2ray_port_opt/" $backup + ;; + uuid) + sed -i "/v2ray_id=$v2ray_id/v2ray_id=$uuid/" $backup + ;; + alterId) + sed -i "/alterId=$alterId/alterId=$new_alterId/" $backup + ;; + v2ray_dynamicPort_start) + sed -i "/v2ray_dynamicPort_start=$v2ray_dynamicPort_start/v2ray_dynamicPort_start=$v2ray_dynamic_port_start_input/" $backup + ;; + v2ray_dynamicPort_end) + sed -i "/v2ray_dynamicPort_end=$v2ray_dynamicPort_end/v2ray_dynamicPort_end=$v2ray_dynamic_port_end_input/" $backup + ;; + domain) + sed -i "/domain=$domain/domain=$new_domain/" $backup + ;; + caddy) + sed -i "/caddy=/caddy=true/" $backup + ;; + +ss) + sed -i "/shadowsocks=/shadowsocks=true/; /ssport=$ssport/ssport=$new_ssport/; /sspass=$sspass/sspass=$new_sspass/; /ssciphers=$ssciphers/ssciphers=$new_ssciphers/" $backup + ;; + -ss) + sed -i "/shadowsocks=true/shadowsocks=/" $backup + ;; + ssport) + sed -i "/ssport=$ssport/ssport=$new_ssport/" $backup + ;; + sspass) + sed -i "/sspass=$sspass/sspass=$new_sspass/" $backup + ;; + ssciphers) + sed -i "/ssciphers=$ssciphers/ssciphers=$new_ssciphers/" $backup + ;; + +ad) + sed -i "/ban_ad=/ban_ad=true/" $backup + ;; + -ad) + sed -i "/ban_ad=true/ban_ad=/" $backup + ;; + +path) + sed -i "/path_status=/path_status=true/; /path=$path/path=$new_path/; #proxy_site=$proxy_site#proxy_site=$new_proxy_site#" $backup + ;; + -path) + sed -i "/path_status=true/path_status=/" $backup + ;; + path) + sed -i "/path=$path/path=$new_path/" $backup + ;; + proxy_site) + sed -i "#proxy_site=$proxy_site#proxy_site=$new_proxy_site#" $backup + ;; + +socks) + sed -i "/socks=/socks=true/; /socks_port=$socks_port/socks_port=$new_socks_port/; /socks_username=$socks_username/socks_username=$new_socks_username/; /socks_userpass=$socks_userpass/socks_userpass=$new_socks_userpass/;" $backup + ;; + -socks) + sed -i "/socks=true/socks=/" $backup + ;; + socks_port) + sed -i "/socks_port=$socks_port/socks_port=$new_socks_port/" $backup + ;; + socks_username) + sed -i "/socks_username=$socks_username/socks_username=$new_socks_username/" $backup + ;; + socks_userpass) + sed -i "/socks_userpass=$socks_userpass/socks_userpass=$new_socks_userpass/" $backup + ;; + +mtproto) + sed -i "/mtproto=/mtproto=true/; /mtproto_port=$mtproto_port/mtproto_port=$new_mtproto_port/; /mtproto_secret=$mtproto_secret/mtproto_secret=$new_mtproto_secret/" $backup + ;; + -mtproto) + sed -i "/mtproto=true/mtproto=/" $backup + ;; + mtproto_port) + sed -i "/mtproto_port=$mtproto_port/mtproto_port=$new_mtproto_port/" $backup + ;; + mtproto_secret) + sed -i "/mtproto_secret=$mtproto_secret/mtproto_secret=$new_mtproto_secret/" $backup + ;; + +bt) + sed -i "/ban_bt=/ban_bt=true/" $backup + ;; + -bt) + sed -i "/ban_bt=true/ban_bt=/" $backup + ;; + esac + done +} diff --git a/v2ray.sh b/v2ray.sh index 7f44652..22607d0 100644 --- a/v2ray.sh +++ b/v2ray.sh @@ -2752,100 +2752,8 @@ config() { do_service restart v2ray } backup_config() { - for keys in $*; do - case $keys in - v2ray_transport) - sed -i "18s/=$v2ray_transport/=$v2ray_transport_opt/" $backup - ;; - v2ray_port) - sed -i "21s/=$v2ray_port/=$v2ray_port_opt/" $backup - ;; - uuid) - sed -i "24s/=$v2ray_id/=$uuid/" $backup - ;; - alterId) - sed -i "27s/=$alterId/=$new_alterId/" $backup - ;; - v2ray_dynamicPort_start) - sed -i "30s/=$v2ray_dynamicPort_start/=$v2ray_dynamic_port_start_input/" $backup - ;; - v2ray_dynamicPort_end) - sed -i "33s/=$v2ray_dynamicPort_end/=$v2ray_dynamic_port_end_input/" $backup - ;; - domain) - sed -i "36s/=$domain/=$new_domain/" $backup - ;; - caddy) - sed -i "39s/=/=true/" $backup - ;; - +ss) - sed -i "42s/=/=true/; 45s/=$ssport/=$new_ssport/; 48s/=$sspass/=$new_sspass/; 51s/=$ssciphers/=$new_ssciphers/" $backup - ;; - -ss) - sed -i "42s/=true/=/" $backup - ;; - ssport) - sed -i "45s/=$ssport/=$new_ssport/" $backup - ;; - sspass) - sed -i "48s/=$sspass/=$new_sspass/" $backup - ;; - ssciphers) - sed -i "51s/=$ssciphers/=$new_ssciphers/" $backup - ;; - +ad) - sed -i "54s/=/=true/" $backup - ;; - -ad) - sed -i "54s/=true/=/" $backup - ;; - +path) - sed -i "57s/=/=true/; 60s/=$path/=$new_path/; 63s#=$proxy_site#=$new_proxy_site#" $backup - ;; - -path) - sed -i "57s/=true/=/" $backup - ;; - path) - sed -i "60s/=$path/=$new_path/" $backup - ;; - proxy_site) - sed -i "63s#=$proxy_site#=$new_proxy_site#" $backup - ;; - +socks) - sed -i "66s/=/=true/; 69s/=$socks_port/=$new_socks_port/; 72s/=$socks_username/=$new_socks_username/; 75s/=$socks_userpass/=$new_socks_userpass/;" $backup - ;; - -socks) - sed -i "66s/=true/=/" $backup - ;; - socks_port) - sed -i "69s/=$socks_port/=$new_socks_port/" $backup - ;; - socks_username) - sed -i "72s/=$socks_username/=$new_socks_username/" $backup - ;; - socks_userpass) - sed -i "75s/=$socks_userpass/=$new_socks_userpass/" $backup - ;; - +mtproto) - sed -i "78s/=/=true/; 81s/=$mtproto_port/=$new_mtproto_port/; 84s/=$mtproto_secret/=$new_mtproto_secret/" $backup - ;; - -mtproto) - sed -i "78s/=true/=/" $backup - ;; - mtproto_port) - sed -i "81s/=$mtproto_port/=$new_mtproto_port/" $backup - ;; - mtproto_secret) - sed -i "84s/=$mtproto_secret/=$new_mtproto_secret/" $backup - ;; - +bt) - sed -i "87s/=/=true/" $backup - ;; - -bt) - sed -i "87s/=true/=/" $backup - ;; - esac - done + _load backup.sh + _backup "$@" }