debian-config 4.19 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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
fi


#-----------------------------------------------------------------------------------------------------------------------------------------#
# check if we have internet connection to install dependencies
#
echo -e "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 > /dev/null 2>&1
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."
	else
		[[ $(dpkg-query -W -f='${db:Status-Abbrev}\n' bc 2>/dev/null) != *ii* ]] && \
		apt-get -qq -y --no-install-recommends install bc
		[[ $(dpkg-query -W -f='${db:Status-Abbrev}\n' expect 2>/dev/null) != *ii* ]] && \
		apt-get -qq -y --no-install-recommends install expect
		[[ $(dpkg-query -W -f='${db:Status-Abbrev}\n' rcconf 2>/dev/null) != *ii* ]] && \
		apt-get -qq -y --no-install-recommends install rcconf
		[[ $(dpkg-query -W -f='${db:Status-Abbrev}\n' dialog 2>/dev/null) != *ii* ]] && \
		apt-get -qq -y --no-install-recommends install dialog
		[[ $(dpkg-query -W -f='${db:Status-Abbrev}\n' network-manager 2>/dev/null) != *ii* ]] && \
		apt-get -qq -y --no-install-recommends install network-manager
		[[ $(dpkg-query -W -f='${db:Status-Abbrev}\n' sunxi-tools 2>/dev/null) != *ii* ]] && \
		apt-get -qq -y --no-install-recommends install sunxi-tools
Igor Pecovnik's avatar
Igor Pecovnik committed
42
43
		[[ $(dpkg-query -W -f='${db:Status-Abbrev}\n' iptables 2>/dev/null) != *ii* ]] && \
		apt-get -qq -y --no-install-recommends install iptables
44
45
46
47
fi


#-----------------------------------------------------------------------------------------------------------------------------------------#
Igor Pecovnik's avatar
Igor Pecovnik committed
48
49
50
# load functions
source "$0""-submenu"
source "$0""-jobs"
51

52
53

#-----------------------------------------------------------------------------------------------------------------------------------------#
Igor Pecovnik's avatar
Igor Pecovnik committed
54
# Main menu
55
#
Igor Pecovnik's avatar
Igor Pecovnik committed
56
while true; do
57
58


Igor Pecovnik's avatar
Igor Pecovnik committed
59
	LIST=()
60

61
		LIST+=( "System" "General system settings" )
Igor Pecovnik's avatar
Igor Pecovnik committed
62
		LIST+=( "Networking" "Wired, Wireless, Bluetooth, Access point" )
63
		LIST+=( "Armbian" "Armbian specific: overlays, MOTD, loglevel" )
Igor Pecovnik's avatar
Igor Pecovnik committed
64
		LIST+=( "Software" "System and 3rd party software install" )
65
		LIST+=( "Help" "Documentation, support, sources" )
66

67
68
	# count number of menu items to adjust window size
	LISTLENGHT="$((11+${#LIST[@]}/2))"
Igor Pecovnik's avatar
Igor Pecovnik committed
69
	BOXLENGHT=${#LIST[@]}
70
	MENUTITLE="Configuration tool for the \Z1${BOARD_NAME}\Z0 running \Z1$DISTRO $DISTROID\Z0"
Igor Pecovnik's avatar
RFC #2    
Igor Pecovnik committed
71

Igor Pecovnik's avatar
Igor Pecovnik committed
72
73
74
	# main dialog routine
	DIALOG_CANCEL=1
	DIALOG_ESC=255
75

Igor Pecovnik's avatar
RFC #2    
Igor Pecovnik committed
76
	exec 3>&1
77
	selection=$(dialog --colors --backtitle "$BACKTITLE" --title " armbian-config " --clear \
78
79
	--cancel-label "Exit to shell" --menu "\n$MENUTITLE \n \nSupport: \Z1https://www.armbian.com\Z0\n " \
	$LISTLENGHT ${#MENUTITLE} $BOXLENGHT "${LIST[@]}" 2>&1 1>&3)
Igor Pecovnik's avatar
RFC #2    
Igor Pecovnik committed
80
81
	exit_status=$?
	exec 3>&-
82

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

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

Igor Pecovnik's avatar
RFC #2    
Igor Pecovnik committed
87
88
	case $selection in

89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
		"Software" )
			submenu_software
		;;
		"Networking" )
			submenu_networking
		;;
		"System" )
			submenu_settings
		;;
		"Armbian" )
			submenu_hardware
		;;
		"Help" )
			show_box "Info" "This tool provides a straightforward way of configuring the \Z2${BOARD_NAME}\Z0. \
			\n \nAlthough it can be run at any time, some of the options may have difficulties if you alter system settings manually.\n\
			\n\Z1Documentation:\Z0 https://docs.armbian.com\n\n\Z1Support:\Z0 https://forum.armbian.com\n
			\n\Z1Sources:\Z0 https://github.com/armbian/config" "18"
		;;
		esac

done
#-----------------------------------------------------------------------------------------------------------------------------------------#