scripts/network/start_vnc/start_vnc.sh

25 lines
807 B
Bash

#!/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
systemctl --user start gnome-remote-desktop.service
ssh -C -N -R 3389:localhost:3389 -p $SSH_PORT $SSH_USER@$SSH_HOST &
ssh_pid="$!"
zenity --title="Bildschirmfreigabe auf $(hostname)" --info --text="$info_text" --width=230 --ok-label="Beenden" --icon="$ICON"
kill $ssh_pid
systemctl --user stop gnome-remote-desktop.service
grdctl rdp disable
) 200>"$LOCK_FILE"