
- The new virtiofsd provides the ability to map a specified UID and GID to that of the user when running in user mode. As a result, virtiofsd is moved to userland for VMs and the new -uid and -gid options are introduced that specify the IDs on the guest.New v - The drives no longer have to be mounted with the group ID 1010. Therefore, the mount options are changed to the real group ID
66 lines
3.8 KiB
Bash
Executable file
66 lines
3.8 KiB
Bash
Executable file
#!/usr/bin/bash
|
|
set -eu
|
|
|
|
home="$(getent passwd "$SUDO_UID" | cut -d : -f 6 | sed 's|/srv/samba/schools/default-school/||')"
|
|
|
|
exit_script() {
|
|
echo "unmounting media - terminated by trap!" >> "/tmp/${SUDO_UID}-exit-mount.log"
|
|
findmnt "/lmn/media/${SUDO_USER}/oldhome" && umount "/lmn/media/${SUDO_USER}/oldhome" && rmdir "/lmn/media/${SUDO_USER}/oldhome"
|
|
findmnt "/lmn/media/${SUDO_USER}/oldprojects" && umount "/lmn/media/${SUDO_USER}/oldprojects" && rmdir "/lmn/media/${SUDO_USER}/oldprojects"
|
|
findmnt "/lmn/media/${SUDO_USER}/linuxhome" && umount "/lmn/media/${SUDO_USER}/linuxhome" && rmdir "/lmn/media/${SUDO_USER}/linuxhome"
|
|
trap - SIGHUP SIGINT SIGTERM # clear the trap
|
|
kill -- -$$ # Sends SIGTERM to child/sub processes
|
|
}
|
|
|
|
exit_script_home() {
|
|
echo "unmounting media - terminated by trap!" >> "/tmp/${SUDO_UID}-exit-mount.log"
|
|
umount "/lmn/media/${SUDO_USER}/home"
|
|
trap - SIGHUP SIGINT SIGTERM # clear the trap
|
|
kill -- -$$ # Sends SIGTERM to child/sub processes
|
|
}
|
|
|
|
##########################
|
|
|
|
if [[ "$#" -gt 0 ]] && [[ "$1" = '-u' ]]; then
|
|
findmnt "/lmn/media/${SUDO_USER}/home" && umount "/lmn/media/${SUDO_USER}/home" && rmdir "/lmn/media/${SUDO_USER}/home"
|
|
#findmnt "/lmn/media/${SUDO_USER}/share" && umount "/lmn/media/${SUDO_USER}/share" && rmdir "/lmn/media/${SUDO_USER}/share"
|
|
findmnt "/lmn/media/${SUDO_USER}/oldhome" && umount "/lmn/media/${SUDO_USER}/oldhome" && rmdir "/lmn/media/${SUDO_USER}/oldhome"
|
|
findmnt "/lmn/media/${SUDO_USER}/oldprojects" && umount "/lmn/media/${SUDO_USER}/oldprojects" && rmdir "/lmn/media/${SUDO_USER}/oldprojects"
|
|
findmnt "/lmn/media/${SUDO_USER}/linuxhome" && umount "/lmn/media/${SUDO_USER}/linuxhome" && rmdir "/lmn/media/${SUDO_USER}/linuxhome"
|
|
elif [ "$#" -gt 0 ] && [ "$1" = '-o' ]; then
|
|
echo "Einbinden der Daten des alten/bisherigen Systems (PaedML Novell)."
|
|
echo "Bitte den Username und Passwort aus dem ALTEN System eingeben."
|
|
read -rp "Username: " username
|
|
read -srp "Passwort: " PASSWD
|
|
export PASSWD
|
|
echo
|
|
mkdir -p "/lmn/media/${SUDO_USER}/oldhome"
|
|
mkdir -p "/lmn/media/${SUDO_USER}/oldprojects"
|
|
#errcode=$(mount -t cifs -o "username=${username},uid=${SUDO_UID},gid=${SUDO_GID},file_mode=0700,dir_mode=0700,forceuid,forcegid" \
|
|
# "//192.168.1.2/DOCS/fvs" "/lmn/media/${SUDO_USER}/oldhome")
|
|
#if [[ ! "${errcode}" ]]; then
|
|
mount -t cifs -o "username=${username},uid=${SUDO_UID},gid=${SUDO_GID},file_mode=0700,dir_mode=0700,forceuid,forcegid,nobrl,mfsymlinks" \
|
|
"//192.168.1.2/DOCS/fvs" "/lmn/media/${SUDO_USER}/oldhome"
|
|
mount -t cifs -o "username=${username},uid=${SUDO_UID},gid=${SUDO_GID},file_mode=0700,dir_mode=0700,forceuid,forcegid,nobrl,mfsymlinks" \
|
|
"//192.168.1.2/DATA/fvs/projekte" "/lmn/media/${SUDO_USER}/oldprojects"
|
|
#echo "Mounting successfull!"
|
|
echo "Einbindung erfolgreich!"
|
|
echo "Dieses Fenster bitte nicht schließen!"
|
|
#echo "Um weiter zu arbeiten: <Strg> + <Z>"
|
|
trap exit_script SIGHUP SIGINT SIGTERM
|
|
sleep infinity
|
|
elif [ "$#" -gt 0 ] && [ "$1" = '-l' ]; then
|
|
echo "Einbinden des Netboot-Home-Verzeichnises. Daten des alten/bisherigen Systems (PaedML Novell)."
|
|
echo "Bitte den Username und Passwort aus dem ALTEN System (PaedML Novell) eingeben."
|
|
echo "Bitte auch Groß- und Kleinschreibung achten."
|
|
read -rp "Username: " username
|
|
mkdir -p "/lmn/media/${SUDO_USER}/linuxhome"
|
|
mount -t fuse -o "allow_other,uid=${SUDO_UID},gid=${SUDO_GID},reconnect" \
|
|
"sshfs#${username}@home.steinbeisschule-reutlingen.de:" "/lmn/media/${SUDO_USER}/linuxhome"
|
|
#echo "Mounting successfull!"
|
|
echo "Einbindung erfolgreich!"
|
|
echo "Dieses Fenster bitte nicht schließen!"
|
|
#echo "Um weiter zu arbeiten: <Strg> + <Z>"
|
|
trap exit_script SIGHUP SIGINT SIGTERM
|
|
sleep infinity
|
|
fi
|