added script to remove wrestic and unmount drives

This commit is contained in:
2023-10-10 19:20:20 -05:00
parent 21dfd6b42d
commit ec14157a24
3 changed files with 35 additions and 1 deletions

View File

@@ -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

11
wrestic/wrestic-remove.sh Normal file
View File

@@ -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