computer-playbook/roles/native-user-backup/templates/ssh-wrapper.sh.j2

30 lines
704 B
Django/Jinja

#!/bin/sh
# log command
if [ -n "$SSH_ORIGINAL_COMMAND" ]
then
echo "`/bin/date`: $SSH_ORIGINAL_COMMAND" | systemd-cat -t "ssh-wrapper.sh"
fi
# define executable commands
hashed_machine_id_command="sha256sum /etc/machine-id";
find_command="find /Backups/{{hashed_machine_id.stdout}}/ -maxdepth 1 -type d";
rsync_command="sudo rsync --server --sender -blogDtpre.iLsfxCIvu . /Backups/{{hashed_machine_id.stdout}}/docker-volume-backup/latest/"
# filter commands
case "$SSH_ORIGINAL_COMMAND" in
"$hashed_machine_id_command")
$hashed_machine_id_command
;;
"$find_command")
$find_command
;;
"$rsync_command")
$rsync_command
;;
*)
echo "This command is not supported."
exit 1
;;
esac