leafclick-system-rbackup

by katox
0 deployments · 0 still active · last rev. 1 year ago

Leafclick specific system utilities

Auto RBackup

Compatible with: Debian 7
Includes: private-script
						#!/bin/bash
#
# Leafclick specific system utilities

source <ssinclude StackScriptID="10446"> # Common utilities
#source ./lib-system-ubuntu.sh

function system_rbackup_install {
    # system_rbackup_install(username)
    USERNAME=`lower $1`
    USER_HOME="/home/$USERNAME"

    aptitude -y install rsync
    useradd -m -d /home/$USERNAME -s /bin/sh -c "Remote Backup user" -U "$USERNAME"
    sudo -u "$USERNAME" mkdir "$USER_HOME/.ssh"
    sudo -u "$USERNAME" cat >> "$USER_HOME/.ssh/authorized_keys" <<EOF
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDjduSdTdW9zkL72QIgq/0tAgGFkFUt6J5zhSWEEX9g4jDRWcLS8+aqRXTxqDrAUMCyD8Eh0vfCAQ6ZmEl4HPHC8Lu5+6S8kPLSnYjmzJKdKjYSwQSnu0EScLAyju8hUmwPWtyyp57qLk+tZtPK9unSqth1nn5rkWUxIm9NV4Edni9V8QohDoqlU5uldIknbdx6zbM10e9ZJrBnoba2SDZD37MYB30sEyMrJXZE8Y0yhVUWg4fz5Dy14Y/9xkBouMXsARhheYg2LE73f5S97enlaqLPYlh58TQUD4ln7Nbmqb9t6d3f6gVNQAB0I4etxWydeJRRzRf7RbzPN0iahu/t root@nas
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAojEH8j/WnbJLbMGIGvRUPpcER8VC277SloenG6wXBmwTjlchLviNQ0zigb8zI8D9Dg7Cj273O4hb5Yx4CThwJldl+XIg0fj2hwvnW9Xp1j17NKqXVb4wtCmMzvLDslkUfnNBoOiO3UkbmWeJBiQCH3Q2UjIQTvZafZnMhTALryKbqF/eD2Z5jVpBIxvW0DX1axLyzErQ2qMO8HDpfO9WTfXptyHDIXzl4JlhOWezHYLanTZud5QZo/lJCQcyioZY0VYACqU/ZLrTYMN1hu2FEHvFYHv2zbGr2phSUXbypk6KOEu5TPTx2hkZP153HrqeCJo5Eul9FyN2HfsEEHLQKQ== admin@NASC7B3E5
EOF
    chmod 0600 "$USER_HOME/.ssh/authorized_keys"
    chmod 0700 "$USER_HOME/.ssh"

    sudo echo "$USERNAME ALL= NOPASSWD:/usr/bin/rsync" > /etc/sudoers.d/01_rbackup
}