From 2c201e160e756122e3e6fc0a1018ed177a24bf4c Mon Sep 17 00:00:00 2001 From: Raphael Dannecker Date: Sun, 8 Sep 2024 11:27:24 +0200 Subject: [PATCH] Improve printer installation on teacherlaptops - Update printer list when connected via VPN - Prevent printer removal, when logging in without a connection to the school network --- roles/lmn_printer/templates/install-printers.sh.j2 | 3 +++ roles/lmn_teacherlaptop/files/10-lmn-mount.sh | 1 + 2 files changed, 4 insertions(+) diff --git a/roles/lmn_printer/templates/install-printers.sh.j2 b/roles/lmn_printer/templates/install-printers.sh.j2 index cd9009a..e9129a0 100644 --- a/roles/lmn_printer/templates/install-printers.sh.j2 +++ b/roles/lmn_printer/templates/install-printers.sh.j2 @@ -2,6 +2,9 @@ set -eu +## Exit if first printserver is not reachable +ping -c1 -W1 {{ printservers | first }} || exit 0 + printservers="{{ printservers | join(' ') }}" hostgroup="$(id -Gn "${HOSTNAME^^}$")" usergroup="$(id -Gn "${SUDO_USER}")" diff --git a/roles/lmn_teacherlaptop/files/10-lmn-mount.sh b/roles/lmn_teacherlaptop/files/10-lmn-mount.sh index b7a1dfa..6f42725 100755 --- a/roles/lmn_teacherlaptop/files/10-lmn-mount.sh +++ b/roles/lmn_teacherlaptop/files/10-lmn-mount.sh @@ -30,6 +30,7 @@ if [[ "$CONNECTION_ID" = "VPN-Schule" ]]; then -o "sec=krb5i,cruid=${USERID},user=${USERNAME},uid=${USERID},gid=${GROUPID},file_mode=0700,dir_mode=0700,mfsymlinks,nobrl,actimeo=600,cache=loose,echo_interval=10" echo "after mount" >&2 mount --bind /srv/samba/schools/default-school/share "/lmn/media/${USERNAME}/share" + SUDO_USER=$USERNAME /usr/local/bin/install-printers.sh elif [[ "$NM_DISPATCHER_ACTION" = "pre-down" ]]; then # FIXME: Only umount server when Wireguard-Connection was the only connection to server. # Dirty fix (works only in fvs-IP-Range)