debian-config-submenu 28.9 KB
Newer Older
Igor Pecovnik's avatar
Igor Pecovnik committed
1
2
3
4
5
6
7
8
9
#!/bin/bash
#
# Copyright (c) 2017 Igor Pecovnik, igor.pecovnik@gma**.com
#
# 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.


10
11
12
DIALOG_CANCEL=1
DIALOG_ESC=255

Igor Pecovnik's avatar
Igor Pecovnik committed
13

Igor Pecovnik's avatar
Igor Pecovnik committed
14
15
16
17
18
19
20
21
22
23
#-----------------------------------------------------------------------------------------------------------------------------------------#
# gather info about the board and start with loading menu
#
[[ -f /etc/armbian-release ]] && source /etc/armbian-release && ARMBIAN="Armbian $VERSION $IMAGE_TYPE";
DISTRO=$(lsb_release -is)
DISTROID=$(lsb_release -sc)
KERNELID=$(uname -r)
BACKTITLE="Configuration utility, $ARMBIAN, https://www.armbian.com"
TITLE="$BOARD_NAME "
DEFAULT_ADAPTER=$(ip -4 route ls | grep default | grep -Po '(?<=dev )(\S+)')
24
25
[[ -z "${DEFAULT_ADAPTER// }" ]] && DEFAULT_ADAPTER="lo"

Igor Pecovnik's avatar
Igor Pecovnik committed
26
27
dialog --backtitle "$BACKTITLE" --title "Please wait" --infobox "\nLoading Armbian configuration utility ... " 5 45
sleep 1
Igor Pecovnik's avatar
Igor Pecovnik committed
28
29


30
31
32
33
34
35
36
37
38
39
40
41
42
check_if_installed (){
#------------------------------------------------------------------------------------------------------------------------------------------
# check dpkg status of $1 -- currently only 'not installed at all' case catched
#------------------------------------------------------------------------------------------------------------------------------------------
	local DPKG_Status="$(dpkg -s "$1" 2>/dev/null | awk -F": " '/^Status/ {print $2}')"
	if [[ "X${DPKG_Status}" = "X" || "${DPKG_Status}" = *deinstall* ]]; then
		return 1
	else
		return 0
	fi
}


Igor Pecovnik's avatar
Igor Pecovnik committed
43
44
45
#-----------------------------------------------------------------------------------------------------------------------------------------#
# check all possible wireless modes
#
46
47
48
function check_advanced_modes ()
{
CHECK=$(systemctl daemon-reload;service hostapd stop; sleep 2;service hostapd start;sleep 2;service hostapd status|grep fail)
Igor Pecovnik's avatar
Igor Pecovnik committed
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
# check n,a and ac modes
if [[ -z "$CHECK" ]]; then
	dialog --title " Info " --backtitle "$BACKTITLE" --no-collapse --colors --infobox "\nProbing wireless 802.11n \Z1(150-300Mbps)\Z0" 5 43
	sleep 2
	sed '/### IEEE 802.11n/,/^### IEEE 802.11n/ s/^# *//' -i /etc/hostapd.conf
	CHECK=$(systemctl daemon-reload;service hostapd stop; sleep 2;service hostapd start;sleep 2;service hostapd status|grep fail)
	if [[ -z "$CHECK" ]]; then
		# check various HT modes
		check_ht_capab
		# than go to check 5Ghz
		dialog --title " Info " --backtitle "$BACKTITLE" --no-collapse --colors --infobox "\nProbing wireless 802.11a \Z1(5Ghz)\Z0" 5 36
		sleep 2
		sed '/### IEEE 802.11a\>/,/^### IEEE 802.11a\>/ s/^# *//' -i /etc/hostapd.conf
		CHECK=$(systemctl daemon-reload;service hostapd stop; sleep 2;service hostapd start;sleep 2;service hostapd status|grep fail)
		if [[ -n "$CHECK" ]]; then
			check_channels
		fi
		CHECK=$(systemctl daemon-reload;service hostapd stop; sleep 2;service hostapd start;service hostapd status|grep fail)
		if [[ -z "$CHECK" ]]; then
			dialog --title " Info " --backtitle "$BACKTITLE" --no-collapse --colors \
			--infobox "\nProbing wireless 802.11ac \Z1(433Mbps x n @ 5Ghz)\Z0" 5 51
			sleep 2
			sed '/### IEEE 802.11ac\>/,/^### IEEE 802.11ac\>/ s/^# *//' -i /etc/hostapd.conf
			CHECK=$(systemctl daemon-reload;service hostapd stop; sleep 2;service hostapd start;service hostapd status|grep fail)
			if [[ -n "$CHECK" ]]; then
				dialog --title " Reverting configuration " --backtitle "$BACKTITLE" --no-collapse --colors \
				--infobox "\nWireless 802.11ac \Z1(433Mbps x n @ 5Ghz)\Z0 is not supported!" 5 60
				sed '/## IEEE 802.11ac\>/,/^## IEEE 802.11ac\>/ s/.*/#&/' -i /etc/hostapd.conf
			fi
		else
			dialog --title " Reverting configuration " --backtitle "$BACKTITLE" --no-collapse --colors \
			--infobox "\nWireless 802.11a \Z1(5Ghz)\Z0 is not supported!" 5 45
			sed -i "s/^channel=.*/channel=5/" /etc/hostapd.conf
			sed '/## IEEE 802.11a\>/,/^## IEEE 802.11a\>/ s/.*/#&/' -i /etc/hostapd.conf
		fi
	else
		dialog --title " Reverting configuration " --backtitle "$BACKTITLE" --no-collapse --colors \
		--infobox "\nWireless 802.11n \Z1(150-300Mbps)\Z0 is not supported!" 5 52
		sed '/## IEEE 802.11n/,/^## IEEE 802.11n/ s/.*/#&/' -i /etc/hostapd.conf
	fi
fi
90
91
92
}


