scripts/network/start_vnc/start_vnc.sh

25 lines
807 B
Bash
Raw Permalink Normal View History

2023-12-28 10:02:44 +01:00
#!/bin/bash
USERNAME=${USER,,}
LOCK_FILE=/tmp/start_vnc_$USERNAME.lock
ICON=application-x-vnc
SSH_HOST=ulrich.earth
SSH_PORT=2222
SSH_USER=karin
(
flock -n 200 || { echo "already running, exiting."; exit 1; }
password=$(echo -e $(od -vAn -N3 -tu4 < /dev/urandom))
info_text="Bildschirmfreigabe aktiv! Passwort: $password"
grdctl rdp disable-view-only
grdctl rdp set-credentials "admin" "$password"
grdctl rdp enable
2023-12-28 10:02:44 +01:00
systemctl --user start gnome-remote-desktop.service
ssh -C -N -R 3389:localhost:3389 -p $SSH_PORT $SSH_USER@$SSH_HOST &
2023-12-28 10:02:44 +01:00
ssh_pid="$!"
zenity --title="Bildschirmfreigabe auf $(hostname)" --info --text="$info_text" --width=230 --ok-label="Beenden" --icon="$ICON"
2023-12-28 10:02:44 +01:00
kill $ssh_pid
systemctl --user stop gnome-remote-desktop.service
grdctl rdp disable
2023-12-28 10:02:44 +01:00
) 200>"$LOCK_FILE"