50 lines
2.4 KiB
Bash
Executable File
50 lines
2.4 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
rm -r /home/akanealw/.config/wrestic > /dev/null 2>&1
|
|
rm -r /root/.config/wrestic > /dev/null 2>&1
|
|
rm -r /usr/local/bin/wrestic > /dev/null 2>&1
|
|
rm /home/akanealw/scripts/wrestic-backup-to-truenas.sh > /dev/null 2>&1
|
|
rm /root/scripts/wrestic-backup-to-truenas.sh > /dev/null 2>&1
|
|
|
|
mkdir -p /root/scripts/restic > /dev/null 2>&1
|
|
rm /root/scripts/restic/* > /dev/null 2>&1
|
|
wget -q http://192.168.1.50/scripts/restic/restic-sftp/restic-sftp-backup.sh -P /root/scripts/restic
|
|
wget -q http://192.168.1.50/scripts/restic/restic-sftp/export-etc.sh -P /root/scripts/restic
|
|
wget -q http://192.168.1.50/scripts/restic/restic-sftp/export-home-akanealw.sh -P /root/scripts/restic
|
|
wget -q http://192.168.1.50/scripts/restic/restic-sftp/export-opt.sh -P /root/scripts/restic
|
|
wget -q http://192.168.1.50/scripts/restic/restic-sftp/export-root.sh -P /root/scripts/restic
|
|
wget -q http://192.168.1.50/scripts/restic/restic-sftp/restic-sftp-init.sh -P /root/scripts/restic
|
|
|
|
chmod +x /root/scripts/restic/*
|
|
sed -i "s/changemepls/$(cat /etc/hostname | tr '[:upper:]' '[:lower:]')/g" /root/scripts/restic/*
|
|
|
|
if [[ ! -f /root/.ssh/config ]]; then
|
|
touch /root/.ssh/config
|
|
fi
|
|
|
|
isInFile=$(cat /root/.ssh/config | grep -c "truenas")
|
|
if [ $isInFile -eq 0 ]
|
|
then
|
|
echo "" >> /root/.ssh/config
|
|
echo "Host truenas" >> /root/.ssh/config
|
|
echo "Hostname 192.168.1.41" >> /root/.ssh/config
|
|
echo "Port 22" >> /root/.ssh/config
|
|
echo "User akanealw" >> /root/.ssh/config
|
|
echo "IdentityFile ~/.ssh/truenas" >> /root/.ssh/config
|
|
echo "StrictHostKeyChecking no" >> /root/.ssh/config
|
|
chmod 600 /root/.ssh/config
|
|
fi
|
|
|
|
if [[ ! -f /root/.ssh/truenas ]] > /dev/null 2>&1
|
|
then
|
|
echo "-----BEGIN OPENSSH PRIVATE KEY-----" > /root/.ssh/truenas
|
|
echo "b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW" >> /root/.ssh/truenas
|
|
echo "QyNTUxOQAAACCDKl0DNjKWKlSpbCGeKjmA3tc0pKDvAiMfWQ83h0JVlQAAAJhNQ67sTUOu" >> /root/.ssh/truenas
|
|
echo "7AAAAAtzc2gtZWQyNTUxOQAAACCDKl0DNjKWKlSpbCGeKjmA3tc0pKDvAiMfWQ83h0JVlQ" >> /root/.ssh/truenas
|
|
echo "AAAEBoM2bsFqToHCHKO3F6MvOlObGaiNXw6UPcyBlyfbSAvYMqXQM2MpYqVKlsIZ4qOYDe" >> /root/.ssh/truenas
|
|
echo "1zSkoO8CIx9ZDzeHQlWVAAAAEWFrYW5lYWx3QExhcHRvcFBDAQIDBA==" >> /root/.ssh/truenas
|
|
echo "-----END OPENSSH PRIVATE KEY-----" >> /root/.ssh/truenas
|
|
chown root:root /root/.ssh/truenas
|
|
chmod 600 /root/.ssh/truenas
|
|
fi
|