initial commit
This commit is contained in:
commit
a83a99dc1d
7 changed files with 447 additions and 0 deletions
61
fhnw-ad-mount
Executable file
61
fhnw-ad-mount
Executable file
|
@ -0,0 +1,61 @@
|
|||
#!/usr/bin/env sh
|
||||
set -o errexit
|
||||
|
||||
export SUDO_PROMPT="sudo password: "
|
||||
|
||||
mount_dir="/mnt/fhnw-share"
|
||||
pass_path="accounts/fhnw/students.fhnw.ch"
|
||||
|
||||
display_help() {
|
||||
echo "Usage: $0 [option...] " >&2
|
||||
echo
|
||||
echo " -m, ad mount directory [default: $mount_dir]"
|
||||
echo " -p, path for pass to get user and password information [default: $pass_path]"
|
||||
echo " -h, display this help and exit"
|
||||
echo
|
||||
}
|
||||
|
||||
parse_args() {
|
||||
while getopts ":hm:p:" opt; do
|
||||
case $opt in
|
||||
h)
|
||||
display_help
|
||||
exit 0
|
||||
;;
|
||||
m)
|
||||
mount_dir=$OPTARG
|
||||
;;
|
||||
p)
|
||||
pass_path=$OPTARG
|
||||
;;
|
||||
\?)
|
||||
echo "Invalid option: -$OPTARG" >&2
|
||||
display_help
|
||||
exit 1
|
||||
;;
|
||||
:)
|
||||
echo "Option -$OPTARG requires an argument." >&2
|
||||
display_help
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
get_account_info() {
|
||||
echo "getting account info from pass..."
|
||||
acc_info="$(pass "$pass_path")"
|
||||
acc_pw="$(echo "$acc_info" | head -n 1)"
|
||||
acc_user="$(echo "$acc_info" | awk -F ': ' '/^login-shortcut:/ {print $2}')"
|
||||
}
|
||||
|
||||
mount_ad() {
|
||||
echo "mounting ad..."
|
||||
sudo mkdir -p "$mount_dir"
|
||||
sudo mount -t cifs //fs.edu.ds.fhnw.ch/data "$mount_dir" \
|
||||
-o vers=3.0,username="$acc_user",password="$acc_pw",workgroup=EDU,iocharset=utf8,uid="$USER",gid="$USER"
|
||||
}
|
||||
|
||||
parse_args "$@"
|
||||
get_account_info
|
||||
mount_ad
|
Loading…
Add table
Add a link
Reference in a new issue