-
Notifications
You must be signed in to change notification settings - Fork 2
/
menue_vnc.bash
231 lines (194 loc) · 4.72 KB
/
menue_vnc.bash
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
#!/bin/bash
# Set UTF-8; e.g. "en_US.UTF-8" or "de_DE.UTF-8":
#export LANG="C.UTF-8"
export LC_ALL="C.UTF-8"
# Tell ncurses to use line characters that work with UTF-8.
export NCURSES_NO_UTF8_ACS=1
separator=":"
function CHECK_ROOT {
# check if root for future installations
if [ "$(id -u)" != "0" ];
then
echo "This script must be run as root. Like this sudo $0" #1>&2
exit 1
else
echo "This script runs as root." #1>&2
fi
}
function OPTIONS {
case $VALUE in
1) ONE;;
2) TWO;;
3) THREE;;
4) FOUR;;
5) echo "$VALUE";;
6) echo "$VALUE";;
7) echo "$VALUE";;
8) echo "$VALUE";;
9) CREATE_SERVICE_FILE;;
esac
}
function APT_UPDATE {
apt-get update 1> /dev/null
}
function APT_DISTUPGRADE {
apt-get -y dist-upgrade
apt-get -y autoclean
apt-get -y autoremove
}
function ONE {
APT_UPDATE
APT_DISTUPGRADE
DONE
sleep 1
MENU
}
function DONE {
dialog --backtitle "Installing VNC-Server on OSMC" \
--infobox "Done" \
5 20
}
function TWO () {
FRESH_VARIABLES
CONFS SET_VARIABLES
}
function TWO_PARTS {
DONE
sleep 1
MENU
}
function THREE {
CONFS FOUR
}
#function FOUR {
# echo "4"
# pass="4444"
# sed -i /etc/dispmanx_vncserver.conf -e 's/password =.*/password = "'"$pass"'";/'
# sed -i /etc/dispmanx_vncserver.conf -e 's/port =.*/port = '"$pass"';/'
#}
function FOUR {
GREP_VARIABLES
CONFIG SET_VARIABLES
}
function GREP_VARIABLES {
port=$(egrep "port" /etc/dispmanx_vncserver.conf | egrep -o [0-9]+)
framerate=$(egrep "frame-rate" /etc/dispmanx_vncserver.conf | egrep -o [0-9]+)
mypassword=$(egrep "password" /etc/dispmanx_vncserver.conf | cut -d'"' -f2)
}
function FRESH_VARIABLES {
port="5900"
framerate="23"
mypassword=""
}
function COPY_CONF {
sudo cp dispmanx_vncserver.conf.sample /etc/dispmanx_vncserver.conf
}
function SET_VARIABLES {
sed -i /etc/dispmanx_vncserver.conf -e 's/port =.*/port = '"$port"';/'
sed -i /etc/dispmanx_vncserver.conf -e 's/frame-rate =.*/frame-rate = '"$framerate"';/'
sed -i /etc/dispmanx_vncserver.conf -e 's/password =.*/password = "'"$mypassword"'";/'
}
function APT_INSTALL {
apt-get install -y build-essential rbp-userland-dev-osmc libvncserver-dev libconfig++-dev unzip 1> /dev/null
}
function CLEAN {
cd /home/osmc
if [ -d "dispmanx_vnc-master/" ];
then
rm -rf dispmanx_vnc-master/
fi
if [ -d "master.zip" ];
then
rm -f master.zip
fi
}
function GET_DISPMANX {
cd /home/osmc
wget -q https://github.com/patrikolausson/dispmanx_vnc/archive/master.zip
unzip -q -u master.zip -d /home/osmc/
}
function MAKE_DISPMANX {
cd dispmanx_vnc-master
# --quiet after make to make it silent
make --quiet clean
make --quiet
}
function CREATE_SERVICE_FILE {
cat > "/etc/systemd/system/dispmanx_vncserver.service" <<-EOF
[Unit]
Description=VNC Server
After=network-online.target
Requires=network-online.target
[Service]
Restart=on-failure
RestartSec=30
Nice=15
User=root
Group=root
Type=simple
ExecStartPre=/sbin/modprobe evdev
ExecStart=/usr/bin/dispmanx_vncserver
KillMode=process
[Install]
WantedBy=multi-user.target
EOF
}
function CONFIG () {
echo $1
# Store data to $VALUES variable
VALUES=$(dialog --title "" \
--stdout \
--backtitle "Installing VNC-Server on OSMC" \
--insecure \
--output-separator $separator \
--mixedform "Configuration" \
10 50 0 \
"Port:" 1 2 "$port" 1 17 12 0 0 \
"Framerate:" 2 2 "$framerate" 2 17 12 0 0 \
"VNC-Password:" 3 2 "$mypassword" 3 17 12 0 1 \
)
rep=$?
# display values just entered
#echo "$VALUES"
#echo "$response"
port=$(echo "$VALUES" | cut -f 1 -d "$separator")
framerate=$(echo "$VALUES" | cut -f 2 -d "$separator")
mypassword=$(echo "$VALUES" | cut -f 3 -d "$separator")
#echo "$port"
#echo "$framerate"
#echo "$mypassword"
case $rep in
0) $1;;
1) MENU;;
255) MENU;;
esac
}
function MENU {
# Store data to $VALUES variable
VALUE=$(dialog --backtitle "Installing VNC-Server on OSMC" --title "" \
--stdout \
--no-tags \
--cancel-label "Quit" \
--menu "Choose a Option" 17 54 9 \
"1" "OSMC System-Update with clean-up" \
"2" "Install VNC Server and Service" \
"3" "Update VNC Server (after a kernel update)" \
"4" "Change VNC settings" \
"5" "Start VNC Server (manual, no service)" \
"6" "Stop VNC Server"\
"7" "Install VNC Service (on boot)" \
"8" "Remove VNC Service" \
"9" "Remove/Clean all up"
)
response=$?
# display values just entered
#echo "$response"
#echo "$VALUE"
case $response in
0) OPTIONS;;
1) ;;
255) ;;
esac
}
CHECK_ROOT
MENU