updated reseter app to include ipv6
This commit is contained in:
parent
da7a679a37
commit
2956093cb9
@ -2,8 +2,9 @@
|
||||
|
||||
set -o nounset
|
||||
|
||||
ID=$(dig @resolver4.opendns.com myip.opendns.com +short -4)
|
||||
ID=$(timeout 1 -k dig @resolver4.opendns.com myip.opendns.com +short -4)
|
||||
|
||||
ID6=$(timeout 1 dig -t aaaa +short myip.opendns.com @resolver1.opendns.com)
|
||||
|
||||
#### CREATE NEW MASTER LOGIN ####
|
||||
|
||||
@ -36,7 +37,7 @@ curl "https://git.sovransystems.com/Sovran_Systems/Software/raw/branch/main/Sovr
|
||||
|
||||
#### Initial Reseter Tag ####
|
||||
|
||||
ssh -i /home/free/.ssh/factory_login root@${ID} 'mkdir -p /var/lib/beacons/reseter ; touch /var/lib/beacons/reseter/started'
|
||||
ssh -i /home/free/.ssh/factory_login root@${ID} 'mkdir -p /var/lib/beacons/reseter ; touch /var/lib/beacons/reseter/started' || ssh -i /home/free/.ssh/factory_login root@${ID6} 'mkdir -p /var/lib/beacons/reseter ; touch /var/lib/beacons/reseter/started'
|
||||
|
||||
if [[ $? != 0 ]]; then
|
||||
|
||||
@ -77,7 +78,7 @@ curl "https://git.sovransystems.com/Sovran_Systems/Software/raw/branch/main/Sovr
|
||||
fi
|
||||
|
||||
|
||||
ssh -i /home/free/.ssh/factory_login root@${ID} 'sed -i -e "0,/ssh-ed25519.*/{ s::$(cat /home/free/.ssh/sovranpro_login.pub): }" /root/.ssh/authorized_keys'
|
||||
ssh -i /home/free/.ssh/factory_login root@${ID} 'sed -i -e "0,/ssh-ed25519.*/{ s::$(cat /home/free/.ssh/sovranpro_login.pub): }" /root/.ssh/authorized_keys' || ssh -i /home/free/.ssh/factory_login root@${ID6} 'sed -i -e "0,/ssh-ed25519.*/{ s::$(cat /home/free/.ssh/sovranpro_login.pub): }" /root/.ssh/authorized_keys'
|
||||
|
||||
if [[ $? != 0 ]]; then
|
||||
|
||||
@ -115,7 +116,7 @@ curl "https://git.sovransystems.com/Sovran_Systems/Software/raw/branch/main/Sovr
|
||||
NOW=$(date '+%Y%m%d.%H%M%S') # default NOW string
|
||||
BAKDIR=bak_${NOW}
|
||||
|
||||
ssh -i /home/free/.ssh/sovranpro_login root@${ID} "cd /root/.ssh/agenix/; mkdir ${BAKDIR}"
|
||||
ssh -i /home/free/.ssh/sovranpro_login root@${ID} "cd /root/.ssh/agenix/; mkdir ${BAKDIR}" || ssh -i /home/free/.ssh/sovranpro_login root@${ID6} "cd /root/.ssh/agenix/; mkdir ${BAKDIR}"
|
||||
|
||||
if [[ $? != 0 ]]; then
|
||||
|
||||
@ -132,7 +133,7 @@ curl "https://git.sovransystems.com/Sovran_Systems/Software/raw/branch/main/Sovr
|
||||
|
||||
#### Move existing keys to Backup Directory ####
|
||||
|
||||
ssh -i /home/free/.ssh/sovranpro_login root@${ID} "cd /root/.ssh/agenix/; mv agenix-secret-keys* ${BAKDIR}"
|
||||
ssh -i /home/free/.ssh/sovranpro_login root@${ID} "cd /root/.ssh/agenix/; mv agenix-secret-keys* ${BAKDIR}" || ssh -i /home/free/.ssh/sovranpro_login root@${ID6} "cd /root/.ssh/agenix/; mv agenix-secret-keys* ${BAKDIR}"
|
||||
|
||||
if [[ $? != 0 ]]; then
|
||||
|
||||
@ -149,7 +150,7 @@ curl "https://git.sovransystems.com/Sovran_Systems/Software/raw/branch/main/Sovr
|
||||
|
||||
##### Generate New Keys ####
|
||||
|
||||
ssh -i /home/free/.ssh/sovranpro_login root@${ID} 'ssh-keygen -q -N "" -t ed25519 -f /root/.ssh/agenix/agenix-secret-keys'
|
||||
ssh -i /home/free/.ssh/sovranpro_login root@${ID} 'ssh-keygen -q -N "" -t ed25519 -f /root/.ssh/agenix/agenix-secret-keys' || ssh -i /home/free/.ssh/sovranpro_login root@${ID6} 'ssh-keygen -q -N "" -t ed25519 -f /root/.ssh/agenix/agenix-secret-keys'
|
||||
|
||||
if [[ $? != 0 ]]; then
|
||||
|
||||
@ -167,7 +168,7 @@ curl "https://git.sovransystems.com/Sovran_Systems/Software/raw/branch/main/Sovr
|
||||
#### Send .pub into agenix/secrets.nix ####
|
||||
|
||||
|
||||
ssh -i /home/free/.ssh/sovranpro_login root@${ID} 'sed -i -e "0,/root.*/{s::root = $(cat /root/.ssh/agenix/agenix-secret-keys.pub):};s:root@nixos::" /var/lib/agenix-secrets/secrets.nix'
|
||||
ssh -i /home/free/.ssh/sovranpro_login root@${ID} 'sed -i -e "0,/root.*/{s::root = $(cat /root/.ssh/agenix/agenix-secret-keys.pub):};s:root@nixos::" /var/lib/agenix-secrets/secrets.nix' || ssh -i /home/free/.ssh/sovranpro_login root@${ID6} 'sed -i -e "0,/root.*/{s::root = $(cat /root/.ssh/agenix/agenix-secret-keys.pub):};s:root@nixos::" /var/lib/agenix-secrets/secrets.nix'
|
||||
|
||||
if [[ $? != 0 ]]; then
|
||||
|
||||
@ -181,7 +182,7 @@ curl "https://git.sovransystems.com/Sovran_Systems/Software/raw/branch/main/Sovr
|
||||
|
||||
fi
|
||||
|
||||
ssh -i /home/free/.ssh/sovranpro_login root@${ID} << 'EOF'
|
||||
ssh -i /home/free/.ssh/sovranpro_login root@${ID} || ssh -i /home/free/.ssh/sovranpro_login root@${ID6} << 'EOF'
|
||||
|
||||
sed -i 's:\(root =[[:blank:]]*\)\(.*\):\1"\2";:' /var/lib/agenix-secrets/secrets.nix
|
||||
|
||||
@ -202,11 +203,11 @@ EOF
|
||||
|
||||
#### DATABASES ####
|
||||
|
||||
ssh -i /home/free/.ssh/sovranpro_login root@${ID} "echo -n $(pwgen -s 33 -1) > /var/lib/secrets/wordpressdb"
|
||||
ssh -i /home/free/.ssh/sovranpro_login root@${ID} "echo -n $(pwgen -s 33 -1) > /var/lib/secrets/wordpressdb" || ssh -i /home/free/.ssh/sovranpro_login root@${ID6} "echo -n $(pwgen -s 33 -1) > /var/lib/secrets/wordpressdb"
|
||||
|
||||
ssh -i /home/free/.ssh/sovranpro_login root@${ID} "echo -n $(pwgen -s 33 -1) > /var/lib/secrets/matrixdb"
|
||||
ssh -i /home/free/.ssh/sovranpro_login root@${ID} "echo -n $(pwgen -s 33 -1) > /var/lib/secrets/matrixdb" || ssh -i /home/free/.ssh/sovranpro_login root@${ID6} "echo -n $(pwgen -s 33 -1) > /var/lib/secrets/matrixdb"
|
||||
|
||||
ssh -i /home/free/.ssh/sovranpro_login root@${ID} "echo -n $(pwgen -s 33 -1) > /var/lib/secrets/nextclouddb"
|
||||
ssh -i /home/free/.ssh/sovranpro_login root@${ID} "echo -n $(pwgen -s 33 -1) > /var/lib/secrets/nextclouddb" || ssh -i /home/free/.ssh/sovranpro_login root@${ID6} "echo -n $(pwgen -s 33 -1) > /var/lib/secrets/nextclouddb"
|
||||
|
||||
|
||||
if [[ $? != 0 ]]; then
|
||||
@ -224,7 +225,7 @@ EOF
|
||||
|
||||
#### Mysql Passwords ####
|
||||
|
||||
ssh -i /home/free/.ssh/sovranpro_login root@${ID} << 'EOF'
|
||||
ssh -i /home/free/.ssh/sovranpro_login root@${ID} || ssh -i /home/free/.ssh/sovranpro_login root@${ID6} << 'EOF'
|
||||
|
||||
wp=$(cat /var/lib/secrets/wordpressdb)
|
||||
|
||||
@ -249,7 +250,7 @@ EOF
|
||||
|
||||
#### PostgresQL Passwords ####
|
||||
|
||||
ssh -i /home/free/.ssh/sovranpro_login root@${ID} << 'EOF'
|
||||
ssh -i /home/free/.ssh/sovranpro_login root@${ID} || ssh -i /home/free/.ssh/sovranpro_login root@${ID6} << 'EOF'
|
||||
|
||||
nc=$(cat /var/lib/secrets/nextclouddb)
|
||||
|
||||
@ -270,7 +271,7 @@ EOF
|
||||
fi
|
||||
|
||||
|
||||
ssh -i /home/free/.ssh/sovranpro_login root@${ID} << 'EOF'
|
||||
ssh -i /home/free/.ssh/sovranpro_login root@${ID} || ssh -i /home/free/.ssh/sovranpro_login root@${ID6} << 'EOF'
|
||||
|
||||
nc=$(cat /var/lib/secrets/nextclouddb)
|
||||
|
||||
@ -291,7 +292,7 @@ EOF
|
||||
fi
|
||||
|
||||
|
||||
ssh -i /home/free/.ssh/sovranpro_login root@${ID} << 'EOF'
|
||||
ssh -i /home/free/.ssh/sovranpro_login root@${ID} || ssh -i /home/free/.ssh/sovranpro_login root@${ID6} << 'EOF'
|
||||
|
||||
ms=$(cat /var/lib/secrets/matrixdb)
|
||||
|
||||
@ -314,9 +315,9 @@ EOF
|
||||
|
||||
#### Matrix-Synapse Keys ####
|
||||
|
||||
ssh -i /home/free/.ssh/sovranpro_login root@${ID} "echo -n $(pwgen -s 33 -1) > /var/lib/secrets/turn"
|
||||
ssh -i /home/free/.ssh/sovranpro_login root@${ID} "echo -n $(pwgen -s 33 -1) > /var/lib/secrets/turn" || ssh -i /home/free/.ssh/sovranpro_login root@${ID6} "echo -n $(pwgen -s 33 -1) > /var/lib/secrets/turn"
|
||||
|
||||
ssh -i /home/free/.ssh/sovranpro_login root@${ID} "echo -n $(pwgen -s 33 -1) > /var/lib/secrets/matrix_reg_secret"
|
||||
ssh -i /home/free/.ssh/sovranpro_login root@${ID} "echo -n $(pwgen -s 33 -1) > /var/lib/secrets/matrix_reg_secret" || ssh -i /home/free/.ssh/sovranpro_login root@${ID6} "echo -n $(pwgen -s 33 -1) > /var/lib/secrets/matrix_reg_secret"
|
||||
|
||||
if [[ $? != 0 ]]; then
|
||||
|
||||
@ -333,7 +334,7 @@ EOF
|
||||
|
||||
#### UPDATE AGENIX SECRETS ####
|
||||
|
||||
ssh -i /home/free/.ssh/sovranpro_login root@${ID} "
|
||||
ssh -i /home/free/.ssh/sovranpro_login root@${ID} || ssh -i /home/free/.ssh/sovranpro_login root@${ID6} "
|
||||
|
||||
rm -rf /var/lib/agenix-secrets/nextclouddb.age ;
|
||||
rm -rf /var/lib/agenix-secrets/wordpressdb.age ;
|
||||
@ -342,7 +343,7 @@ EOF
|
||||
rm -rf /var/lib/agenix-secrets/matrix_reg_secret.age "
|
||||
|
||||
|
||||
ssh -i /home/free/.ssh/sovranpro_login root@${ID} << 'EOF'
|
||||
ssh -i /home/free/.ssh/sovranpro_login root@${ID} || ssh -i /home/free/.ssh/sovranpro_login root@${ID6} << 'EOF'
|
||||
|
||||
pushd /var/lib/agenix-secrets/
|
||||
|
||||
@ -376,7 +377,7 @@ EOF
|
||||
|
||||
#### VAULTWARDEN ####
|
||||
|
||||
ssh -i /home/free/.ssh/sovranpro_login root@${ID} << 'EOF'
|
||||
ssh -i /home/free/.ssh/sovranpro_login root@${ID} || ssh -i /home/free/.ssh/sovranpro_login root@${ID6} << 'EOF'
|
||||
|
||||
echo -n $(pwgen -s 77 -1) > /var/lib/secrets/vaultwarden/vaultwarden
|
||||
|
||||
@ -401,7 +402,7 @@ EOF
|
||||
|
||||
#### MAIN ####
|
||||
|
||||
ssh -i /home/free/.ssh/sovranpro_login root@${ID} << 'EOF'
|
||||
ssh -i /home/free/.ssh/sovranpro_login root@${ID} || ssh -i /home/free/.ssh/sovranpro_login root@${ID6} << 'EOF'
|
||||
|
||||
echo -n $(pwgen -s 77 -1) > /var/lib/secrets/main
|
||||
|
||||
@ -425,7 +426,7 @@ EOF
|
||||
|
||||
#### RESET SYSTEMD SERVICES ####
|
||||
|
||||
ssh -i /home/free/.ssh/sovranpro_login root@${ID} "
|
||||
ssh -i /home/free/.ssh/sovranpro_login root@${ID} || ssh -i /home/free/.ssh/sovranpro_login root@${ID6} "
|
||||
|
||||
systemctl restart postgresql matrix-synapse caddy mysql coturn vaultwarden"
|
||||
|
||||
@ -444,7 +445,7 @@ EOF
|
||||
|
||||
#### RESET LND AND RTL ####
|
||||
|
||||
ssh -i /home/free/.ssh/sovranpro_login root@${ID} << 'EOF'
|
||||
ssh -i /home/free/.ssh/sovranpro_login root@${ID} || ssh -i /home/free/.ssh/sovranpro_login root@${ID6} << 'EOF'
|
||||
|
||||
systemctl stop bitcoind lnd lightning-loop lightning-pool rtl
|
||||
|
||||
@ -468,12 +469,12 @@ EOF
|
||||
|
||||
#### NixOS Rebuild Switch ####
|
||||
|
||||
ssh -i /home/free/.ssh/sovranpro_login root@${ID} 'nixos-rebuild switch --impure'
|
||||
ssh -i /home/free/.ssh/sovranpro_login root@${ID} || ssh -i /home/free/.ssh/sovranpro_login root@${ID6} 'nixos-rebuild switch --impure'
|
||||
|
||||
|
||||
#### FINAL RESETER TAG ####
|
||||
|
||||
ssh -i /home/free/.ssh/sovranpro_login root@${ID} 'touch /var/lib/beacons/reseter/completed'
|
||||
ssh -i /home/free/.ssh/sovranpro_login root@${ID} || ssh -i /home/free/.ssh/sovranpro_login root@${ID6} 'touch /var/lib/beacons/reseter/completed'
|
||||
|
||||
if [[ $? != 0 ]]; then
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user