Created
February 28, 2017 09:53
-
-
Save timofurrer/e9259dd42ceb005940bc2e6001f7f0d2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hi