From ec14157a247a39831b8d75ec84d8c807e1984b2f Mon Sep 17 00:00:00 2001 From: akanealw Date: Tue, 10 Oct 2023 19:20:20 -0500 Subject: [PATCH] added script to remove wrestic and unmount drives --- debian/debian-download-configure-wrestic.sh | 25 ++++++++++++++++++- .../wrestic-backup-to-truenas.sh | 0 wrestic/wrestic-remove.sh | 11 ++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) rename {restic => wrestic}/wrestic-backup-to-truenas.sh (100%) create mode 100644 wrestic/wrestic-remove.sh diff --git a/debian/debian-download-configure-wrestic.sh b/debian/debian-download-configure-wrestic.sh index e92df1b..7fe6072 100644 --- a/debian/debian-download-configure-wrestic.sh +++ b/debian/debian-download-configure-wrestic.sh @@ -6,6 +6,29 @@ if [ "$EUID" -ne 0 ] exit fi +isInFile=$(cat /home/akanealw/.ssh/config | grep -c "truenas") +if [ $isInFile -eq 0 ] + then + echo "Host truenas" >> /home/akanealw/.ssh/config + echo "Hostname 192.168.1.41" >> /home/akanealw/.ssh/config + echo "Port 22" >> /home/akanealw/.ssh/config + echo "User akanealw" >> /home/akanealw/.ssh/config + echo "IdentityFile ~/.ssh/truenas" >> /home/akanealw/.ssh/config + chmod 600 /home/akanealw/.ssh/config +fi + +if [[ ! -f /home/akanealw/.ssh/truenas ]] + then + echo "-----BEGIN OPENSSH PRIVATE KEY-----" > /home/akanealw/.ssh/truenas + echo "b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW" >> /home/akanealw/.ssh/truenas + echo "QyNTUxOQAAACCDKl0DNjKWKlSpbCGeKjmA3tc0pKDvAiMfWQ83h0JVlQAAAJhNQ67sTUOu" >> /home/akanealw/.ssh/truenas + echo "7AAAAAtzc2gtZWQyNTUxOQAAACCDKl0DNjKWKlSpbCGeKjmA3tc0pKDvAiMfWQ83h0JVlQ" >> /home/akanealw/.ssh/truenas + echo "AAAEBoM2bsFqToHCHKO3F6MvOlObGaiNXw6UPcyBlyfbSAvYMqXQM2MpYqVKlsIZ4qOYDe" >> /home/akanealw/.ssh/truenas + echo "1zSkoO8CIx9ZDzeHQlWVAAAAEWFrYW5lYWx3QExhcHRvcFBDAQIDBA==" >> /home/akanealw/.ssh/truenas + echo "-----END OPENSSH PRIVATE KEY-----" >> /home/akanealw/.ssh/truenas + chmod 600 /home/akanealw/.ssh/truenas +fi + if [[ ! -f /home/akanealw/.config/wrestic/wrestic.toml ]] then apt update @@ -15,7 +38,7 @@ if [[ ! -f /home/akanealw/.config/wrestic/wrestic.toml ]] mkdir -pv /root/restic/restore wget -qO /usr/local/bin/wrestic http://192.168.1.50/files/wrestic/wrestic wget -qO /home/akanealw/.config/wrestic/wrestic.toml http://192.168.1.50/files/wrestic/wrestic.toml - wget -qO /home/akanealw/scripts/wrestic-backup-to-truenas.sh http://192.168.1.50/scripts/restic/wrestic-backup-to-truenas.sh + wget -qO /home/akanealw/scripts/wrestic-backup-to-truenas.sh http://192.168.1.50/scripts/wrestic/wrestic-backup-to-truenas.sh sed -i "s/changemepls/$HOSTNAME/g" /home/akanealw/.config/wrestic/wrestic.toml sed -r 's/(resticbackups)(.*)/\1\L\2\E/g' /home/akanealw/.config/wrestic/wrestic.toml > /home/akanealw/.config/wrestic/wrestic2.toml mv /home/akanealw/.config/wrestic/wrestic.toml /home/akanealw/.config/wrestic/wresticbackup.toml diff --git a/restic/wrestic-backup-to-truenas.sh b/wrestic/wrestic-backup-to-truenas.sh similarity index 100% rename from restic/wrestic-backup-to-truenas.sh rename to wrestic/wrestic-backup-to-truenas.sh diff --git a/wrestic/wrestic-remove.sh b/wrestic/wrestic-remove.sh new file mode 100644 index 0000000..3b6f337 --- /dev/null +++ b/wrestic/wrestic-remove.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +sudo rm /home/akanealw/.config/wrestic/* +sudo rm /home/akanealw/scripts/wrestic-backup-to-truenas.sh +sudo rm /usr/local/bin/wrestic + +if [[ ! -f /etc/profile.d/mount-shared-drives.sh ]] + then + sudo umount /mnt/* -v + echo "Shared folders have been unmounted" +fi