debian-config-submenu 13.6 KB
Newer Older
Igor Pecovnik's avatar
Igor Pecovnik committed
1
2
#!/bin/bash
#
Igor Pecovnik's avatar
Igor Pecovnik committed
3
# Copyright (c) 2018 Igor Pecovnik, igor.pecovnik@gma**.com
Igor Pecovnik's avatar
Igor Pecovnik committed
4
5
6
7
8
#
# This file is licensed under the terms of the GNU General Public
# License version 2. This program is licensed "as is" without any
# warranty of any kind, whether express or implied.

9
10
11
12
13
# Functions:
# submenu_settings
# submenu_networking
# submenu_personal
# submenu_software
14

Igor Pecovnik's avatar
Igor Pecovnik committed
15
16
17
18
19



#
# system settings
Igor Pecovnik's avatar
Igor Pecovnik committed
20
#
Igor Pecovnik's avatar
Igor Pecovnik committed
21
function submenu_settings ()
Igor Pecovnik's avatar
Igor Pecovnik committed
22
23
24
25
{
while true; do

	LIST=()
Igor Pecovnik's avatar
Igor Pecovnik committed
26
27
	DIALOG_CANCEL=1
	DIALOG_ESC=255
Igor Pecovnik's avatar
Igor Pecovnik committed
28

29
30
31
	# detect desktop
	check_desktop

Igor Pecovnik's avatar
Igor Pecovnik committed
32
	# check update status of BSP packages
33
34
	local mark=$(apt-mark showhold | grep -w "$BOARD")

Igor Pecovnik's avatar
Igor Pecovnik committed
35
36
37
38
39
40
41
	# check if install targets are avaliable
	if [[ $(sed -n 's/^DEVNAME=//p' /sys/dev/block/$(mountpoint -d /)/uevent 2> /dev/null) == mmcblk* \
	&& -f /usr/sbin/nand-sata-install ]]; then
		LIST+=( "Install" "Install to SATA, eMMC, NAND or USB" )
	fi

	# armbian specific function
42
43
44
45
46
47
	if [[ -f /etc/armbian-release ]]; then
		if [[ -n "${mark}" ]]; then
				LIST+=( "Defreeze" "Enable kernel upgrades" )
			else
				LIST+=( "Freeze" "Disable kernel upgrades" )
		fi
48
	fi
Igor Pecovnik's avatar
Igor Pecovnik committed
49
50
51
52

	# armbian specific function, when upgrades are enabled
	if [[ -z ${mark} ]]; then
		[[ -f /etc/apt/sources.list.d/armbian.list ]] && [[ -n $(grep -w apt /etc/apt/sources.list.d/armbian.list) ]] \
53
		&& LIST+=( "Nightly" "Switch to nightly automated builds" )
Igor Pecovnik's avatar
Igor Pecovnik committed
54
		[[ -f /etc/apt/sources.list.d/armbian.list ]] && [[ -n $(grep -w beta /etc/apt/sources.list.d/armbian.list) ]] \
55
56
		&& LIST+=( "Stable" "Switch to stable builds" )
	fi
Igor Pecovnik's avatar
Igor Pecovnik committed
57

58
	[[ -n $(grep -w "#kernel.printk" /etc/sysctl.conf ) ]] && LIST+=( "Lowlevel" "Stop low-level messages on console" )
Igor Pecovnik's avatar
Igor Pecovnik committed
59

60
61
62
	[[ -f /boot/armbianEnv.txt ]] && LIST+=( "Bootenv" "Edit boot environment" )
	[[ -f /boot/boot.ini ]] && LIST+=( "Bootscript" "Edit boot script" )

63
	[[ -d ${OVERLAYDIR} ]] && \
64
	LIST+=( "Hardware" "Toggle hardware configuration: UART, I2C, etc." )
65
	[[ "$LINUXFAMILY" = cubox && "$BRANCH" = "next" ]] && LIST+=( "DTB" "Switch board .dtb configuration" )
66
67
68
	# this is avaliable only in kernel higher than 4.10
	testvercomp "$(uname -r | sed 's/-.*//')" "4.10.0" ">"
	[[ "$LINUXFAMILY" = odroidxu4 && $? == 0 ]] && LIST+=( "DTB" "Select optimised board configuration" )
69
70
	[[ -f /usr/bin/bin2fex && "$LINUXFAMILY" = sun*i && "$BRANCH" = "default" ]] && LIST+=( "Fexedit" "Board (fex) settings editor" )
	[[ $(apt-cache search --names-only '^linux-'$(lsb_release  -cs)'-root.*.'$BOARD'' | sed 's/.*(\(.*\))/\1/' | awk '{print $1}' \
71
	| wc -l) -gt 1 && -z "${mark}" ]] && LIST+=( "Switch" "Switch to alternative kernels" )
72

Igor Pecovnik's avatar
Igor Pecovnik committed
73
	LIST+=( "SSH" "Reconfigure SSH daemon" )
74
	LIST+=( "Firmware" "Run apt update & apt upgrade" )
75
76
77
78
79
80
81
82

	if [[ "$SHELL" != "/bin/bash" ]]; then
		LIST+=( "BASH" "Revert to stock BASH shell" )
		else
		LIST+=( "ZSH" "Install ZSH with most used plugins and tmux" )
	fi


83
84
	[[ "$LINUXFAMILY" = sun*i && "$BRANCH" = "default" && \
	-n $(bin2fex </boot/script.bin 2>/dev/null | grep -w "hdmi_used = 1") ]] && LIST+=( "Display" "set the display resolution" )
85
	[[ "$LINUXFAMILY" = odroidc* && "$BRANCH" = "default" ]] && LIST+=( "Display" "set the display resolution" )
Igor Pecovnik's avatar
Igor Pecovnik committed
86
	# desktop
Igor Pecovnik's avatar
Igor Pecovnik committed
87
88
	if [[ -n $DISPLAY_MANAGER ]]; then
			LIST+=( "Desktop" "Disable desktop" )
89
90
91
			if ! check_if_installed mpv ; then
				LIST+=( "Default" "Install desktop with browser and extras" )
			fi
Igor Pecovnik's avatar
Igor Pecovnik committed
92
93
			[[ $DISPLAY_MANAGER == 'nodm' ]] && 			LIST+=( "Lightdm" "Switch to standard login manager" )
			[[ $DISPLAY_MANAGER == 'lightdm' ]] && 			LIST+=( "Nodm" "Switch to simple auto login manager" )
94
95
	else
			if [[ -n $DESKTOP_INSTALLED ]]; then
Igor Pecovnik's avatar
Igor Pecovnik committed
96
															LIST+=( "Desktop" "Enable desktop" )
97
98
99
															if ! check_if_installed mpv ; then
																LIST+=( "Default" "Install desktop with browser and extras" )
															fi
100
				else
101
102
103
104
															LIST+=( "Minimal" "Install minimal desktop" )
															if ! check_if_installed mpv ; then
																LIST+=( "Default" "Install desktop with browser and extras" )
															fi
105
			fi
Igor Pecovnik's avatar
Igor Pecovnik committed
106
107
	fi

Igor Pecovnik's avatar
Igor Pecovnik committed
108
	# overlayroot
Igor Pecovnik's avatar
Igor Pecovnik committed
109
110
111
112
113
114
115
116
117
118
119
	if [[ "$DISTRO" == "Ubuntu" && "$(modinfo overlay > /dev/null 2>&1; echo $?)" == "0" ]]; then
		if [ -n "$(mount | grep -w tmpfs-root)" ]; then
			LIST+=( "Overlayroot" "Disable virtual read-only root filesystem" )
		else
			LIST+=( "Overlayroot" "Enable virtual read-only root filesystem" )
		fi
	fi

	# count number of menu items to adjust window sizee
	LISTLENGHT="$((6+${#LIST[@]}/2))"
	BOXLENGHT=${#LIST[@]}
Igor Pecovnik's avatar
Igor Pecovnik committed
120
121

	exec 3>&1
Igor Pecovnik's avatar
Igor Pecovnik committed
122
	selection=$(dialog --colors --backtitle "$BACKTITLE" --title " System settings " --clear \
123
	--cancel-label "Cancel" --menu "$disclaimer" $LISTLENGHT 70 $BOXLENGHT \
Igor Pecovnik's avatar
Igor Pecovnik committed
124
125
126
127
	"${LIST[@]}" 2>&1 1>&3)
	exit_status=$?
	exec 3>&-
	[[ $exit_status == $DIALOG_CANCEL || $exit_status == $DIALOG_ESC ]] && clear && break
Igor Pecovnik's avatar
Igor Pecovnik committed
128
129

	# run main function
Igor Pecovnik's avatar
Igor Pecovnik committed
130
131
132
133
	jobs "$selection"
done
}

Igor Pecovnik's avatar
Igor Pecovnik committed
134

Igor Pecovnik's avatar
Igor Pecovnik committed
135
136
137


#
Igor Pecovnik's avatar
Igor Pecovnik committed
138
139
140
141
# menu for networking
#
function submenu_networking ()
{
Igor Pecovnik's avatar
Igor Pecovnik committed
142
143

# if there is more than one connected device
144
select_default_interface
Igor Pecovnik's avatar
Igor Pecovnik committed
145

Igor Pecovnik's avatar
Igor Pecovnik committed
146
while true; do
Igor Pecovnik's avatar
Igor Pecovnik committed
147

Igor Pecovnik's avatar
Igor Pecovnik committed
148
	LIST=()
Igor Pecovnik's avatar
Igor Pecovnik committed
149
150
	DIALOG_CANCEL=1
	DIALOG_ESC=255
Igor Pecovnik's avatar
Igor Pecovnik committed
151

152
153
154
	# check if we have some LTE modems
	for i in $(lsusb | awk '{print $6}'); do lte "$i"; done;

Igor Pecovnik's avatar
Igor Pecovnik committed
155
	# edit ip
Igor Pecovnik's avatar
RC1    
Igor Pecovnik committed
156
	LIST+=( "IP" "Select dynamic or edit static IP address" )
Igor Pecovnik's avatar
Igor Pecovnik committed
157
158

	# hostapd
Igor Pecovnik's avatar
Igor Pecovnik committed
159
	HOSTAPDBRIDGE=$(cat /etc/hostapd.conf 2> /dev/null | grep -w "^bridge=br0")
Igor Pecovnik's avatar
Igor Pecovnik committed
160
	HOSTAPDSTATUS=$(service hostapd status 2> /dev/null | grep -w active | grep -w running)
Igor Pecovnik's avatar
Igor Pecovnik committed
161
162
163
164
	if [[ -n "$HOSTAPDSTATUS" ]]; then
			HOSTAPDINFO=$(hostapd_cli get_config 2> /dev/null | grep ^ssid | sed 's/ssid=//g')
			HOSTAPDCLIENTS=$(hostapd_cli all_sta 2> /dev/null | grep connected_time | wc -l)
			LIST+=( "Hotspot" "Manage active wireless access point" )
Igor Pecovnik's avatar
Igor Pecovnik committed
165
		else
166
			[[ -n $(LC_ALL=C nmcli device status 2> /dev/null | grep wifi | grep -w disconnected) ]] && LIST+=( "Hotspot" "Create WiFi access point" )
Igor Pecovnik's avatar
Cleanup    
Igor Pecovnik committed
167

Igor Pecovnik's avatar
Igor Pecovnik committed
168
	fi
169

Igor Pečovnik's avatar
Igor Pečovnik committed
170
171
172
173
174
175
176
	# toogle IPV6
	if [[ $(cat /proc/sys/net/ipv6/conf/all/disable_ipv6) == 1 ]]; then
			LIST+=( "IPV6" "Enable IPV6 for APT and system" )
		else
			LIST+=( "IPV6" "Disable IPV6 for APT and system" )
	fi

Igor Pecovnik's avatar
Igor Pecovnik committed
177
178
179
180
181
182
183
184
	# network throughput test
	if check_if_installed iperf3; then
		if pgrep -x "iperf3" > /dev/null
		then
			LIST+=( "Iperf3" "Disable network throughput tests daemon" )
			else
			LIST+=( "Iperf3" "Enable network throughput tests daemon" )
		fi
185
186
	fi

187
	if [[ -n $(LC_ALL=C nmcli device status 2> /dev/null | grep wifi | grep -v unavailable | grep -v unmanaged) ]]; then
188
189
190
191
		LIST+=( "WiFi" "Manage wireless networking" )
	else
		LIST+=( "Clear" "Clear possible blocked interfaces" )
	fi
192
193
194
195
196
197
198

	if [[ -n $LTE_MODEM ]]; then
		# apply udev rules
		initialize_lte
		LIST+=( "LTE" "$LTE_MODEM" )
	fi

199
200
201
202
203
204
205
206
	check_if_installed lirc && LIST+=( "Remove IR" "Remove IR support" ) || LIST+=( "IR" "Install IR support" )
	if check_if_installed bluetooth then ; then
			LIST+=( "BT remove" "Remove Bluetooth support" )
			if [[ -n $(service bluetooth status | grep -w active | grep -w running) ]]; then
				[[ $(hcitool dev | sed '1d') != "" ]] && LIST+=( "BT discover" "Discover and connect Bluetooth devices" )
			fi
		else
			LIST+=( "BT install" "Install Bluetooth support" )
Igor Pecovnik's avatar
Igor Pecovnik committed
207
208
	fi

209
210


211
212
	[[ -d /usr/local/vpnclient ]] && LIST+=( "VPN" "Manage Softether VPN client" ) && VPNSERVERIP=$(/usr/local/vpnclient/vpncmd /client localhost /cmd accountlist | grep "VPN Server" |grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' | head -1)

Igor Pecovnik's avatar
RC1    
Igor Pecovnik committed
213
	LIST+=( "Advanced" "Edit /etc/network/interfaces" )
Igor Pecovnik's avatar
Igor Pecovnik committed
214
215
	[[ $(ls -1 /etc/NetworkManager/system-connections 2> /dev/null) ]] && \
	LIST+=( "Forget" "Disconnect and forget all wireless connections" )
Igor Pecovnik's avatar
Igor Pecovnik committed
216
217

	# count number of menu items to adjust window sizee
218
	LISTLENGHT="$((12+${#LIST[@]}/2))"
Igor Pecovnik's avatar
Igor Pecovnik committed
219
	BOXLENGHT=${#LIST[@]}
220
	WIFICONNECTED=$(LC_ALL=C nmcli -f NAME,TYPE connection show --active 2> /dev/null | grep wireless | awk 'NF{NF-=1};1')
Igor Pecovnik's avatar
Igor Pecovnik committed
221

Igor Pecovnik's avatar
Cleanup    
Igor Pecovnik committed
222
	local disclaimer=""
223
224
225

	local ipadd=$(ip -4 addr show dev $DEFAULT_ADAPTER | awk '/inet/ {print $2}' | cut -d'/' -f1)

226

227
	if [[ -n $(LC_ALL=C nmcli device status 2> /dev/null | grep $DEFAULT_ADAPTER | grep connected) ]]; then
228
		local ifup="\nIP ($DEFAULT_ADAPTER) via Network Manager: \Z1${ipadd}\n\Z0 "
229
	else
230
231
232
233
234
		if [[ -n $(service systemd-networkd status | grep -w active | grep -w running) ]]; then
			local ifup="\nIP ($DEFAULT_ADAPTER) via systemd-networkd: \Z1${ipadd}\n\Z0 "
		else
			local ifup="\nIP ($DEFAULT_ADAPTER) via IFUPDOWN: \Z1${ipadd}\n\Z0 "
		fi
235
	fi
236

237
238
	disclaimer="$ifup"

Igor Pecovnik's avatar
Igor Pecovnik committed
239
	if [[ -n $WIFICONNECTED ]]; then
Igor Pecovnik's avatar
Cleanup    
Igor Pecovnik committed
240
		LISTLENGHT=$((LISTLENGHT+2))
241
242
		local connected="\n\Z0Connected to SSID: \Z1${WIFICONNECTED}\n\Z0 "
		disclaimer=$disclaimer"$connected"
Igor Pecovnik's avatar
Cleanup    
Igor Pecovnik committed
243
244
	fi

245
246
247
248
249
250
	if [[ -n $VPNSERVERIP ]]; then
		local vpnserverip="\n\Z0Connected to VPN server: \Z1${VPNSERVERIP}\n\Z0 "
		disclaimer=$disclaimer"$vpnserverip"
		LISTLENGHT=$((LISTLENGHT+2))
	fi

Igor Pecovnik's avatar
Igor Pecovnik committed
251
	if [[ -n $HOSTAPDINFO && -n $HOSTAPDSTATUS ]]; then
Igor Pecovnik's avatar
Cleanup    
Igor Pecovnik committed
252
		LISTLENGHT=$((LISTLENGHT+2))
Igor Pecovnik's avatar
Igor Pecovnik committed
253
		chpid=$(dmesg | grep $(grep ^interface /etc/hostapd.conf | sed 's/interface=//g') | head -1 | sed 's/\[.*\]//g' | awk '{print $1}')
254
		disclaimer=$disclaimer$"\n\Z0Hotspot SSID: \Z1$HOSTAPDINFO\Zn Band:";
255
		if [[ `grep ^hw_mode=a /etc/hostapd.conf` ]]; then local band="5Ghz"; else band="2.4Ghz"; fi
256
257
		if [[ `grep ^ieee80211n /etc/hostapd.conf` ]]; then local type="N"; fi
		if [[ `grep ^ieee80211ac /etc/hostapd.conf` ]]; then local type="AC"; fi
258
		disclaimer=$disclaimer$" \Z1${band} ${type}\Z0"
259
		[[ ! "$chpid" =~ .*IPv6.* ]] && disclaimer=$disclaimer$"\n\nChip: \Z1${chpid}\Z0";
Igor Pecovnik's avatar
Igor Pecovnik committed
260
		if [ "$HOSTAPDCLIENTS" -gt "0" ]; then disclaimer=$disclaimer$" Connected clients: \Z1$HOSTAPDCLIENTS\Zn"; fi
261
		if [[ ! "$chpid" =~ .*IPv6.* ]]; then LISTLENGHT=$((LISTLENGHT+2)); fi
Igor Pecovnik's avatar
Igor Pecovnik committed
262
		disclaimer=$disclaimer$"\n";
Igor Pecovnik's avatar
Igor Pecovnik committed
263
	fi
264
	disclaimer=$disclaimer"\n\Z1Note\Zn: This tool can be successful only when drivers are in good shape. If autodetection fails, you are on your own.\n "
Igor Pecovnik's avatar
Igor Pecovnik committed
265
266

	exec 3>&1
267
	selection=$(dialog --backtitle "$BACKTITLE" --colors --title " Wired, Wireless, Bluetooth, Hotspot " --clear \
268
	--cancel-label "Cancel" --menu "${disclaimer}" $LISTLENGHT 70 $BOXLENGHT \
Igor Pecovnik's avatar
Igor Pecovnik committed
269
270
271
272
273
	"${LIST[@]}" 2>&1 1>&3)
	exit_status=$?
	exec 3>&-
	[[ $exit_status == $DIALOG_CANCEL || $exit_status == $DIALOG_ESC ]] && clear && break

Igor Pecovnik's avatar
Igor Pecovnik committed
274
	# run main function
Igor Pecovnik's avatar
Igor Pecovnik committed
275
	jobs "$selection"
276

Igor Pecovnik's avatar
Igor Pecovnik committed
277
278
279
done
}

280

Igor Pecovnik's avatar
Igor Pecovnik committed
281
#-----------------------------------------------------------------------------------------------------------------------------------------#
282
# personal
Igor Pecovnik's avatar
Igor Pecovnik committed
283
#
284
function submenu_personal ()
Igor Pecovnik's avatar
Igor Pecovnik committed
285
286
287
288
{
while true; do

	LIST=()
289
290
	LIST+=( "Timezone" "Change timezone \Z5($(date +%Z))\Z0" )
	LIST+=( "Locales" "Reconfigure language \Z5($(locale | grep LANGUAGE | cut -d= -f2 | cut -d_ -f1))\Z0 and character set" )
Igor Pecovnik's avatar
Igor Pecovnik committed
291
	LIST+=( "Keyboard" "Change console keyboard layout (\Z5$(cat /etc/default/keyboard | grep XKBLAYOUT | grep -o '".*"' | sed 's/"//g')\Z0)")
292
	LIST+=( "Hostname" "Change your hostname \Z5($(cat /etc/hostname))\Z0" )
293
	[[ -f /etc/apt/sources.list.d/armbian.list ]] && LIST+=( "Mirror" "Change repository server" )
Igor Pecovnik's avatar
Igor Pecovnik committed
294
295
296
	LIST+=( "Welcome" "Toggle welcome screen items" )

	# count number of menu items to adjust window sizee
297
	LISTLENGHT="$((6+${#LIST[@]}/2))"
Igor Pecovnik's avatar
Igor Pecovnik committed
298
299
300
	BOXLENGHT=${#LIST[@]}

	exec 3>&1
301
302
	selection=$(dialog --colors --backtitle "$BACKTITLE" --title "Personal settings" --clear \
	--cancel-label "Cancel" --menu "$disclaimer" $LISTLENGHT 70 $BOXLENGHT \
Igor Pecovnik's avatar
Igor Pecovnik committed
303
304
305
306
	"${LIST[@]}" 2>&1 1>&3)
	exit_status=$?
	exec 3>&-
	[[ $exit_status == $DIALOG_CANCEL || $exit_status == $DIALOG_ESC ]] && clear && break
307
308

	# run main function
Igor Pecovnik's avatar
Igor Pecovnik committed
309
	jobs "$selection"
310

Igor Pecovnik's avatar
Igor Pecovnik committed
311
done
Igor Pecovnik's avatar
Igor Pecovnik committed
312
313
314
315
316
317
318
319
320
321
}


#-----------------------------------------------------------------------------------------------------------------------------------------#
# software
#
function submenu_software ()
{
while true; do

322
323
324
	# detect desktop
	check_desktop

Igor Pecovnik's avatar
Igor Pecovnik committed
325
	LIST=()
326
	[[ -f /usr/bin/softy || -f softy ]] && LIST+=( "Softy" "3rd party applications installer" )
Igor Pecovnik's avatar
Igor Pecovnik committed
327
328
329
330
	[[ -f /usr/bin/h3consumption && "$LINUXFAMILY" = "sun8i" && "$BRANCH" = "default" ]] && \
	LIST+=( "Consumption" "Control board consumption" )
	[[ -f /usr/bin/armbianmonitor ]] && LIST+=( "Monitor" "Simple CLI board monitoring" )
	[[ -f /usr/bin/armbianmonitor ]] && LIST+=( "Diagnostics" "Send diagnostics" )
331

Igor Pecovnik's avatar
Igor Pecovnik committed
332
333
	if [[ -n $(dpkg -l | grep linux-headers) ]]; then LIST+=( "Headers" "Remove kernel headers" ); else \
	LIST+=( "Headers" "Install kernel headers" ); fi
334

Igor Pecovnik's avatar
Igor Pecovnik committed
335
336
337
338
339
340
	SOURCE_PKG=$(apt-cache --names-only search ^linux-source-* | awk '{ print $1 }' | grep ${BRANCH}-${LINUXFAMILY} | tail -1)
	if [[ -n $SOURCE_PKG ]]; then
		if [[ -n $(dpkg -l | grep $SOURCE_PKG) ]]; then LIST+=( "Source" "Remove kernel source" ); else \
	        LIST+=( "Source" "Install kernel source" ); fi
	fi

Igor Pecovnik's avatar
Igor Pecovnik committed
341
	if [[ -f /etc/armbian.txt ]]; then
Igor Pecovnik's avatar
Bugfix    
Igor Pecovnik committed
342
		if [[ -n $(dpkg -l | grep -w "armbian-firmware-full ") ]]; then
343
344
345
346
347
348
			LIST+=( "Mini" "Install mini firmware package" );
		else
			LIST+=( "Full" "Install full firmware package" );
		fi
	fi

349
350
351
352
353
354
	if [[ -n $DISPLAY_MANAGER ]]; then
			if [[ $(service xrdp status 2> /dev/null | grep -w active) ]]; then
				LIST+=( "RDP" "Disable remote desktop access from Windows" )
				else
				LIST+=( "RDP" "Enable remote desktop access from Windows" )
			fi
355
			if ! check_if_installed thunderbird ; then
356
357
358
359
				LIST+=( "Thunderbird" "Install full featured email client" )
				else
				LIST+=( "Thunderbird" "Remove full featured email client" )
			fi
360
			if ! check_if_installed libreoffice-writer ; then
361
362
363
				LIST+=( "Writer" "Libreoffice: Writer only" )
				LIST+=( "Suite" "Libreoffice: Full suite" )
				else
364
					if ! check_if_installed libreoffice-base ; then
365
366
367
368
369
370
						LIST+=( "Suite" "Libreoffice: Full suite" )
						LIST+=( "Libre" "Remove Libre office packages" )
					else
						LIST+=( "Libre" "Remove Libre office packages" )
					fi
			fi
371
	fi
Igor Pecovnik's avatar
Igor Pecovnik committed
372
373
374
375
376
377
378

	# count number of menu items to adjust window sizee
	LISTLENGHT="$((6+${#LIST[@]}/2))"
	BOXLENGHT=${#LIST[@]}

	exec 3>&1
	selection=$(dialog --backtitle "$BACKTITLE" --title "System and 3rd party software" --clear \
379
	--cancel-label "Cancel" --menu "$disclaimer" $LISTLENGHT 70 $BOXLENGHT \
Igor Pecovnik's avatar
Igor Pecovnik committed
380
381
382
383
384
385
386
	"${LIST[@]}" 2>&1 1>&3)
	exit_status=$?
	exec 3>&-
	[[ $exit_status == $DIALOG_CANCEL || $exit_status == $DIALOG_ESC ]] && clear && break

	# run main function
	jobs "$selection"
387

Igor Pecovnik's avatar
Igor Pecovnik committed
388
done
389
}