diff --git a/dotinstall.sh b/dotinstall.sh index 552a397..a689f34 100755 --- a/dotinstall.sh +++ b/dotinstall.sh @@ -1,18 +1,94 @@ #!/bin/sh -cd $(dirname $(echo $0))/src/ +# Symlink dotfiles into the home directory + +set -e + +SCRIPT_NAME="$(basename $0)" + +# Default source for dotfiles +SRCFOLDER="$(dirname "$0")/src/" +DESTFOLDER="$HOME" + +# Allow overwriting of outdated files +FORCE="N" +VERBOSE="N" + +display_help () { +cat >&2 <&2 + fi + fi + else + link "$SRC" "$DEST" + fi done diff --git a/src/.local/bin/msync b/src/.local/bin/msync index dcd6ff5..19c3e42 100755 --- a/src/.local/bin/msync +++ b/src/.local/bin/msync @@ -4,14 +4,35 @@ set -e -while getopts ":pr" o; do +SCRIPT_NAME="$(basename $0)" + +ACTION=NONE + +MNT="$HOME/quar/mnt" +DEST="$HOME/quar" + +while getopts "prhs:d:" o; do case "${o}" in p) ACTION=PUSH ;; r) ACTION=RECV ;; + h) ACTION=HELP ;; + s) + ROOT="$OPTARG" + if ! [ -e "$MNT" ]; then + printf "$SCRIPT_NAME: source mountpoint $MNT does not exist" + exit 1 + fi + ;; + d) + DEST="$OPTARG" + if ! [ -e "$DEST" ]; then + printf "$SCRIPT_NAME: destination $DEST does not exist" + exit 1 + fi + ;; esac done -MNT="$HOME/quar/mnt" ROOT="$MNT/Internal shared storage" imp () { @@ -26,33 +47,53 @@ exp () { find "$1" -type f | xargs -I{} cp -n "{}" "$2" } -if [ $ACTION = PUSH ] -then - # Optionally send sorted files back +display_help () { + cat << "EOF" +usage: $SCRIPT_NAME [-r] [-p] [-h] [-s PATH] [-d PATH] + -r: receive files from mobile device + -p: send files to mobile device + -s: set go-mtpfs source mountpoint path + -d: set local download destination path +EOF +} - exp ~/med/memes/woof/ "$ROOT/Pictures/memes/" - exp ~/med/memes/bork/ "$ROOT/Pictures/memes2/" - exp ~/med/rw/sch/ "$ROOT/Pictures/rw/sch/" - exp ~/med/sticker/ "$ROOT/Pictures/sticker/" -fi +case "$ACTION" in + PUSH) + # Optionally send sorted files back -if [ $ACTION = RECV ] -then - # Move files to the quarantine zone for categorisation and renaming + exp ~/med/memes/woof/ "$ROOT/Pictures/memes/" + exp ~/med/memes/bork/ "$ROOT/Pictures/memes2/" + exp ~/med/rw/sch/ "$ROOT/Pictures/rw/sch/" + exp ~/med/sticker/ "$ROOT/Pictures/sticker/" + ;; + + RECV) + # Move files to the quarantine zone for categorisation and renaming - imp "$ROOT/Pictures/Infinity/" ~/quar - imp "$ROOT/Pictures/Screenshots/" ~/quar + imp "$ROOT/Pictures/Infinity/" $DEST + imp "$ROOT/Pictures/Screenshots/" $DEST - imp "$ROOT/Movies/Infinity/" ~/quar + imp "$ROOT/Movies/Infinity/" $DEST - imp "$ROOT/DCIM/OpenCamera/" ~/quar - imp "$ROOT/DCIM/Camera/" ~/quar + imp "$ROOT/DCIM/OpenCamera/" $DEST + imp "$ROOT/DCIM/Camera/" $DEST - imp "$ROOT/Recordings/Sound records/" ~/quar + imp "$ROOT/Recordings/Sound records/" $DEST - imp "$ROOT/Documents/dr" ~/quar + imp "$ROOT/Documents/dr" $DEST - imp "$ROOT/Documents/contacts.vcf" ~/quar - imp "$ROOT/infbk/" ~/quar/infinity/ - impf "$ROOT/.SeedVaultAndroidBackup/" ~/quar/seedvault/ -fi + imp "$ROOT/Documents/contacts.vcf" $DEST + imp "$ROOT/infbk/" $DEST + impf "$ROOT/.SeedVaultAndroidBackup/" $DEST/seedvault/ + ;; + + HELP) + # show help + display_help + ;; + + NONE) + # Default + printf "$SCRIPT_NAME: no option specified, see $SCRIPT_NAME -h for help" + ;; +esac