debian-config 3.42 KB
Newer Older
Igor Pecovnik's avatar
RFC #2    
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
RFC #2    
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.

Igor Pecovnik's avatar
Igor Pecovnik committed
9
10
11



ThomasKaiser's avatar
ThomasKaiser committed
12
13
# define sane $PATH
export PATH=/usr/sbin:/usr/bin:/sbin:/bin
Igor Pecovnik's avatar
Igor Pecovnik committed
14

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



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


Igor Pecovnik's avatar
Igor Pecovnik committed
28
29
30


#
31
32
# check if we have internet connection to install dependencies
#
33
echo -e "GET http://github.com HTTP/1.0\n\n" | nc github.com 80 > /dev/null 2>&1
34
35
36
37
38
39
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


40

Igor Pecovnik's avatar
Igor Pecovnik committed
41
42
43
44

#
# load functions, local first
#
45
46
47
48
49
50
51
52
53
if  [[ -f ${BASH_SOURCE}-jobs ]]; then source ${BASH_SOURCE}-jobs;
	elif  [[ -f /usr/lib/armbian-config/jobs.sh ]]; then source /usr/lib/armbian-config/jobs.sh;
	else exit 1;
fi

if  [[ -f ${BASH_SOURCE}-submenu ]]; then source ${BASH_SOURCE}-submenu;
	elif  [[ -f /usr/lib/armbian-config/submenu.sh ]]; then source /usr/lib/armbian-config/submenu.sh;
	else exit 1;
fi
54

55
56
57
58
59
60
61
62
63
64
if  [[ -f ${BASH_SOURCE}-functions ]]; then source ${BASH_SOURCE}-functions;
	elif  [[ -f /usr/lib/armbian-config/functions.sh ]]; then source /usr/lib/armbian-config/functions.sh;
	else exit 1;
fi

if  [[ -f ${BASH_SOURCE}-functions-network ]]; then source ${BASH_SOURCE}-functions-network;
	elif  [[ -f /usr/lib/armbian-config/functions-network.sh ]]; then source /usr/lib/armbian-config/functions-network.sh;
	else exit 1;
fi

Igor Pecovnik's avatar
Igor Pecovnik committed
65
66
67



68
69
# collect info
main "$@"
70
71


Igor Pecovnik's avatar
Igor Pecovnik committed
72
73
74


#
Igor Pecovnik's avatar
Igor Pecovnik committed
75
# Main menu
76
#
Igor Pecovnik's avatar
Cleanup    
Igor Pecovnik committed
77
78
while true
do
Igor Pecovnik's avatar
Igor Pecovnik committed
79
	LIST=()
80

81
82
83
	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
84
85
	LIST+=( "Software" "System and 3rd party software install" )
	LIST+=( "Help" "Documentation, support, sources" )
86

87
88
	# count number of menu items to adjust window size
	LISTLENGHT="$((11+${#LIST[@]}/2))"
Igor Pecovnik's avatar
Igor Pecovnik committed
89
	BOXLENGHT=${#LIST[@]}
90
91
	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
92

Igor Pecovnik's avatar
Igor Pecovnik committed
93
94
95
	# main dialog routine
	DIALOG_CANCEL=1
	DIALOG_ESC=255
Igor Pecovnik's avatar
Igor Pecovnik committed
96
97
	TITLELENGHT=${#MENUTITLE}

98
	[[ "$TITLELENGHT" -lt 60 ]] && TITLELENGHT="60"
99

Igor Pecovnik's avatar
RFC #2    
Igor Pecovnik committed
100
	exec 3>&1
101
	selection=$(dialog --colors --backtitle "$BACKTITLE" --title " armbian-config " --clear \
Igor Pecovnik's avatar
Igor Pecovnik committed
102
	--cancel-label "Cancel" --menu "\n$MENUTITLE \n \nSupport: \Z1https://www.armbian.com\Z0\n " \
Igor Pecovnik's avatar
Igor Pecovnik committed
103
	$LISTLENGHT ${TITLELENGHT} $BOXLENGHT "${LIST[@]}" 2>&1 1>&3)
Igor Pecovnik's avatar
RFC #2    
Igor Pecovnik committed
104
105
	exit_status=$?
	exec 3>&-
106

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

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

Igor Pecovnik's avatar
RFC #2    
Igor Pecovnik committed
111
112
	case $selection in

113
114
		"System" )
			submenu_settings
115
		;;
116
117

		"Network" )
118
119
			submenu_networking
		;;
120
121
122

		"Personal" )
			submenu_personal
123
		;;
124
125
126

		"Software" )
			submenu_software
127
		;;
128

129
		"Help" )
Igor Pecovnik's avatar
Igor Pecovnik committed
130
			show_box "Info" "This tool provides a straightforward way of configuring. \
131
			\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
132
133
			\n\Z1Documentation:\Z0     https://docs.armbian.com\n\n\Z1Support:\Z0           https://forum.armbian.com\n
			\n\Z1Sources:\Z0           https://git.armbian.com" "18"
134
		;;
Igor Pecovnik's avatar
Cleanup    
Igor Pecovnik committed
135
	esac
Igor Pecovnik's avatar
Igor Pecovnik committed
136
done