Igor Pecovnik's avatar
Igor Pecovnik committed
93
94
#-----------------------------------------------------------------------------------------------------------------------------------------#
#
Igor Pecovnik's avatar
Cleanup    
Igor Pecovnik committed
95
# create interface configuration section
Igor Pecovnik's avatar
Igor Pecovnik committed
96
#
Igor Pecovnik's avatar
Cleanup    
Igor Pecovnik committed
97
function create_if_config() {
Igor Pecovnik's avatar
RC1    
Igor Pecovnik committed
98
99
100
101
102
		address=$(ip -4 addr show dev $1 | awk '/inet/ {print $2}' | cut -d'/' -f1)
		netmask=$(ifconfig $1 | sed -rn '2s/ .*:(.*)$/\1/p')
		gateway=$(route -n | grep 'UG[ \t]' | awk '{print $2}' | sed -n '1p')
		echo -e "# armbian-config created"
		echo -e "source /etc/network/interfaces.d/*\n"
Igor Pecovnik's avatar
Cleanup    
Igor Pecovnik committed
103
		echo -e "allow-hotplug $2\nno-auto-down $2"
Igor Pecovnik's avatar
RC1    
Igor Pecovnik committed
104
		if [[ "$3" != "fixed" ]]; then
Igor Pecovnik's avatar
Cleanup    
Igor Pecovnik committed
105
106
			echo -e "iface $2 inet dhcp"
		else
Igor Pecovnik's avatar
RC1    
Igor Pecovnik committed
107
			echo -e "iface $2 inet static\n\taddress $address\n\tnetmask $netmask\n\tgateway $gateway\n\tdns-nameservers 8.8.8.8"
Igor Pecovnik's avatar
Cleanup    
Igor Pecovnik committed
108
109
		fi
} #
Igor Pecovnik's avatar
Igor Pecovnik committed
110
111
112
113


#-----------------------------------------------------------------------------------------------------------------------------------------#
#
Igor Pecovnik's avatar
Igor Pecovnik committed
114
115
116
117
118
119
120
121
122
123
# reaload network related services. some are "just in case"
#
function reload-nety() {
	systemctl daemon-reload
	if [[ "$1" == "reload" ]]; then WHATODO="Reloading services"; else WHATODO="Stopping services"; fi
	(service network-manager stop; echo 10; sleep 1; service hostapd stop; echo 20; sleep 1; service dnsmasq stop; echo 30; sleep 1;\
	[[ "$1" == "reload" ]] && service dnsmasq start && echo 60 && sleep 1 && service hostapd start && echo 80 && sleep 1;\
	service network-manager start; echo 90; sleep 5;) | dialog --backtitle "$BACKTITLE" --title " $WHATODO " --gauge "" 6 70 0
	systemctl restart systemd-resolved.service
}
Igor Pecovnik's avatar
Igor Pecovnik committed
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143


#-----------------------------------------------------------------------------------------------------------------------------------------#
#
# Check if something is running on port $1 and display info
#
check_port ()
{
[[ -n $(netstat -lnt | awk '$6 == "LISTEN" && $4 ~ ".'$1'"') ]] && dialog --backtitle "$BACKTITLE" --title "Checking service" \
--msgbox "\nIt looks good.\n\nThere is $2 service on port $1" 9 52
}


#-----------------------------------------------------------------------------------------------------------------------------------------#
#
# show disclaimer
#
function beta_disclaimer ()
{
exec 3>&1
Igor Pecovnik's avatar
Igor Pecovnik committed
144
145
ACKNOWLEDGEMENT=$(dialog --nocancel --backtitle "$BACKTITLE" --no-collapse --title " Warning " \
--clear \--radiolist "\n$1.\n \n" 12 56 7 "Yes, I understand" "" off	 2>&1 1>&3)
Igor Pecovnik's avatar
Igor Pecovnik committed
146
147
148
149
exec 3>&-
}


Igor Pecovnik's avatar
Cleanup    
Igor Pecovnik committed
150
151
152
153
154
155
#-----------------------------------------------------------------------------------------------------------------------------------------#
#
# show box
#
function show_box ()
{
156
dialog --colors --backtitle "$BACKTITLE" --no-collapse --title " $1 " --clear --msgbox "\n$2\n \n" $3 56
Igor Pecovnik's avatar
Cleanup    
Igor Pecovnik committed
157
158
159
}


Igor Pecovnik's avatar
Igor Pecovnik committed
160
161
162
163
#-----------------------------------------------------------------------------------------------------------------------------------------#
#
# check wifi high throughput
#
164
165
function check_ht_capab ()
{
Igor Pecovnik's avatar
Igor Pecovnik committed
166
167
declare -a arr=("[HT40+][LDPC][SHORT-GI-20][SHORT-GI-40][TX-STBC][RX-STBC1][DSSS_CCK-40][SMPS-STATIC]" \
"[HT40-][SHORT-GI-40][SHORT-GI-40][DSSS_CCK-40]" "[SHORT-GI-20][SHORT-GI-40][HT40+]")
168
local j=0
169
170
for i in "${arr[@]}"
do
171
	j=$((j+1))
Igor Pecovnik's avatar
Igor Pecovnik committed
172
173
	dialog --title " Info " --backtitle "$BACKTITLE" --no-collapse --colors \
	--infobox "\nProbing high throughput capabilities \Z1(${j})\Z0" 5 46
174
175
176
177
178
179
	sed -i "s/^ht_capab=.*/ht_capab=$i/" /etc/hostapd.conf
	CHECK=$(systemctl daemon-reload;service hostapd stop; sleep 2;service hostapd start;sleep 2;service hostapd status|grep fail)
	if [[ -z "$CHECK" ]]; then break; fi
done
}

Igor Pecovnik's avatar
Igor Pecovnik committed
180
181
182
183
184

#-----------------------------------------------------------------------------------------------------------------------------------------#
#
# check 5Ghz channels
#
185
186
187
188
189
190
191
192
193
194
195
196
function check_channels ()
{
declare -a arr=("36" "40")
for i in "${arr[@]}"
do
	dialog --title " Info " --backtitle "$BACKTITLE" --no-collapse --colors --infobox "\nProbing channels \Z1(${i})\Z0" 5 26
	sed -i "s/^channel=.*/channel=$i/" /etc/hostapd.conf
	CHECK=$(systemctl daemon-reload;service hostapd stop; sleep 2;service hostapd start;sleep 2;service hostapd status|grep fail)
	if [[ -z "$CHECK" ]]; then break; fi
done
}

197

Igor Pecovnik's avatar
Igor Pecovnik committed
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
#-----------------------------------------------------------------------------------------------------------------------------------------#
#
# show description for MOTD files
#
function description
{
	case $1 in
		*header*)
			echo "Big board logo and kernel info"
		;;
		*sysinfo*)
			echo "Sysinfo - load, ip, memory, uptime, ..."
		;;
		*tips*)
			echo "Shows tip of the day"
		;;
		*updates*)
			echo "Display number of avaliable updates"
		;;
		*armbian-config*)
			echo "Show command for system configuration"
		;;
		*autoreboot-warn*)
			echo "Show warning when reboot is needed"
		;;
223
224
225
226
227
228
		*uk.armbian.com*)
			echo "United Kingdom"
		;;
		*.armbian.com*)
			echo "Estonia"
		;;
Igor Pecovnik's avatar
Igor Pecovnik committed
229
230
231
232
233
234
235
		*)
		echo ""
		;;
	esac
}


Igor Pecovnik's avatar
Igor Pecovnik committed
236
237
238
#-----------------------------------------------------------------------------------------------------------------------------------------#
# edit ip address
#
Igor Pecovnik's avatar
RC1    
Igor Pecovnik committed
239
240
241
242
243
244
245
246
247
248
249
function ip_editor ()
{
	exec 3>&1
	dialog --title " Static IP configuration" --backtitle "$BACKTITLE" --form "\nAdapter: $1
	\n " 12 38 0 \
	"Address:"				1 1 "$address"				1 15 15 0 \
	"Netmask:"			2 1 "$netmask"	2 15 15 0 \
	"Gateway:"			3 1 "$gateway"			3 15 15 0 \
	2>&1 1>&3 | {
		read -r address;read -r netmask;read -r gateway
		if [[ $? = 0 ]]; then
Igor Pecovnik's avatar
Igor Pecovnik committed
250
251
252
				echo -e "# armbian-config created\nsource /etc/network/interfaces.d/*\n\nallow-hotplug $2\
				\nno-auto-down $2\niface $2 inet static\
				\n\taddress $address\n\tnetmask $netmask\n\tgateway $gateway\n\tdns-nameservers 8.8.8.8" > $3
Igor Pecovnik's avatar
RC1    
Igor Pecovnik committed
253
254
255
256
257
		fi
		}
}


Igor Pecovnik's avatar
Igor Pecovnik committed
258
259
260
#-----------------------------------------------------------------------------------------------------------------------------------------#
# edit hostapd parameters
#
261
function wlan_edit_basic ()
Igor Pecovnik's avatar
Igor Pecovnik committed
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
{
	source /etc/hostapd.conf
	exec 3>&1
	dialog --title "AP configuration" --backtitle "$BACKTITLE" --form "\nWPA2 enabled, \
	advanced config: edit /etc/hostapd.conf\n " 12 58 0 \
	"SSID:"				1 1 "$ssid"				1 31 22 0 \
	"Password:"			2 1 "$wpa_passphrase"	2 31 22 0 \
	"Channel:"			3 1 "$channel"			3 31 3 0 \
	2>&1 1>&3 | {
		read -r ssid;read -r wpa_passphrase;read -r channel
		if [[ $? = 0 ]]; then
				sed -i "s/^ssid=.*/ssid=$ssid/" /etc/hostapd.conf
				sed -i "s/^wpa_passphrase=.*/wpa_passphrase=$wpa_passphrase/" /etc/hostapd.conf
				sed -i "s/^channel=.*/channel=$channel/" /etc/hostapd.conf
				wpa_psk=$(wpa_passphrase $ssid $wpa_passphrase | grep '^[[:blank:]]*[^[:blank:]#;]' | grep psk | cut -d= -f2-)
				sed -i "s/^wpa_psk=.*/wpa_psk=$wpa_psk/" /etc/hostapd.conf
		fi
		}
}

Igor Pecovnik's avatar
Igor Pecovnik committed
282

283
284
285
286
287
#-----------------------------------------------------------------------------------------------------------------------------------------#
# edit hostapd parameters
#
function wlan_edit ()
{
Igor Pecovnik's avatar
Igor Pecovnik committed
288
289
290
291
292
293
294
295
296
297
298
	# select default interfaces if there is more than one
	select_default_interface
	dialog --title " Configuration edit " --colors --backtitle "$BACKTITLE" --help-button --help-label "Cancel" --yes-label "Basic" \
	--no-label "Advanced" --yesno "\n\Z1Basic:\Z0    Change SSID, password and channel\n\n\Z1Advanced:\Z0 Edit /etc/hostapd.conf file" 9 70
	if [[ $? = 0 ]]; then
		wlan_edit_basic
	elif [[ $? = 1 ]]; then
		dialog --backtitle "$BACKTITLE" --title " Edit hostapd configuration /etc/hostapd.conf" --no-collapse \
		--ok-label "Save" --editbox /etc/hostapd.conf 30 0 2> /etc/hostapd.conf.out
		[[ $? = 0 ]] && mv /etc/hostapd.conf.out /etc/hostapd.conf && service hostapd restart
	fi
299
300
}

Igor Pecovnik's avatar
Igor Pecovnik committed
301
302
303
304
305
306
307
308

#-----------------------------------------------------------------------------------------------------------------------------------------#
# naming exceptions for packages
#
function exceptions ()
{
	TARGET_FAMILY=$LINUXFAMILY
	UBOOT_BRANCH=$TARGET_BRANCH # uboot naming is different
Igor Pecovnik's avatar
Igor Pecovnik committed
309
310
311
312
313
314
315
316

	if [[ $TARGET_BRANCH == "default" ]]; then TARGET_BRANCH=""; else TARGET_BRANCH="-"$TARGET_BRANCH; fi
	if [[ $TARGET_FAMILY == sun*i ]]; then
		TARGET_FAMILY="sunxi"
		if [[ $UBOOT_BRANCH == "default" ]]; then
			TARGET_FAMILY=$(cat /proc/cpuinfo | grep "Hardware" | sed 's/^.*Allwinner //' | awk '{print $1;}')
		fi
	fi
Igor Pecovnik's avatar
Igor Pecovnik committed
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
}


#-----------------------------------------------------------------------------------------------------------------------------------------#
# here we add wifi exceptions
#
function wlan_exceptions ()
{
	[[ -n "$(lsmod | grep -w dhd)" && $1 = "on" ]] && \
	echo 'options dhd op_mode=2' >/etc/modprobe.d/ap6212.conf && rmmod dhd && modprobe dhd
	[[ -n "$(lsmod | grep -w dhd)" && $1 = "off" ]] && \
	rm /etc/modprobe.d/ap6212.conf && rmmod dhd && modprobe dhd
}


#-----------------------------------------------------------------------------------------------------------------------------------------#
# check if board has alternative kernels
#
function aval_kernel ()
{
	IFS=$'\r\n'
	GLOBIGNORE='*'
	AVAL_KERNEL=($(apt-cache search --names-only '^linux-'$(lsb_release	 -cs)'-root.*.'$BOARD'*' \
	| grep -w "$BOARD " | sed 's/.*(\(.*\))/\1/' | awk '{print $1}' | grep -v "$BRANCH" ))
	local LIST=()
	for i in "${AVAL_KERNEL[@]}"
	do
			LIST+=( "${i[0]//[[:blank:]]/}" "" )
	done
	LIST_LENGHT=$((${#LIST[@]}/2));
	if [ "$LIST_LENGHT" -eq 1 ]; then
			TARGET_BRANCH=${AVAL_KERNEL[0]}
	else
			exec 3>&1
351
			TARGET_BRANCH=$(dialog --cancel-label "Back" --backtitle "$BACKTITLE" --no-collapse \
Igor Pecovnik's avatar
Igor Pecovnik committed
352
			--title "Upgrade from $BRANCH to:" --clear --menu "" $((6+${LIST_LENGHT})) 40 15 "${LIST[@]}" 2>&1 1>&3)
353
			exitstatus=$?;
Igor Pecovnik's avatar
Igor Pecovnik committed
354
355
356
357
358
			exec 3>&-
	fi
}


359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
#-----------------------------------------------------------------------------------------------------------------------------------------#
# select video modes for a10 and a20
#
function get_a20modes ()
{
	IFS=$'\r'
	GLOBIGNORE='*'
	SCREEN_RESOLUTION=("1920x1080p60" "1280x720p60" "1920x1080p50" "1280x1024p60" "1024x768p60" "800x600p60" "640x480p60" "1360x768p60" "1440x900p60" "1680x1050p60")
	local LIST=()
	for i in "${SCREEN_RESOLUTION[@]}"
	do
			LIST+=( "${i[0]//[[:blank:]]/}" "" )
	done
	LIST_LENGHT=$((${#LIST[@]}/2));
	#echo $LIST_LENGHT
	#exit
	if [ "$LIST_LENGHT" -eq 1 ]; then
			SCREEN_RESOLUTION=${SCREEN_RESOLUTION[0]}
	else
			exec 3>&1
			SCREEN_RESOLUTION=$(dialog --nocancel --backtitle "$BACKTITLE" --no-collapse \
			--title "Select video mode" --clear --menu "" $((6+${LIST_LENGHT})) 25 $((1+${LIST_LENGHT})) "${LIST[@]}" 2>&1 1>&3)
			exec 3>&-
	fi
}


386
#-----------------------------------------------------------------------------------------------------------------------------------------#
Igor Pecovnik's avatar
Igor Pecovnik committed
387
# select video modes for h3
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
#
function get_h3modes ()
{
	IFS=$'\r\n'
	GLOBIGNORE='*'
	SCREEN_RESOLUTION=($(h3disp -i))
	local LIST=()
	for i in "${SCREEN_RESOLUTION[@]}"
	do
			LIST+=( "${i[0]//[[:blank:]]/}" "" )
	done
	LIST_LENGHT=$((${#LIST[@]}/2));
	#echo $LIST_LENGHT
	#exit
	if [ "$LIST_LENGHT" -eq 1 ]; then
			SCREEN_RESOLUTION=${SCREEN_RESOLUTION[0]}
	else
			exec 3>&1
			SCREEN_RESOLUTION=$(dialog --nocancel --backtitle "$BACKTITLE" --no-collapse \
			--title "Select video mode" --clear --menu "" $((6+${LIST_LENGHT})) 25 $((1+${LIST_LENGHT})) "${LIST[@]}" 2>&1 1>&3)
			exec 3>&-
	fi
}


Igor Pecovnik's avatar
Igor Pecovnik committed
413
414
415
416
417
418
419
#-----------------------------------------------------------------------------------------------------------------------------------------#
# search for wlan interfaces and provide a selection menu if there are more than one
#
function get_wlan_interface ()
{
	IFS=$'\r\n'
	GLOBIGNORE='*'
Igor Pecovnik's avatar
Igor Pecovnik committed
420
	WLAN_INTERFACES=($(nmcli dev status | grep wifi | grep disconnected |awk '{print $1}'))
421

Igor Pecovnik's avatar
Igor Pecovnik committed
422
423
424
425
426
427
	local LIST=()
	for i in "${WLAN_INTERFACES[@]}"
	do
			LIST+=( "${i[0]//[[:blank:]]/}" "" )
	done
	LIST_LENGHT=$((${#LIST[@]}/2));
428

Igor Pecovnik's avatar
Igor Pecovnik committed
429
430
431
432
433
434
435
436
437
438
439
	if [ "$LIST_LENGHT" -eq 1 ]; then
			WIRELESS_ADAPTER=${WLAN_INTERFACES[0]}
	else
			exec 3>&1
			WIRELESS_ADAPTER=$(dialog --nocancel --backtitle "$BACKTITLE" --no-collapse \
			--title "Select interface" --clear --menu "" $((6+${LIST_LENGHT})) 30 15 "${LIST[@]}" 2>&1 1>&3)
			exec 3>&-
	fi
}


Igor Pecovnik's avatar
Igor Pecovnik committed
440
441
442
443
444
445
446
447
448
449
450
451
452
453
#-----------------------------------------------------------------------------------------------------------------------------------------#
# select interface if there is more than one
#
function select_default_interface ()
{
	IFS=$'\r\n'
	GLOBIGNORE='*'
	local ADAPTER=($(ip -4 route ls | grep default | grep -Po '(?<=dev )(\S+)'))
	local LIST=()
	for i in "${ADAPTER[@]}"
	do
			LIST+=( "${i[0]//[[:blank:]]/}" "" )
	done
	LIST_LENGHT=$((${#LIST[@]}/2));
454
455
456
	if [ "$LIST_LENGHT" -eq 0 ]; then
			DEFAULT_ADAPTER="lo"
	elif [ "$LIST_LENGHT" -eq 1 ]; then
Igor Pecovnik's avatar
Igor Pecovnik committed
457
458
459
460
461
462
463
464
465
466
			DEFAULT_ADAPTER=${ADAPTER[0]}
	else
			exec 3>&1
			DEFAULT_ADAPTER=$(dialog --nocancel --backtitle "$BACKTITLE" --no-collapse \
			--title "Select default interface" --clear --menu "" $((6+${LIST_LENGHT})) 30 15 "${LIST[@]}" 2>&1 1>&3)
			exec 3>&-
	fi
}


Igor Pecovnik's avatar
Igor Pecovnik committed
467
#-----------------------------------------------------------------------------------------------------------------------------------------#
Igor Pecovnik's avatar
Igor Pecovnik committed
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
# search for BT devices and connect
#
function connect_bt_interface ()
{
		IFS=$'\r\n'
		GLOBIGNORE='*'
		dialog --backtitle "$BACKTITLE" --title "Please wait" --infobox "\nDiscovering Bluetooth devices ... " 5 37
		BT_INTERFACES=($(hcitool scan | sed '1d'))

		local LIST=()
		for i in "${BT_INTERFACES[@]}"
		do
			local a=$(echo ${i[0]//[[:blank:]]/} | sed -e 's/^\(.\{17\}\).*/\1/')
			local b=${i[0]//$a/}
			local b=$(echo $b | sed -e 's/^[ \t]*//')
			LIST+=( "$a" "$b")
		done

		LIST_LENGHT=$((${#LIST[@]}/2));
		if [ "$LIST_LENGHT" -eq 0 ]; then
			BT_ADAPTER=${WLAN_INTERFACES[0]}
			dialog --backtitle "$BACKTITLE" --title "Bluetooth" --msgbox "\nNo nearby Bluetooth devices were found!" 7 43
		else
			exec 3>&1
			BT_ADAPTER=$(dialog --backtitle "$BACKTITLE" --no-collapse --title "Select interface" \
			--clear --menu "" $((6+${LIST_LENGHT})) 50 15 "${LIST[@]}" 2>&1 1>&3)
			exec 3>&-
			if [[ $BT_ADAPTER != "" ]]; then
				dialog --backtitle "$BACKTITLE" --title "Please wait" --infobox "\nConnecting to $BT_ADAPTER " 5 35
Igor Pecovnik's avatar
Igor Pecovnik committed
497
498
499
500
501
				BT_EXEC=$(
				expect -c 'set prompt "#";set address '$BT_ADAPTER';spawn bluetoothctl;expect -re $prompt;send "disconnect $address\r";
				sleep 1;send "remove $address\r";sleep 1;expect -re $prompt;send "scan on\r";sleep 8;send "scan off\r";
				expect "Controller";send "trust $address\r";sleep 2;send "pair $address\r";sleep 2;send "connect $address\r";
				send_user "\nShould be paired now.\r";sleep 2;send "quit\r";expect eof')
Igor Pecovnik's avatar
Igor Pecovnik committed
502
503
504
505
506
507
508
509
510
511
				echo "$BT_EXEC" > /tmp/bt-connect-debug.log
					if [[ $(echo "$BT_EXEC" | grep "Connection successful" ) != "" ]]; then
						dialog --backtitle "$BACKTITLE" --title "Bluetooth" --msgbox "\nYour device is ready to use!" 7 32
					else
						dialog --backtitle "$BACKTITLE" --title "Bluetooth" --msgbox "\nError connecting. Try again!" 7 32
					fi
			fi
		fi
}

Igor Pecovnik's avatar
Igor Pecovnik committed
512

Igor Pecovnik's avatar
Igor Pecovnik committed
513
#-----------------------------------------------------------------------------------------------------------------------------------------#
Igor Pecovnik's avatar
Igor Pecovnik committed
514
# system
Igor Pecovnik's avatar
Igor Pecovnik committed
515
#
Igor Pecovnik's avatar
Igor Pecovnik committed
516
function submenu_settings ()
Igor Pecovnik's avatar
Igor Pecovnik committed
517
518
519
520
521
{
while true; do

	LIST=()

Igor Pecovnik's avatar
Igor Pecovnik committed
522
523
524
	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" )
	LIST+=( "Hostname" "Change your hostname \Z5($(cat /etc/hostname))\Z0" )
Igor Pecovnik's avatar
Igor Pecovnik committed
525
	LIST+=( "SSH" "Reconfigure SSH daemon" )
Igor Pecovnik's avatar
Igor Pecovnik committed
526
	LIST+=( "Firmware" "Upgrade board firmware" )
Igor Pecovnik's avatar
Igor Pecovnik committed
527

Igor Pecovnik's avatar
Igor Pecovnik committed
528
529
530
531
532
533
534
535
536
537
538
539
540
	# detect desktop
	DISPLAY_MANAGER=""; DESKTOP_INSTALLED=""
	if [ $(dpkg-query -W -f='${db:Status-Abbrev}\n' nodm 2>/dev/null) <> "*ii*" ]; then DESKTOP_INSTALLED="nodm"; fi
	if [ $(dpkg-query -W -f='${db:Status-Abbrev}\n' lightdm 2>/dev/null) <> "*ii*" ]; then DESKTOP_INSTALLED="lightdm"; fi
	[[ -n $(service lightdm status 2> /dev/null | grep -w active) ]] && DISPLAY_MANAGER="lightdm"
	[[ -n $(service nodm status 2> /dev/null | grep -w active) ]] && DISPLAY_MANAGER="nodm"

	if [[ -n $DISPLAY_MANAGER ]]; then
			LIST+=( "Desktop" "Disable desktop" )
			[[ $DISPLAY_MANAGER == 'nodm' ]] && 			LIST+=( "Lightdm" "Switch to standard login manager" )
			[[ $DISPLAY_MANAGER == 'lightdm' ]] && 			LIST+=( "Nodm" "Switch to simple auto login manager" )
		elif [[ -n $DESKTOP_INSTALLED ]]; then
			LIST+=( "Desktop" "Enable desktop" )
Igor Pecovnik's avatar
Igor Pecovnik committed
541
542
	fi

Igor Pecovnik's avatar
Igor Pecovnik committed
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
	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
	fi
	LIST+=( "Services" "Toggle running services" )
	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
562
563

	exec 3>&1
Igor Pecovnik's avatar
Igor Pecovnik committed
564
	selection=$(dialog --colors --backtitle "$BACKTITLE" --title " System settings " --clear \
Igor Pecovnik's avatar
Igor Pecovnik committed
565
566
567
568
569
	--cancel-label "Back" --menu "$disclaimer" $LISTLENGHT 70 $BOXLENGHT \
	"${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
570
571

	# run main function
Igor Pecovnik's avatar
Igor Pecovnik committed
572
573
574
575
	jobs "$selection"
done
}

Igor Pecovnik's avatar
Igor Pecovnik committed
576

Igor Pecovnik's avatar
Igor Pecovnik committed
577
578
579
580
581
#-----------------------------------------------------------------------------------------------------------------------------------------#
# menu for networking
#
function submenu_networking ()
{
Igor Pecovnik's avatar
Igor Pecovnik committed
582
583

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

Igor Pecovnik's avatar
Igor Pecovnik committed
586
while true; do
Igor Pecovnik's avatar
Igor Pecovnik committed
587

Igor Pecovnik's avatar
Igor Pecovnik committed
588
	LIST=()
Igor Pecovnik's avatar
Igor Pecovnik committed
589

Igor Pecovnik's avatar
RC1    
Igor Pecovnik committed
590
	LIST+=( "IP" "Select dynamic or edit static IP address" )
Igor Pecovnik's avatar
Igor Pecovnik committed
591
592
593
594
595
596
	HOSTAPDBRIDGE=$(cat /etc/hostapd.conf 2> /dev/null | grep -w "^bridge=br0")
	HOSTAPDSTATUS=$(service hostapd status | grep -w active | grep -w running)
	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
597
		else
Igor Pecovnik's avatar
Igor Pecovnik committed
598
			[[ -n $(nmcli device status | grep wifi | grep -w disconnected) ]] && LIST+=( "Hotspot" "Create WiFi access point" )
Igor Pecovnik's avatar
Cleanup    
Igor Pecovnik committed
599

Igor Pecovnik's avatar
Igor Pecovnik committed
600
	fi
601

602
603
604
605
606
607
608
609
	if pgrep -x "iperf3" > /dev/null
	then
		LIST+=( "Iperf3" "Disable network throughput tests daemon" )
		else
		LIST+=( "Iperf3" "Enable network throughput tests daemon" )
	fi


610
611
612
613
614
	if [[ -n $(nmcli device status | grep wifi | grep -v unavailable | grep -v unmanaged) ]]; then
		LIST+=( "WiFi" "Manage wireless networking" )
	else
		LIST+=( "Clear" "Clear possible blocked interfaces" )
	fi
Igor Pecovnik's avatar
Cleanup    
Igor Pecovnik committed
615

Igor Pecovnik's avatar
Igor Pecovnik committed
616
	if [[ -n $(service bluetooth status | grep -w active | grep -w running) ]]; then
617
		[[ $(hcitool dev | sed '1d') != "" ]] && LIST+=( "Discover" "Discover and connect Bluetooth devices" )
Igor Pecovnik's avatar
Igor Pecovnik committed
618
619
	fi

620
621
	[[ -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
622
	LIST+=( "Advanced" "Edit /etc/network/interfaces" )
Igor Pecovnik's avatar
Igor Pecovnik committed
623
624
	[[ $(ls -1 /etc/NetworkManager/system-connections 2> /dev/null) ]] && \
	LIST+=( "Forget" "Disconnect and forget all wireless connections" )
Igor Pecovnik's avatar
Igor Pecovnik committed
625
626

	# count number of menu items to adjust window sizee
627
	LISTLENGHT="$((12+${#LIST[@]}/2))"
Igor Pecovnik's avatar
Igor Pecovnik committed
628
	BOXLENGHT=${#LIST[@]}
Igor Pecovnik's avatar
Igor Pecovnik committed
629
	WIFICONNECTED=$(nmcli -f NAME,TYPE connection show --active | grep wireless | awk 'NF{NF-=1};1')
Igor Pecovnik's avatar
Igor Pecovnik committed
630

Igor Pecovnik's avatar
Cleanup    
Igor Pecovnik committed
631
	local disclaimer=""
632
633
634

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

635
636
	if [[ -n $(nmcli device status | grep wlan0 | grep connected) ]]; then
		local ifup="\nIP ($DEFAULT_ADAPTER) via Network Manager: \Z1${ipadd}\n\Z0 "
637
	else
638
		local ifup="\nIP ($DEFAULT_ADAPTER) via IFUPDOWN: \Z1${ipadd}\n\Z0 "
639
	fi
640

641
642
	disclaimer="$ifup"

Igor Pecovnik's avatar
Igor Pecovnik committed
643
	if [[ -n $WIFICONNECTED ]]; then
Igor Pecovnik's avatar
Cleanup    
Igor Pecovnik committed
644
		LISTLENGHT=$((LISTLENGHT+2))
645
646
		local connected="\n\Z0Connected to SSID: \Z1${WIFICONNECTED}\n\Z0 "
		disclaimer=$disclaimer"$connected"
Igor Pecovnik's avatar
Cleanup    
Igor Pecovnik committed
647
648
	fi

649
650
651
652
653
654
	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
655
	if [[ -n $HOSTAPDINFO && -n $HOSTAPDSTATUS ]]; then
Igor Pecovnik's avatar
Cleanup    
Igor Pecovnik committed
656
		LISTLENGHT=$((LISTLENGHT+2))
Igor Pecovnik's avatar
Igor Pecovnik committed
657
		chpid=$(dmesg | grep $(grep ^interface /etc/hostapd.conf | sed 's/interface=//g') | head -1 | sed 's/\[.*\]//g' | awk '{print $1}')
658
		disclaimer=$disclaimer$"\n\Z0Hotspot SSID: \Z1$HOSTAPDINFO\Zn Band:";
659
		if [[ `grep ^hw_mode=a /etc/hostapd.conf` ]]; then local band="5Ghz"; else band="2.4Ghz"; fi
660
661
		if [[ `grep ^ieee80211n /etc/hostapd.conf` ]]; then local type="N"; fi
		if [[ `grep ^ieee80211ac /etc/hostapd.conf` ]]; then local type="AC"; fi
662
		disclaimer=$disclaimer$" \Z1${band} ${type}\Z0"
Igor Pecovnik's avatar
Igor Pecovnik committed
663
		if [ -n $chpid ]; then disclaimer=$disclaimer$"\n\nChip: \Z1${chpid}\Z0"; fi
Igor Pecovnik's avatar
Igor Pecovnik committed
664
		if [ "$HOSTAPDCLIENTS" -gt "0" ]; then disclaimer=$disclaimer$" Connected clients: \Z1$HOSTAPDCLIENTS\Zn"; fi
665
		if [ -n $chip ] || [ "$HOSTAPDCLIENTS" -gt "0" ]; then LISTLENGHT=$((LISTLENGHT+2)); fi
Igor Pecovnik's avatar
Igor Pecovnik committed
666
		disclaimer=$disclaimer$"\n";
Igor Pecovnik's avatar
Igor Pecovnik committed
667
	fi
668
	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
669
670

	exec 3>&1
671
	selection=$(dialog --backtitle "$BACKTITLE" --colors --title " Wired, Wireless, Bluetooth, Hotspot " --clear \
Igor Pecovnik's avatar
Igor Pecovnik committed
672
	--cancel-label "Back" --menu "${disclaimer}" $LISTLENGHT 70 $BOXLENGHT \
Igor Pecovnik's avatar
Igor Pecovnik committed
673
674
675
676
677
	"${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
678
	# run main function
Igor Pecovnik's avatar
Igor Pecovnik committed
679
680
681
682
	jobs "$selection"
done
}

683

Igor Pecovnik's avatar
Igor Pecovnik committed
684
#-----------------------------------------------------------------------------------------------------------------------------------------#
Igor Pecovnik's avatar
Igor Pecovnik committed
685
# armbian
Igor Pecovnik's avatar
Igor Pecovnik committed
686
687
688
689
690
691
#
function submenu_hardware ()
{
while true; do

	LIST=()
692
693
694

	[[ $(sed -n 's/^DEVNAME=//p' /sys/dev/block/$(mountpoint -d /)/uevent 2> /dev/null) == mmcblk* && -f /usr/sbin/nand-sata-install ]] \
	&& LIST+=( "Install" "Install to SATA, eMMC, NAND or USB" )
Igor Pecovnik's avatar
Igor Pecovnik committed
695
	if [[ -n $(apt-mark showhold | grep -w "$BOARD") ]]; then
Igor Pecovnik's avatar
Igor Pecovnik committed
696
			LIST+=( "Defreeze" "Defreeze firmware upgrade" )
Igor Pecovnik's avatar
Igor Pecovnik committed
697
		else
Igor Pecovnik's avatar
Igor Pecovnik committed
698
			LIST+=( "Freeze" "Freeze firmware upgrade" )
Igor Pecovnik's avatar
Igor Pecovnik committed
699
	fi
Igor Pecovnik's avatar
Igor Pecovnik committed
700
701
702
	[[ -n $(grep -w "#kernel.printk" /etc/sysctl.conf ) ]] && LIST+=( "Lowlevel" "Stop low-level messages on console" )
	[[ -f /boot/armbianEnv.txt ]] && LIST+=( "Bootenv" "Edit boot environment" )
	[[ -f /boot/boot.ini ]] && LIST+=( "Bootscript" "Edit boot script" )
703
	[[ -f /etc/apt/sources.list.d/armbian.list ]] && LIST+=( "Mirror" "Change repository server" )
Igor Pecovnik's avatar
Igor Pecovnik committed
704
705
706
707
708
709
710
	LIST+=( "Welcome" "Toggle welcome screen items" )
	if [[ -z $(apt-mark showhold | grep -w "$BOARD") ]]; then
	[[ -f /etc/apt/sources.list.d/armbian.list ]] && [[ -n $(grep -w apt /etc/apt/sources.list.d/armbian.list) ]] \
		&& LIST+=( "Nightly" "Switch to nightly builds" )
	[[ -f /etc/apt/sources.list.d/armbian.list ]] && [[ -n $(grep -w beta /etc/apt/sources.list.d/armbian.list) ]] \
		&& LIST+=( "Stable" "Switch to stable builds" )
	fi
711
712
	[[ -d /boot/dtb/overlay && $LINUXFAMILY == sun*i && $BRANCH != default ]] && \
	LIST+=( "Overlays" "Toggle board functions: UART, I2C, SPI, ..." )
Igor Pecovnik's avatar
Igor Pecovnik committed
713
714
715
716
	[[ $(apt-cache search --names-only '^linux-'$(lsb_release  -cs)'-root.*.'$BOARD'' | sed 's/.*(\(.*\))/\1/' | awk '{print $1}' \
	| wc -l) -gt 1 ]] && LIST+=( "Switch" "Switch to alternative kernels" )

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

	exec 3>&1
Igor Pecovnik's avatar
Igor Pecovnik committed
721
	selection=$(dialog --backtitle "$BACKTITLE" --title " Armbian specific settings " --clear \
Igor Pecovnik's avatar
Igor Pecovnik committed
722
723
724
725
726
	--cancel-label "Back" --menu "$disclaimer" $LISTLENGHT 70 $BOXLENGHT \
	"${LIST[@]}" 2>&1 1>&3)
	exit_status=$?
	exec 3>&-
	[[ $exit_status == $DIALOG_CANCEL || $exit_status == $DIALOG_ESC ]] && clear && break
727
728

	# run main function
Igor Pecovnik's avatar
Igor Pecovnik committed
729
	jobs "$selection"
730

Igor Pecovnik's avatar
Igor Pecovnik committed
731
done
Igor Pecovnik's avatar
Igor Pecovnik committed
732
733
734
735
736
737
738
739
740
741
742
743
744
745
}


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

	LIST=()
	[[ -f /usr/bin/softy ]] && LIST+=( "Softy" "3rd party applications installer" )
	[[ -f /usr/bin/h3consumption && "$LINUXFAMILY" = "sun8i" && "$BRANCH" = "default" ]] && \
	LIST+=( "Consumption" "Control board consumption" )
746
747
748
749
750


	check_if_installed bluetooth && LIST+=( "Remove BT" "Remove Bluetooth support" ) || LIST+=( "Bluetooth" "Install Bluetooth support" )
	check_if_installed lirc && LIST+=( "Remove IR" "Remove IR support" ) || LIST+=( "IR" "Install IR support" )

Igor Pecovnik's avatar
Igor Pecovnik committed
751
752
753
754
755
	[[ -f /usr/bin/armbianmonitor ]] && LIST+=( "Monitor" "Simple CLI board monitoring" )
	[[ -f /usr/bin/armbianmonitor ]] && LIST+=( "Diagnostics" "Send diagnostics" )
	[[ -f /usr/bin/bin2fex && "$LINUXFAMILY" = sun*i && "$BRANCH" = "default" ]] && LIST+=( "Fexedit" "Board (fex) settings editor" )
	if [[ -n $(dpkg -l | grep linux-headers) ]]; then LIST+=( "Headers" "Remove kernel headers" ); else \
	LIST+=( "Headers" "Install kernel headers" ); fi
756
	[[ "$LINUXFAMILY" = sun*i && "$BRANCH" = "default" && \
Igor Pecovnik's avatar
Igor Pecovnik committed
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
	-n $(bin2fex </boot/script.bin 2>/dev/null | grep -w "hdmi_used = 1") ]] && LIST+=( "Display" "set the display resolution" )

	# 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 \
	--cancel-label "Back" --menu "$disclaimer" $LISTLENGHT 70 $BOXLENGHT \
	"${LIST[@]}" 2>&1 1>&3)
	exit_status=$?
	exec 3>&-
	[[ $exit_status == $DIALOG_CANCEL || $exit_status == $DIALOG_ESC ]] && clear && break

	# run main function
	jobs "$selection"
done
774
}