#!/bin/bash if [ "$EUID" -ne 0 ] then echo "Please run as root" exit fi isInFile=$(cat /home/akanealw/.ssh/config | grep -c "truenas") if [ $isInFile -eq 0 ] then echo "" >> /home/akanealw/.ssh/config 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 chown akanealw:akanealw /home/akanealw/.ssh/truenas chmod 600 /home/akanealw/.ssh/truenas fi if [[ ! -f /home/akanealw/.config/wrestic/wrestic.toml ]] then mkdir -pv /home/akanealw/.config/wrestic mkdir -pv /home/akanealw/restic/restore mkdir -pv /root/restic/restore curl -sL $(curl -s https://api.github.com/repos/alvaro17f/wrestic/releases/latest | grep browser_download_url | cut -d '"' -f 4) | sudo tar zxf - -C /usr/local/bin --overwrite wget -qO /home/akanealw/.config/wrestic/wrestic.toml http://192.168.1.50/files/wrestic/wrestic-sftp.toml wget -qO /home/akanealw/scripts/wrestic-backup-to-truenas.sh http://192.168.1.50/scripts/wrestic/wrestic-backup-to-truenas-sftp.sh sed -i "s/changemepls/$(cat /etc/hostname | tr '[:upper:]' '[:lower:]')/g" /home/akanealw/.config/wrestic/wrestic.toml chown -R akanealw:akanealw /home/akanealw/.config chown -R akanealw:akanealw /home/akanealw/restic chown -R akanealw:akanealw /home/akanealw/scripts chmod +x /home/akanealw/scripts/wrestic-backup-to-truenas.sh chmod +x /usr/local/bin/wrestic else echo "Wrestic is already configured." fi