#!/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 -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 "resticsftp") if [ $isInFile -eq 0 ] then echo "" >> /root/.ssh/config echo "Host resticsftp" >> /root/.ssh/config echo "Hostname 192.168.1.51" >> /root/.ssh/config echo "Port 22" >> /root/.ssh/config echo "User root" >> /root/.ssh/config echo "IdentityFile ~/.ssh/resticsftp" >> /root/.ssh/config echo "StrictHostKeyChecking no" >> /root/.ssh/config chmod 600 /root/.ssh/config fi if [[ ! -f /root/.ssh/resticsftp ]] > /dev/null 2>&1 then echo "-----BEGIN OPENSSH PRIVATE KEY-----" > /root/.ssh/resticsftp echo "b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW" >> /root/.ssh/resticsftp echo "QyNTUxOQAAACC1aqAAHasdh+NMiX+v0iatWv/jwq9+nhPUSKs2oTlzkQAAAJBweDwvcHg8" >> /root/.ssh/resticsftp echo "LwAAAAtzc2gtZWQyNTUxOQAAACC1aqAAHasdh+NMiX+v0iatWv/jwq9+nhPUSKs2oTlzkQ" >> /root/.ssh/resticsftp echo "AAAEB7kN9ngDVf30Nr/C3f236ml6UiXi07X2szfLvNPvpQp7VqoAAdqx2H40yJf6/SJq1a" >> /root/.ssh/resticsftp echo "/+PCr36eE9RIqzahOXORAAAACnJlc3RpY3NmdHABAgM=" >> /root/.ssh/resticsftp echo "-----END OPENSSH PRIVATE KEY-----" >> /root/.ssh/resticsftp chown root:root /root/.ssh/resticsftp chmod 600 /root/.ssh/resticsftp fi