Move VM mount functionality to PAM for better umount handling.
This commit is contained in:
parent
f854b3659c
commit
793b37853e
4 changed files with 32 additions and 61 deletions
|
@ -18,6 +18,8 @@ exit_script_home() {
|
|||
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"
|
||||
|
@ -56,27 +58,4 @@ elif [ "$#" -gt 0 ] && [ "$1" = '-l' ]; then
|
|||
#echo "Um weiter zu arbeiten: <Strg> + <Z>"
|
||||
trap exit_script SIGHUP SIGINT SIGTERM
|
||||
sleep infinity
|
||||
else
|
||||
#mkdir -p "/media/${SUDO_USER}"
|
||||
#chown "${SUDO_USER}:1010" "/media/${SUDO_USER}"
|
||||
chgrp 1010 "/lmn/media/${SUDO_USER}"
|
||||
chmod 0770 "/lmn/media/${SUDO_USER}"
|
||||
#if ! findmnt "/lmn/media/${SUDO_USER}/share"; then
|
||||
# [[ -d "/lmn/media/${SUDO_USER}/share" ]] || mkdir "/lmn/media/${SUDO_USER}/share"
|
||||
# mount --bind "/lmn/media/${SUDO_USER}/.default-school/share" "/lmn/media/${SUDO_USER}/share"
|
||||
#fi
|
||||
if ! findmnt "/lmn/media/${SUDO_USER}/home"; then
|
||||
[[ -d "/lmn/media/${SUDO_USER}/home" ]] || mkdir "/lmn/media/${SUDO_USER}/home"
|
||||
home="$(getent passwd $SUDO_USER | cut -d: -f6)"
|
||||
mount -t cifs -o "sec=krb5i,cruid=${SUDO_UID},user=${SUDO_USER},uid=${SUDO_UID},gid=1010,file_mode=0770,dir_mode=0770,nobrl,mfsymlinks" \
|
||||
"//server/default-school/${home##/srv/samba/schools/default-school/}" "/lmn/media/${SUDO_USER}/home"
|
||||
trap exit_script_home SIGHUP SIGINT SIGTERM
|
||||
sleep infinity
|
||||
fi
|
||||
#mkdir -p "/lmn/media/${SUDO_USER}/home"
|
||||
#mkdir -p "/lmn/media/${SUDO_USER}/share"
|
||||
#mount -t cifs -o "sec=krb5i,cruid=${SUDO_UID},user=${SUDO_USER},uid=${SUDO_UID},gid=1010,file_mode=0770,dir_mode=0770,mfsymlinks" \
|
||||
# "//server/default-school/${home}" "/lmn/media/${SUDO_USER}/home"
|
||||
#mount -t cifs -o "sec=krb5i,cruid=${SUDO_UID},user=${SUDO_USER},uid=${SUDO_UID},gid=1010,file_mode=0770,dir_mode=0770,mfsymlinks" \
|
||||
# "//server/default-school/share" "/lmn/media/${SUDO_USER}/share"
|
||||
fi
|
||||
|
|
|
@ -99,18 +99,14 @@ check_images() {
|
|||
echo "VM-Image and required backingfiles available and checked"
|
||||
}
|
||||
|
||||
#################
|
||||
|
||||
# check, if we have to start squid
|
||||
if ! killall -s 0 squid; then
|
||||
echo "starting squid."
|
||||
/usr/sbin/squid -f /etc/squid/squid-usermode.conf
|
||||
fi
|
||||
|
||||
## check, if we have to mount home
|
||||
#if ! findmnt "/media/${USER}/home"; then
|
||||
# echo "mounting home."
|
||||
sudo mounthome.sh &
|
||||
#fi
|
||||
|
||||
# because virsh has problems with long pathnames, using diffent configdir
|
||||
export XDG_CONFIG_HOME="/tmp/${UID}/.config"
|
||||
|
||||
|
|
|
@ -9,24 +9,28 @@ if [[ $# -ne 1 ]]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
VM_NAME=$1
|
||||
|
||||
export XDG_RUNTIME_DIR="/run/user/${SUDO_UID}"
|
||||
VM_NAME="$1"
|
||||
XDG_RUNTIME_DIR="/run/user/${SUDO_UID}"
|
||||
|
||||
if ! [[ -d "${XDG_RUNTIME_DIR}/virtiofs" ]]; then
|
||||
mkdir "${XDG_RUNTIME_DIR}/virtiofs/"
|
||||
chown "${SUDO_UID}" "${XDG_RUNTIME_DIR}/virtiofs/"
|
||||
fi
|
||||
|
||||
[[ -S "${XDG_RUNTIME_DIR}/virtiofs/${VM_NAME}-clone.sock" ]] && \
|
||||
if [[ -S "${XDG_RUNTIME_DIR}/virtiofs/${VM_NAME}-clone.sock" ]] ; then
|
||||
/usr/bin/rm "${XDG_RUNTIME_DIR}/virtiofs/${VM_NAME}-clone.sock"
|
||||
#sudo /usr/lib/qemu/virtiofsd --socket-path="${XDG_RUNTIME_DIR}/virtiofs/${VM_NAME}-clone.sock" --socket-group="${SUDO_USER}" --announce-submounts -o source="/media/${USER}" > /dev/null &
|
||||
#sudo /usr/lib/qemu/virtiofsd --socket-path="${XDG_RUNTIME_DIR}/virtiofs/${VM_NAME}-clone.sock" --socket-group="${SUDO_USER}" -o source="/media/${USER}" > /dev/null &
|
||||
fi
|
||||
#sudo /usr/lib/qemu/virtiofsd --socket-path="${XDG_RUNTIME_DIR}/virtiofs/${VM_NAME}-clone.sock" \
|
||||
# --socket-group="${SUDO_USER}" --announce-submounts -o source="/media/${USER}" > /dev/null &
|
||||
#sudo /usr/lib/qemu/virtiofsd --socket-path="${XDG_RUNTIME_DIR}/virtiofs/${VM_NAME}-clone.sock" \
|
||||
# --socket-group="${SUDO_USER}" -o source="/media/${USER}" > /dev/null &
|
||||
|
||||
/usr/lib/qemu/virtiofsd --socket-path="${XDG_RUNTIME_DIR}/virtiofs/${VM_NAME}-clone.sock" \
|
||||
-o source="/lmn/media/${SUDO_USER}" > /dev/null &
|
||||
-o source="/lmn/media/${SUDO_USER}/" &
|
||||
|
||||
# Wait until socket-File exists and chown to user
|
||||
until [[ -S "${XDG_RUNTIME_DIR}/virtiofs/${VM_NAME}-clone.sock" ]]; do
|
||||
echo "waiting for ${XDG_RUNTIME_DIR}/virtiofs/${VM_NAME}-clone.sock"
|
||||
sleep 0.1
|
||||
echo "waiting for ${XDG_RUNTIME_DIR}/virtiofs/${VM_NAME}-clone.sock"
|
||||
sleep 0.1
|
||||
done
|
||||
/usr/bin/chown "${SUDO_USER}" "${XDG_RUNTIME_DIR}/virtiofs/${VM_NAME}-clone.sock"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue