22 lines
512 B
Bash
22 lines
512 B
Bash
|
#!/bin/sh
|
||
|
[ -z "$REMOTE" ] && REMOTE=siv@archy.42069.no:/home/coder
|
||
|
run_rsync() {
|
||
|
rsync "$1" "$2" "$3"
|
||
|
[ $? -eq 12 ] && echo -e "\e[0;31mRsync is missing on the remote server!\e[0," && exit 0
|
||
|
}
|
||
|
pull() {
|
||
|
run_rsync "$1" "$3" "$2"
|
||
|
}
|
||
|
push() {
|
||
|
run_rsync "$1" "$2" "$3"
|
||
|
}
|
||
|
sync() {
|
||
|
pull "$1" "$2" "$3"
|
||
|
push "$1" "$2" "$3"
|
||
|
}
|
||
|
case "$1" in
|
||
|
mount) cryfs ~/.vault ~/vault -o allow_root ;;
|
||
|
push|pull|sync) $1 "-aze ssh" "$HOME/.vault" "$REMOTE" ;;
|
||
|
*) echo "Usage: $0 [ push | pull | sync | mount ]" ;;
|
||
|
esac
|