#!/bin/bash # INIT seahub="http://192.168.2.172:8083" user="zino@zinomedia.de" pw="13371337" homedir=$( getent passwd "$USER" | cut -d: -f6 ) projectroot="${homedir}/projects2" declare -A projects projects=( \ #["BA"]="8ace3c29-708d-4d2c-9771-dd07360af3d6" \ ["instafeed"]="8136d454-f4aa-41d7-8d83-b2310520ead3" \ #["service.berlin.de"]="e02a0ffd-51d3-4aab-9cee-8c5e784982e5" \ ["unsplash"]="110b5ea6-9cba-4da5-a879-1b00916a18c6" \ #["vstorrent"]="6ae063e9-3ad6-450e-aef3-bccac94049f1" \ #["pkrstarsbot"]="39ab3f9c-53aa-4640-bafa-894a68e147a0" \ #["smartface"]="c3e77314-4595-453f-8d9b-60d8456be33d" \ ) # ARGS POSITIONAL=() while [[ $# -gt 0 ]] do key="$1" case $key in sync) sync="$2" shift shift ;; desync) desync="$2" shift shift ;; *) POSITIONAL+=("$1") # save it in an array for later shift ;; esac done set -- "${POSITIONAL[@]}" # restore positional parameters # SYNC if [ -z ${sync+x} ]; then echo ""; else echo ""; if [ "$sync" == "all" ]; then #echo "foobar" for name in "${!projects[@]}"; do projectdir="${projectroot}/${name}" && \ echo "syncing $name to $projectdir now..." && \ mkdir -p $projectdir && \ seaf-cli sync -l ${projects[$name]} -s $seahub -d $projectdir -u $user -p $pw done watch -n 2 seaf-cli status elif [[ -v projects[$sync] ]]; then projectdir="${projectroot}/${sync}" echo "syncing $sync to $projectdir now..." mkdir -p $projectdir seaf-cli sync -l ${projects[$sync]} -s $seahub -d $projectdir -u $user -p $pw watch -n 2 seaf-cli status else echo "project $sync does not exist" fi fi # DESYNC if [ -z ${desync+x} ]; then echo ""; else echo ""; if [ "$desync" == "all" ]; then for name in "${!projects[@]}"; do projectdir="${projectroot}/${name}" && \ echo "desyncing $name now..." && \ seaf-cli desync -d $projectdir done seaf-cli status elif [[ -v projects[$desync] ]]; then projectdir="${projectroot}/${desync}" if [ -d $projectdir ]; then echo "desyncing $projectdir now..." seaf-cli desync -d $projectdir seaf-cli status else echo "directory projectdir does not exist" fi else echo "project $desync does not exist" fi fi