Files
linux-scripts/restic/restic-sftp/install-restic-sftp.sh
2024-03-14 10:53:28 -05:00

45 lines
2.0 KiB
Bash

#!/bin/bash
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
wget -q http://192.168.1.50/scripts/restic/restic-sftp/export-etc.sh
wget -q http://192.168.1.50/scripts/restic/restic-sftp/export-home-akanealw.sh
wget -q http://192.168.1.50/scripts/restic/restic-sftp/export-opt.sh
wget -q http://192.168.1.50/scripts/restic/restic-sftp/export-root.sh
wget -q http://192.168.1.50/scripts/restic/restic-sftp/restic-sftp-init.sh
mv /root/restic-sftp-* /root/scripts/restic
mv /root/export-* /root/scripts/restic
chmod +x /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