-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathba-labs-set-resolution.sh
executable file
·79 lines (64 loc) · 1.66 KB
/
ba-labs-set-resolution.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
usage() {
cat <<EOF
Usage:
sudo $0 <resolution>
<resolution> is specified as WIDTHxHEIGHT, e.g. 1920x1080
This script must be run as root (e.g. via sudo)
EOF
}
check_params() {
if [ -z $1 ]; then
usage
exit 1
fi
if [[ ! $1 =~ ^[0-9][0-9]*x[0-9][0-9]*$ ]]; then
usage
exit 1
fi
if [ $UID -ne 0 ]; then
usage
exit 1
fi
}
update_service_file() {
cat <<EOF > /etc/systemd/system/[email protected]
[Unit]
Description=Start VNC server at startup
After=syslog.target network.target
[Service]
Type=forking
User=$SUDO_USER
Group=$SUDO_USER
WorkingDirectory=/home/$SUDO_USER
PIDFile=/home/$SUDO_USER/.vnc/%H:%i.pid
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill :%i > /dev/null 2>&1 || :'
ExecStartPre=-/bin/rm -f /tmp/.X11-unix/X%i /tmp/.X%i-lock
ExecStart=/usr/bin/vncserver -depth 24 -geometry $1 :%i
ExecStop=/usr/bin/vncserver -kill %i
Restart=always
[Install]
WantedBy=multi-user.target
EOF
}
reload_service() {
systemctl daemon-reload
systemctl restart [email protected]
systemctl restart tomcat8.service
}
check_params $*
cat <<EOF
ATTENTION: You requested to change desktop resolution to $1
The Xvnc server will be restarted and all applications will close.
Make sure all your work is saved.
You will briefly lose the connection to the proxy server (Guacamole).
Wait ten seconds or so and reconnect again.
EOF
read -p "Enter YES to proceed: " proceed
proceed=`echo $proceed | tr a-z A-Z`
if [[ "$proceed" == "YES" ]]; then
reload_service &
update_service_file $*
else
echo "Resolution change cancelled"
fi