From 40212b1c2bddb55d041a7ea4b463185ae9bc8f54 Mon Sep 17 00:00:00 2001
From: Xiao Pan <xyz@flylightning.xyz>
Date: Sun, 29 Dec 2024 02:30:46 -0800
Subject: consider new ib server

---
 sh/sbar | 11 ++++++-----
 sh/upd  | 10 +++++-----
 sh/vip  |  1 +
 sh/vpn  |  2 +-
 4 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/sh/sbar b/sh/sbar
index b378619..9614b6a 100755
--- a/sh/sbar
+++ b/sh/sbar
@@ -16,11 +16,12 @@ update_time () {
 update_net () { 
 	net="$(if nmcli -t --fields type,state device | grep -q '^\(ethernet\|wifi\):connected$'; then echo 1; else echo 0; fi)"
 	case "$(nmcli -t --fields device,state device)" in
-		*wg_aa:connected*) wg=A;;
-		*wg_ca:connected*) wg=C;;
-		*wg_ia:connected*) wg=I;;
-		*wg_mydefault:connected*) wg=D;;
-		*wg_studio:connected*) wg=S;;
+		*wg_aa:connected*) wg=aa;;
+		*wg_ca:connected*) wg=ca;;
+		*wg_ia:connected*) wg=ia;;
+		*wg_ib:connected*) wg=ib;;
+		*wg_mydefault:connected*) wg=1;;
+		*wg_studio:connected*) wg=st;;
 		*) wg=0;;
 	esac
 }
diff --git a/sh/upd b/sh/upd
index f8a315d..92856b9 100755
--- a/sh/upd
+++ b/sh/upd
@@ -9,7 +9,7 @@ all () {
 	# pp maybe finish upd -a first and start to suspend, and it cause insp music() failed to rsync to pp, so I need to finish rsync to ssh before pp finish upd, so I put music() here, not perfect but good enough
 	[ "$hostname" = xyzinsp ] && music
 	# monthly_misc() needs to use qbittorrent-nox APIs, so I need to restart qbt before that, so I put qb() at top here, not perfect but good enough
-	if [ "$hostname" = xyzia ]; then
+	if [ "$hostname" = xyzia ] || [ "$hostname" = xyzib ]; then
 		qb
 	fi
 	fast
@@ -84,7 +84,7 @@ backup () {
 		# --files-from has a bug, this bug makes source url that is / not working while /home works, more see vq notes
 		# --use-agent not working when ssh to pp and insp, works on insp, not sure why
 		# --use-agent maybe timeout on gpg key and failed when do full backup, maybe due to key stored in gpg agent timeout, so I'm not using --use-agent on insp now
-		sudo duplicity --ssh-askpass --encrypt-key 9790577D2BE328D46838117ED3F54FE03F3C68D6 --sign-key 05899270DF25BB1EEDF57BE824F769E5D08C9E9A --full-if-older-than 2Y --include /etc/.cfgs --include-filelist "/home/xyz/.config/myconf/upd_rsync_files" --exclude / / "sftp://xyz@ia.flylightning.xyz//home/xyz/backup/$backup_branch"
+		sudo duplicity --ssh-askpass --encrypt-key 9790577D2BE328D46838117ED3F54FE03F3C68D6 --sign-key 05899270DF25BB1EEDF57BE824F769E5D08C9E9A --full-if-older-than 2Y --include /etc/.cfgs --include-filelist "/home/xyz/.config/myconf/upd_rsync_files" --exclude / / "sftp://xyz@ib.flylightning.xyz//home/xyz/backup/$backup_branch"
 	fi
 }
 
@@ -231,7 +231,7 @@ refl () {
 	# https://www.reddit.com/r/archlinux/comments/mynw6e/rsync_mirrors_with_pacman/
 	# need --delay so no super out of sync mirrors
 	case "$hostname" in
-		xyzia) sudo reflector --verbose --save /etc/pacman.d/mirrorlist --country ro --protocol https --delay 1 --fastest 3;;
+		xyzia|xyzib) sudo reflector --verbose --save /etc/pacman.d/mirrorlist --country ro --protocol https --delay 1 --fastest 3;;
 		# aa now default wireguard to ca, so I choose to copy ca mirrorlist to aa instead
 		# old cn mirrorlists code, only 2 cn mirror servers satisfied `--delay 1`, https://mirrors.jlu.edu.cn/archlinux/$repo/os/$arch is better than https://mirrors.neusoft.edu.cn/archlinux/$repo/os/$arch , the latter had issues
 		#xyzaa) sudo reflector --verbose --save /etc/pacman.d/mirrorlist --country cn --protocol https --delay 1 --fastest 2;;
@@ -258,8 +258,8 @@ monthly_misc () {
 		fi
 
 		# https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)
-		curl -sS -X POST '10.0.0.4:57151/api/v2/search/updatePlugins' &
-		for qbt_wireguard_ip in 10.0.0.3 10.0.0.4; do
+		curl -sS -X POST '10.0.0.8:57151/api/v2/search/updatePlugins' &
+		for qbt_wireguard_ip in 10.0.0.3 10.0.0.8; do
 			curl -sS https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_best.txt | awk '$0{printf("%s\\n",$0)}' | xargs -0 -I {} curl -sS -d json='{"add_trackers":"{}"}' "$qbt_wireguard_ip:57151/api/v2/app/setPreferences" &
 			# another way: `jq -r '.[]|"\(.added_on)\t\(.hash)\t\(.name)"'`
 			curl -sS "$qbt_wireguard_ip:57151/api/v2/torrents/info?category=useful" | jq -r '.[]|[.added_on,.hash,.name]|@tsv' | grep 'archlinux.*\.iso' | sort -n | head -n-1 | awk '{print $2}' | while read -r hash; do
diff --git a/sh/vip b/sh/vip
index 74e5c3f..95941be 100755
--- a/sh/vip
+++ b/sh/vip
@@ -5,6 +5,7 @@ case "$(nmcli -t --fields device,state device)" in
 	*wg_aa:connected*) echo aa;;
 	*wg_ca:connected*) echo ca;;
 	*wg_ia:connected*) echo ia;;
+	*wg_ib:connected*) echo ib;;
 	*wg_mydefault:connected*) echo mydefault;;
 	*wg_studio:connected*) echo studio;;
 	*) echo none;;
diff --git a/sh/vpn b/sh/vpn
index 126c608..aed5410 100755
--- a/sh/vpn
+++ b/sh/vpn
@@ -2,7 +2,7 @@
 # toggle VPN
 
 down_not_mydefault () {
-	for v in wg_studio wg_ia wg_aa wg_ca; do
+	for v in wg_studio wg_ia wg_aa wg_ca wg_ib; do
 		nmcli connection down "$v"
 	done
 }
-- 
cgit v1.2.3-70-g09d2