From: Mario Höllein Date: Wed, 5 Feb 2020 13:57:55 +0000 (+0100) Subject: Änderunen bzgl. der Angabe des X-Git-Url: https://git.hoellein.online/?a=commitdiff_plain;h=5eccea54929c28d72c1159d74129365d2a93b683;p=zenbook_bin Änderunen bzgl. der Angabe des Datums Source löschen Nutzer in Nextcloud --- diff --git a/getPicturesFromHomecloud.sh b/getPicturesFromHomecloud.sh index d0d62b2..cc02436 100755 --- a/getPicturesFromHomecloud.sh +++ b/getPicturesFromHomecloud.sh @@ -1,15 +1,75 @@ #!/bin/bash -NEXTCLOUDUSERS="mhoellein nelly susi" +POSITIONAL=() +while [[ $# -gt 0 ]] +do + key="$1" + + case $key in + -u|--user) + NEXTCLOUDUSER="$2" + shift # past argument + shift # past value + ;; + -d|--date) + DATE="$2" + shift # past argument + shift # past value + ;; + -r|--remove) + REMOVE="$2" + shift # past argument + shift # past value + ;; + *) # unknown option + POSITIONAL+=("$1") # save it in an array for later + shift # past argument + ;; + esac +done +set -- "${POSITIONAL[@]}" # restore positional parameters + +if [[ -n $1 ]]; then + echo "Last line of file specified as non-opt/last argument:" + tail -1 "$1" +fi + +if [ "$NEXTCLOUDUSER" == "" ];then + NEXTCLOUDUSER="mhoellein nelly susi" +fi + +if [ "$DATE" == "" ];then + DATE=`date +%Y/%m` +fi + + +if [ "$REMOVE" != "" ];then + case "$REMOVE" in + [yY][eE][sS]|[yY]|[jJ]|[jJ][aA]) + REMOVE='--remove-source-files'; + ;; + *) + REMOVE=''; + ;; + esac +else + REMOVE=''; +fi + NEXTCLOUDSERVER="home.hoellein.online" PWD=`pwd` -if [ "$1" != "" ];then - NEXTCLOUDUSERS=$1 -fi #/localhome/nextcloud/data/mhoellein/files +echo "NEXTCLOUDUSER = ${NEXTCLOUDUSER}" +echo "DATE = ${DATE}" +echo "REMOVE = ${REMOVE}" + +#echo "rsync -av ${REMOVE} --rsh=\"ssh -p 1194\" root@home.hoellein.online:/localhome/nextcloud/data/$u/files/SofortUpload/Camera/${DATE}/ ${PWD}" +#exit -for u in $NEXTCLOUDUSERS + +for u in $NEXTCLOUDUSER do - rsync -av --rsh="ssh -p 1194" root@home.hoellein.online:/localhome/nextcloud/data/$u/files/SofortUpload/Camera/`date +%Y/%m`/ ${PWD} + rsync -av ${REMOVE} --rsh="ssh -p 1194" root@home.hoellein.online:/localhome/nextcloud/data/$u/files/SofortUpload/Camera/${DATE}/ ${PWD} done +