Skip to content

Instantly share code, notes, and snippets.

@n-st
Created November 28, 2017 11:53
Show Gist options
  • Save n-st/b77e45895da58d99d381b9f97e3c3ad6 to your computer and use it in GitHub Desktop.
Save n-st/b77e45895da58d99d381b9f97e3c3ad6 to your computer and use it in GitHub Desktop.
#!/bin/sh
set -e -u
cd "$(dirname "$(readlink -f "$0")")" || exit
cd niko-studip || exit
VIRTUAL_ENV="$(pwd)"
export VIRTUAL_ENV
PATH="$VIRTUAL_ENV/bin:$PATH"
export PATH
# unset PYTHONHOME if set
if ! [ -z "${PYTHONHOME+_}" ] ; then
unset PYTHONHOME
fi
rm -f fifo
mkfifo fifo
stdbuf -i0 -o0 -e0 bin/studip-fuse --user steing02 --cache ~/.studip-niko/cache --mount /tmp/studip.fuse --format "{semester-lexical-short}/{course}/{type}/{short-path}/{name}" --pwfile - 2>&1 | tee fifo &
printf '%s\n' "Waiting for FUSE mount to come online..."
grep -q "Handing over to FUSE driver" fifo
printf '%s\n' "Launching rsync"
rsync --archive --verbose --human-readable --progress --partial --append-verify --stats /tmp/studip.fuse/2017WS ~/Studium/
rsync_rc=$?
printf '%s\n' "Killing FUSE process"
while pkill -P "$$" -f "studip-fuse" > /dev/null 1>&2
do
true
sleep 0.1
done
rm -f fifo
printf '%s\n' "All done"
exit "$rsync_rc"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment