debian-config 3.32 KB
Newer Older
Igor Pecovnik's avatar
RFC #2    
Igor Pecovnik committed
1
2
3
4
5
6
7
8
#!/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.

ThomasKaiser's avatar
ThomasKaiser committed
9
10
# define sane $PATH
export PATH=/usr/sbin:/usr/bin:/sbin:/bin
Igor Pecovnik's avatar
Igor Pecovnik committed
11

12
13
14
15
#-----------------------------------------------------------------------------------------------------------------------------------------#
# check for root
#
if [[ $EUID != 0 ]]; then
ThomasKaiser's avatar
ThomasKaiser committed
16
	echo "This tool requires root privileges. Try again with \"sudo \" please ..." >&2
17
	sleep 2
ThomasKaiser's avatar
ThomasKaiser committed
18
	exit 1
19
20
21
22
23
24
fi


#-----------------------------------------------------------------------------------------------------------------------------------------#
# check if we have internet connection to install dependencies
#
25
echo -e "GET http://github.com HTTP/1.0\n\n" | nc github.com 80 > /dev/null 2>&1
26
27
28
29
30
31
32
if [[ $? -ne 0 ]]; then
		read -n 1 -s -p "Warning. Configurator can't work properly without internet connection. \
		Press CTRL C to stop to stop or any key to ignore and continue."
fi


#-----------------------------------------------------------------------------------------------------------------------------------------#
Igor Pecovnik's avatar
Igor Pecovnik committed
33
34
35
# load functions
source "$0""-submenu"
source "$0""-jobs"
36

37
38


39
#-----------------------------------------------------------------------------------------------------------------------------------------#
Igor Pecovnik's avatar
Igor Pecovnik committed
40
# Main menu
41
#
Igor Pecovnik's avatar
Cleanup    
Igor Pecovnik committed
42
43
while true
do
Igor Pecovnik's avatar
Igor Pecovnik committed
44
	LIST=()
45

46
47
48
	LIST+=( "System" "System and security settings" )
	LIST+=( "Network" "Wired, wireless, Bluetooth, access point" )
	LIST+=( "Personal" "Timezone, language, hostname" )
Igor Pecovnik's avatar
Cleanup    
Igor Pecovnik committed
49
50
	LIST+=( "Software" "System and 3rd party software install" )
	LIST+=( "Help" "Documentation, support, sources" )
51

52
53
	# count number of menu items to adjust window size
	LISTLENGHT="$((11+${#LIST[@]}/2))"
Igor Pecovnik's avatar
Igor Pecovnik committed
54
	BOXLENGHT=${#LIST[@]}
55
56
	MENUTITLE="Configure $DISTRO $DISTROID based \Z1Armbian\Z0 "
	[[ -n "${BOARD_NAME/ /}" ]] && MENUTITLE=$MENUTITLE"for the \Z1${BOARD_NAME}\Z0 "
Igor Pecovnik's avatar
RFC #2    
Igor Pecovnik committed
57

Igor Pecovnik's avatar
Igor Pecovnik committed
58
59
60
	# main dialog routine
	DIALOG_CANCEL=1
	DIALOG_ESC=255
Igor Pecovnik's avatar
Igor Pecovnik committed
61
62
	TITLELENGHT=${#MENUTITLE}

63
	[[ "$TITLELENGHT" -lt 50 ]] && TITLELENGHT="50"
64

Igor Pecovnik's avatar
RFC #2    
Igor Pecovnik committed
65
	exec 3>&1
66
	selection=$(dialog --colors --backtitle "$BACKTITLE" --title " armbian-config " --clear \
Igor Pecovnik's avatar
Igor Pecovnik committed
67
	--cancel-label "Cancel" --menu "\n$MENUTITLE \n \nSupport: \Z1https://www.armbian.com\Z0\n " \
Igor Pecovnik's avatar
Igor Pecovnik committed
68
	$LISTLENGHT ${TITLELENGHT} $BOXLENGHT "${LIST[@]}" 2>&1 1>&3)
Igor Pecovnik's avatar
RFC #2    
Igor Pecovnik committed
69
70
	exit_status=$?
	exec 3>&-
71

Igor Pecovnik's avatar
Igor Pecovnik committed
72
	[[ $exit_status == $DIALOG_CANCEL || $exit_status == $DIALOG_ESC ]] && clear && exit
Igor Pecovnik's avatar
Igor Pecovnik committed
73

Igor Pecovnik's avatar
Igor Pecovnik committed
74
	dialog --backtitle "$BACKTITLE" --title "Please wait" --infobox "\nLoading ${selection,,} submodule ... " 5 $((26+${#selection}))
75

Igor Pecovnik's avatar
RFC #2    
Igor Pecovnik committed
76
77
	case $selection in

78
79
		"System" )
			submenu_settings
80
		;;
81
82

		"Network" )
83
84
			submenu_networking
		;;
85
86
87

		"Personal" )
			submenu_personal
88
		;;
89
90
91

		"Software" )
			submenu_software
92
		;;
93

94
		"Help" )
Igor Pecovnik's avatar
Igor Pecovnik committed
95
			show_box "Info" "This tool provides a straightforward way of configuring the \Z4${BOARD_NAME}\Z0. \
96
			\n \nAlthough it can be run at any time, some of the options may have difficulties if you alter system settings manually.\n\
Igor Pecovnik's avatar
Igor Pecovnik committed
97
98
			\n\Z1Documentation:\Z0     https://docs.armbian.com\n\n\Z1Support:\Z0           https://forum.armbian.com\n
			\n\Z1Sources:\Z0           https://git.armbian.com" "18"
99
		;;
Igor Pecovnik's avatar
Cleanup    
Igor Pecovnik committed
100
	esac
101
done
102
#-----------------------------------------------------------------------------------------------------------------------------------------#