Skip to content

Instantly share code, notes, and snippets.

@timofurrer
Created February 28, 2017 09:53
Show Gist options
  • Save timofurrer/e9259dd42ceb005940bc2e6001f7f0d2 to your computer and use it in GitHub Desktop.
Save timofurrer/e9259dd42ceb005940bc2e6001f7f0d2 to your computer and use it in GitHub Desktop.
#!/bin/sh
MODULES='
CNA:3264958
AD:3264934
FKOM:3265225
PMB:3265214
'
BASE_URL='https://elearning.hslu.ch/ilias/webdav.php/hslu'
if [ -z "$1" ]; then
echo 'Please specify a module name or ILIAS ref id for the share' >&2
exit 1
fi
if echo "$1" | grep -qv 'ref_'; then
module=$(echo "$MODULES" | grep "$1")
if [ -z "$module" ]; then
echo "Given module $1 not defined with it's corresponding ILIAS ref id" >&2
exit 1
fi
dav_ref_id="ref_$(echo "$module" | cut -d: -f2)"
else
dav_ref_id="$1"
fi
if [ -z "$2" ]; then
target=$(echo "$module" | cut -d: -f1)
else
target=$2
fi
mkdir -p "$target"
mount_opts=''
# FIXME(TF): if enabled davfs mount does not hide password
#username=$(cat ~/.ilias_username 2>/dev/null)
#if [ -n "${username}" ]; then
#mount_opts="username=${username}"
#fi
sudo mount -t davfs "${BASE_URL}/${dav_ref_id}/" "$target" -o "${mount_opts}"
@4petneeds88
Copy link

hi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment