Unverified Commit dce8f6ea authored by Aristo Chen's avatar Aristo Chen Committed by GitHub
Browse files

Increase readability (#91)

parent b4691785
...@@ -17,27 +17,27 @@ mkdir -p $COPY_TO ...@@ -17,27 +17,27 @@ mkdir -p $COPY_TO
function database_backup () function database_backup ()
{ {
if which mysql >/dev/null; then if which mysql >/dev/null; then
mysqldump -Q -q -e -R --add-drop-table -A -u $USER -p$PASSWORD > $COPY_TO/all.db mysqldump -Q -q -e -R --add-drop-table -A -u $USER -p$PASSWORD > $COPY_TO/all.db
for db in $(echo 'SHOW DATABASES;'|mysql -u$USER -p$PASSWORD -h$HOST|grep -v '^Database$'|grep -v "^performance_schema" |grep -v "^information_schema" |grep -v "^mysql"); for db in $(echo 'SHOW DATABASES;'|mysql -u$USER -p$PASSWORD -h$HOST|grep -v '^Database$'|grep -v "^performance_schema" |grep -v "^information_schema" |grep -v "^mysql");
do do
mysqldump \ mysqldump \
-u$USER -p$PASSWORD -h$HOST \ -u$USER -p$PASSWORD -h$HOST \
-Q -c -C --add-drop-table --add-locks --quick --lock-tables \ -Q -c -C --add-drop-table --add-locks --quick --lock-tables \
$db | gzip --best -c > $COPY_TO/$DBBACKUPNAME-$db.sql.gz; $db | gzip --best -c > $COPY_TO/$DBBACKUPNAME-$db.sql.gz;
echo -e "[\e[0;32m o.k. \x1B[0m] \e[1;32m$1\x1B[0mDatabase $db backup" echo -e "[\e[0;32m o.k. \x1B[0m] \e[1;32m$1\x1B[0mDatabase $db backup"
done; done;
fi fi
} }
function web_backup () function web_backup ()
{ {
if [[ -d /var/www ]]; then if [[ -d /var/www ]]; then
echo -e "[\e[0;32m o.k. \x1B[0m] \e[1;32m$1\x1B[0mWebsites backup" echo -e "[\e[0;32m o.k. \x1B[0m] \e[1;32m$1\x1B[0mWebsites backup"
for x in $(find $COPY_FROM -maxdepth 2 -name "web*" -type d -print0 | xargs -0) for x in $(find $COPY_FROM -maxdepth 2 -name "web*" -type d -print0 | xargs -0)
do do
tar -cpvzf $COPY_TO/$WEBBACKUPNAME-$(basename $x).tar.gz $x &> /dev/null tar -cpvzf $COPY_TO/$WEBBACKUPNAME-$(basename $x).tar.gz $x &> /dev/null
done; done;
fi fi
} }
...@@ -75,11 +75,11 @@ function conf_backup () ...@@ -75,11 +75,11 @@ function conf_backup ()
function mail_backup () function mail_backup ()
{ {
if [[ -d /var/vmail ]]; then if [[ -d /var/vmail ]]; then
service dovecot stop &> /dev/null service dovecot stop &> /dev/null
service postfix stop &> /dev/null service postfix stop &> /dev/null
echo -e "[\e[0;32m o.k. \x1B[0m] \e[1;32m$1\x1B[0mMail backup" echo -e "[\e[0;32m o.k. \x1B[0m] \e[1;32m$1\x1B[0mMail backup"
tar cvPfz $COPY_TO/$FILEBACKUPNAME-mail.tgz /var/vmail tar cvPfz $COPY_TO/$FILEBACKUPNAME-mail.tgz /var/vmail
service postfix start &> /dev/null service postfix start &> /dev/null
service dovecot start &> /dev/null service dovecot start &> /dev/null
fi fi
......
...@@ -2,22 +2,21 @@ ...@@ -2,22 +2,21 @@
REMOTE= REMOTE=
function sync_backup () function sync_backup ()
{ {
echo -e "[\e[0;32m o.k. \x1B[0m] \e[1;32m$1\x1B[0mSync over trusted ssh net" echo -e "[\e[0;32m o.k. \x1B[0m] \e[1;32m$1\x1B[0mSync over trusted ssh net"
filename=filelist.txt filename=filelist.txt
IFS=$'\n' IFS=$'\n'
for next in `cat $filename` for next in `cat $filename`
do do
if [[ $next != \#* ]]; then if [[ $next != \#* ]]; then
echo $next echo $next
rsync --dry-run -az --progress $REMOTE:$next ${next%*/*} rsync --dry-run -az --progress $REMOTE:$next ${next%*/*}
[[ ! $? -eq 0 ]] && read [[ ! $? -eq 0 ]] && read
fi fi
done done
} }
sync_backup sync_backup
...@@ -25,8 +25,8 @@ fi ...@@ -25,8 +25,8 @@ fi
# #
wget -q --spider http://github.com wget -q --spider http://github.com
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
read -n 1 -s -p "Warning: Configuration cannot work properly without a working internet connection. \ read -n 1 -s -p "Warning: Configuration cannot work properly without a working internet connection. \
Press CTRL C to stop or any key to ignore and continue." Press CTRL C to stop or any key to ignore and continue."
fi fi
...@@ -58,12 +58,12 @@ fi ...@@ -58,12 +58,12 @@ fi
# Script parameters handling # Script parameters handling
while [[ $1 == *=* ]]; do while [[ $1 == *=* ]]; do
parameter=${1%%=*} parameter=${1%%=*}
value=${1##*=} value=${1##*=}
shift shift
echo "Command line: setting $parameter to ${value:-(empty)}" echo "Command line: setting $parameter to ${value:-(empty)}"
eval "$parameter=\"$value\"" eval "$parameter=\"$value\""
scripted=true scripted=true
done done
# Display help # Display help
......
...@@ -199,8 +199,8 @@ check_if_installed (){ ...@@ -199,8 +199,8 @@ check_if_installed (){
function is_package_manager_running() { function is_package_manager_running() {
if ps -C apt-get,apt,dpkg >/dev/null ; then if ps -C apt-get,apt,dpkg >/dev/null ; then
[[ -z $scripted ]] && dialog --colors --title " \Z1Error\Z0 " --backtitle "$BACKTITLE" --no-collapse --msgbox \ [[ -z $scripted ]] && dialog --colors --title " \Z1Error\Z0 " --backtitle "$BACKTITLE" --no-collapse --msgbox \
"\n\Z0Package manager is running in the background. \n\nCan't install dependencies. Try again later." 9 53 "\n\Z0Package manager is running in the background. \n\nCan't install dependencies. Try again later." 9 53
return 0 return 0
else else
return 1 return 1
...@@ -232,15 +232,15 @@ function fancy_wget() ...@@ -232,15 +232,15 @@ function fancy_wget()
function display_qr_code() function display_qr_code()
{ {
clear clear
SECRET=$(head -1 /root/.google_authenticator) SECRET=$(head -1 /root/.google_authenticator)
qrencode -m 2 -d 9 -8 -t ANSI256 "otpauth://totp/test?secret=$SECRET" qrencode -m 2 -d 9 -8 -t ANSI256 "otpauth://totp/test?secret=$SECRET"
echo -e "\nHow to setup your one type password generator?\n" echo -e "\nHow to setup your one type password generator?\n"
echo -e "\nInstall a one-time password authenticator on your mobile device (e.g. FreeOTP) from the Android \ echo -e "\nInstall a one-time password authenticator on your mobile device (e.g. FreeOTP) from the Android \
market or F-Droid. \n\nIn the application menu, click the corresponding button to create a new account and either \ market or F-Droid. \n\nIn the application menu, click the corresponding button to create a new account and either \
scan the QR code or enter the secret key manually:\\n\n$SECRET \n\nYou should now see a new passcode token being \ scan the QR code or enter the secret key manually:\\n\n$SECRET \n\nYou should now see a new passcode token being \
generated every 60 seconds on your phone.\n" | fold -sw 60 generated every 60 seconds on your phone.\n" | fold -sw 60
read -n 1 -s -r -p "Press any key to continue" read -n 1 -s -r -p "Press any key to continue"
} }
...@@ -308,15 +308,15 @@ function description ...@@ -308,15 +308,15 @@ function description
;; ;;
*mirrors.netix.net/armbian/apt/*) *mirrors.netix.net/armbian/apt/*)
echo "Bulgarija" echo "Bulgarija"
;; ;;
*mirrors.dotsrc.org/armbian-apt/*) *mirrors.dotsrc.org/armbian-apt/*)
echo "Denmark" echo "Denmark"
;; ;;
*.armbian.com*) *.armbian.com*)
echo "Estonia" echo "Estonia"
;; ;;
*) *)
echo "" echo ""
;; ;;
esac esac
} }
...@@ -327,27 +327,27 @@ function description ...@@ -327,27 +327,27 @@ function description
# #
function generic_select() function generic_select()
{ {
IFS=$' ' IFS=$' '
PARAMETER=($1) PARAMETER=($1)
local LIST=() local LIST=()
for i in "${PARAMETER[@]}" for i in "${PARAMETER[@]}"
do do
if [[ -n $3 ]]; then if [[ -n $3 ]]; then
[[ ${i[0]} -ge $3 ]] && \ [[ ${i[0]} -ge $3 ]] && \
LIST+=( "${i[0]//[[:blank:]]/}" "" ) LIST+=( "${i[0]//[[:blank:]]/}" "" )
else else
LIST+=( "${i[0]//[[:blank:]]/}" "" ) LIST+=( "${i[0]//[[:blank:]]/}" "" )
fi fi
done done
LIST_LENGTH=$((${#LIST[@]}/2)); LIST_LENGTH=$((${#LIST[@]}/2));
if [ "$LIST_LENGTH" -eq 1 ]; then if [ "$LIST_LENGTH" -eq 1 ]; then
PARAMETER=${PARAMETER[0]} PARAMETER=${PARAMETER[0]}
else else
exec 3>&1 exec 3>&1
PARAMETER=$(dialog --nocancel --backtitle "$BACKTITLE" --no-collapse \ PARAMETER=$(dialog --nocancel --backtitle "$BACKTITLE" --no-collapse \
--title "$2" --clear --menu "" $((6+${LIST_LENGTH})) 0 $((1+${LIST_LENGTH})) "${LIST[@]}" 2>&1 1>&3) --title "$2" --clear --menu "" $((6+${LIST_LENGTH})) 0 $((1+${LIST_LENGTH})) "${LIST[@]}" 2>&1 1>&3)
exec 3>&- exec 3>&-
fi fi
} }
...@@ -475,7 +475,7 @@ function other_kernel_version () ...@@ -475,7 +475,7 @@ function other_kernel_version ()
\n\n\Z1In case of troubles expect no help!\Z0" \n\n\Z1In case of troubles expect no help!\Z0"
if [[ -n $ACKNOWLEDGEMENT ]]; then if [[ -n $ACKNOWLEDGEMENT ]]; then
exec 3>&1 exec 3>&1
TARGET_VERSION=$(dialog --cancel-label "Cancel" --backtitle "$BACKTITLE" --no-collapse \ TARGET_VERSION=$(dialog --cancel-label "Cancel" --backtitle "$BACKTITLE" --no-collapse \
--title "Switch from and reboot" --clear --menu "\n${CURRENT_VERSION} $(uname -r) \n \n" \ --title "Switch from and reboot" --clear --menu "\n${CURRENT_VERSION} $(uname -r) \n \n" \
$((9+${LIST_LENGTH})) 62 25 "${LIST[@]}" 2>&1 1>&3) $((9+${LIST_LENGTH})) 62 25 "${LIST[@]}" 2>&1 1>&3)
exitstatus=$?; exitstatus=$?;
...@@ -544,28 +544,28 @@ function aval_dtbs () ...@@ -544,28 +544,28 @@ function aval_dtbs ()
{ {
if [[ $LINUXFAMILY == cubox ]]; then if [[ $LINUXFAMILY == cubox ]]; then
local width=80 local width=80
LIST=("imx6dl-hummingboard.dtb" "HB Solo/DualLite" "imx6dl-hummingboard-emmc-som-v15.dtb" "HB Solo/DualLite v1.5 with eMMC" "imx6dl-hummingboard-som-v15.dtb" "HB Solo/DualLite v1.5" \ LIST=("imx6dl-hummingboard.dtb" "HB Solo/DualLite" "imx6dl-hummingboard-emmc-som-v15.dtb" "HB Solo/DualLite v1.5 with eMMC" "imx6dl-hummingboard-som-v15.dtb" "HB Solo/DualLite v1.5" \
"imx6dl-hummingboard2.dtb" "HB2 Solo/DualLite" "imx6dl-hummingboard2-emmc-som-v15.dtb" "HB2 Solo/DualLite v1.5 with eMMC" "imx6dl-hummingboard2-som-v15.dtb" "HB2 Solo/DualLite v1.5" \ "imx6dl-hummingboard2.dtb" "HB2 Solo/DualLite" "imx6dl-hummingboard2-emmc-som-v15.dtb" "HB2 Solo/DualLite v1.5 with eMMC" "imx6dl-hummingboard2-som-v15.dtb" "HB2 Solo/DualLite v1.5" \
"imx6q-hummingboard.dtb" "HB Dual/Quad" "imx6q-hummingboard-emmc-som-v15.dtb" "HB Dual/Quad v1.5 with eMMC" "imx6q-hummingboard-som-v15.dtb" "HB Dual/Quad v1.5" \ "imx6q-hummingboard.dtb" "HB Dual/Quad" "imx6q-hummingboard-emmc-som-v15.dtb" "HB Dual/Quad v1.5 with eMMC" "imx6q-hummingboard-som-v15.dtb" "HB Dual/Quad v1.5" \
"imx6q-hummingboard2.dtb" "HB2 Dual/Quad" "imx6q-hummingboard2-emmc-som-v15.dtb" "HB2 Dual/Quad v1.5 with eMMC" "imx6q-hummingboard2-som-v15.dtb" "HB2 Dual/Quad v1.5" \ "imx6q-hummingboard2.dtb" "HB2 Dual/Quad" "imx6q-hummingboard2-emmc-som-v15.dtb" "HB2 Dual/Quad v1.5 with eMMC" "imx6q-hummingboard2-som-v15.dtb" "HB2 Dual/Quad v1.5" \
"imx6dl-cubox-i.dtb" "Cubox-i Solo/DualLite" "imx6dl-cubox-i-emmc-som-v15.dtb" "Cubox-i Solo/DualLite v1.5 with eMMC" "imx6dl-cubox-i-som-v15.dtb" "Cubox-i Solo/DualLite v1.5" \ "imx6dl-cubox-i.dtb" "Cubox-i Solo/DualLite" "imx6dl-cubox-i-emmc-som-v15.dtb" "Cubox-i Solo/DualLite v1.5 with eMMC" "imx6dl-cubox-i-som-v15.dtb" "Cubox-i Solo/DualLite v1.5" \
"imx6q-cubox-i.dtb" "Cubox-i Dual/Quad" "imx6q-cubox-i-emmc-som-v15.dtb" "Cubox-i Dual/Quad v1.5 with eMMC" "imx6q-cubox-i-som-v15.dtb" "Cubox-i Dual/Quad v1.5") "imx6q-cubox-i.dtb" "Cubox-i Dual/Quad" "imx6q-cubox-i-emmc-som-v15.dtb" "Cubox-i Dual/Quad v1.5 with eMMC" "imx6q-cubox-i-som-v15.dtb" "Cubox-i Dual/Quad v1.5")
else else
local width=52 local width=52
LIST=("xu4" "Odroid XU4" "xu3" "Odroid XU3" "xu3l" "Odroid XU3 Lite" "hc1" "Odroid HC1/HC2") LIST=("xu4" "Odroid XU4" "xu3" "Odroid XU3" "xu3l" "Odroid XU3 Lite" "hc1" "Odroid HC1/HC2")
fi fi
LIST_LENGTH=$((${#LIST[@]}/2)); LIST_LENGTH=$((${#LIST[@]}/2));
if [ "$LIST_LENGTH" -eq 1 ]; then if [ "$LIST_LENGTH" -eq 1 ]; then
TARGET_BOARD=${AVAL_KERNEL[0]} TARGET_BOARD=${AVAL_KERNEL[0]}
else else
exec 3>&1 exec 3>&1
TARGET_BOARD=$(dialog --cancel-label "Cancel" --backtitle "$BACKTITLE" --no-collapse \ TARGET_BOARD=$(dialog --cancel-label "Cancel" --backtitle "$BACKTITLE" --no-collapse \
--title "Select optimised board configuration" --clear --menu \ --title "Select optimised board configuration" --clear --menu \
"" $((6+${LIST_LENGTH})) ${width} 25 "${LIST[@]}" 2>&1 1>&3) "" $((6+${LIST_LENGTH})) ${width} 25 "${LIST[@]}" 2>&1 1>&3)
exitstatus=$?; exitstatus=$?;
exec 3>&- exec 3>&-
fi fi
} }
...@@ -585,19 +585,19 @@ function get_a20modes () ...@@ -585,19 +585,19 @@ function get_a20modes ()
local LIST=() local LIST=()
for i in "${SCREEN_RESOLUTION[@]}" for i in "${SCREEN_RESOLUTION[@]}"
do do
LIST+=( "${i[0]//[[:blank:]]/}" "" ) LIST+=( "${i[0]//[[:blank:]]/}" "" )
done done
LIST_LENGTH=$((${#LIST[@]}/2)); LIST_LENGTH=$((${#LIST[@]}/2));
#echo $LIST_LENGTH #echo $LIST_LENGTH
#exit #exit
if [ "$LIST_LENGTH" -eq 1 ]; then if [ "$LIST_LENGTH" -eq 1 ]; then
SCREEN_RESOLUTION=${SCREEN_RESOLUTION[0]} SCREEN_RESOLUTION=${SCREEN_RESOLUTION[0]}
else else
exec 3>&1 exec 3>&1
SCREEN_RESOLUTION=$(dialog --nocancel --backtitle "$BACKTITLE" --no-collapse \ SCREEN_RESOLUTION=$(dialog --nocancel --backtitle "$BACKTITLE" --no-collapse \
--title "Select video mode" --clear --menu \ --title "Select video mode" --clear --menu \
"" $((6+${LIST_LENGTH})) 25 $((1+${LIST_LENGTH})) "${LIST[@]}" 2>&1 1>&3) "" $((6+${LIST_LENGTH})) 25 $((1+${LIST_LENGTH})) "${LIST[@]}" 2>&1 1>&3)
exec 3>&- exec 3>&-
fi fi
} }
...@@ -611,27 +611,27 @@ function get_a20modes () ...@@ -611,27 +611,27 @@ function get_a20modes ()
function get_odroidmodes () function get_odroidmodes ()
{ {
IFS=$'\r\n' IFS=$'\r\n'
GLOBIGNORE='*' GLOBIGNORE='*'
SCREEN_RESOLUTION=($(cat /boot/boot.ini | grep -w "# setenv" | grep "hz" | cut -d'"' -f 2)) SCREEN_RESOLUTION=($(cat /boot/boot.ini | grep -w "# setenv" | grep "hz" | cut -d'"' -f 2))
SCREEN_RESOLUTION=($(cat /boot/boot.ini | grep "Progressive" | grep -v "setenv" | cut -d'"' -f 2)) SCREEN_RESOLUTION=($(cat /boot/boot.ini | grep "Progressive" | grep -v "setenv" | cut -d'"' -f 2))
local LIST=() local LIST=()
for i in "${SCREEN_RESOLUTION[@]}" for i in "${SCREEN_RESOLUTION[@]}"
do do
LIST+=( "${i[0]//[[:blank:]]/}" "" ) LIST+=( "${i[0]//[[:blank:]]/}" "" )
done done
LIST_LENGTH=$((${#LIST[@]}/2)); LIST_LENGTH=$((${#LIST[@]}/2));
#echo $LIST_LENGTH #echo $LIST_LENGTH
#exit #exit
if [ "$LIST_LENGTH" -eq 1 ]; then if [ "$LIST_LENGTH" -eq 1 ]; then
SCREEN_RESOLUTION=${SCREEN_RESOLUTION[0]} SCREEN_RESOLUTION=${SCREEN_RESOLUTION[0]}
else else
exec 3>&1 exec 3>&1
SCREEN_RESOLUTION=$(dialog --nocancel --backtitle "$BACKTITLE" --no-collapse \ SCREEN_RESOLUTION=$(dialog --nocancel --backtitle "$BACKTITLE" --no-collapse \
--title "Select video mode" --clear --menu \ --title "Select video mode" --clear --menu \
"" $((6+${LIST_LENGTH})) 25 $((1+${LIST_LENGTH})) "${LIST[@]}" 2>&1 1>&3) "" $((6+${LIST_LENGTH})) 25 $((1+${LIST_LENGTH})) "${LIST[@]}" 2>&1 1>&3)
exec 3>&- exec 3>&-
fi fi
} }
...@@ -650,19 +650,19 @@ function get_h3modes () ...@@ -650,19 +650,19 @@ function get_h3modes ()
local LIST=() local LIST=()
for i in "${SCREEN_RESOLUTION[@]}" for i in "${SCREEN_RESOLUTION[@]}"
do do
LIST+=( "${i[0]//[[:blank:]]/}" "" ) LIST+=( "${i[0]//[[:blank:]]/}" "" )
done done
LIST_LENGTH=$((${#LIST[@]}/2)); LIST_LENGTH=$((${#LIST[@]}/2));
#echo $LIST_LENGTH #echo $LIST_LENGTH
#exit #exit
if [ "$LIST_LENGTH" -eq 1 ]; then if [ "$LIST_LENGTH" -eq 1 ]; then
SCREEN_RESOLUTION=${SCREEN_RESOLUTION[0]} SCREEN_RESOLUTION=${SCREEN_RESOLUTION[0]}
else else
exec 3>&1 exec 3>&1
SCREEN_RESOLUTION=$(dialog --nocancel --backtitle "$BACKTITLE" --no-collapse \ SCREEN_RESOLUTION=$(dialog --nocancel --backtitle "$BACKTITLE" --no-collapse \
--title "Select video mode" --clear --menu \ --title "Select video mode" --clear --menu \
"" $((6+${LIST_LENGTH})) 25 $((1+${LIST_LENGTH})) "${LIST[@]}" 2>&1 1>&3) "" $((6+${LIST_LENGTH})) 25 $((1+${LIST_LENGTH})) "${LIST[@]}" 2>&1 1>&3)
exec 3>&- exec 3>&-
fi fi
} }
...@@ -699,12 +699,12 @@ function add_choose_user () ...@@ -699,12 +699,12 @@ function add_choose_user ()
echo "Trying to add user $CHOSEN_USER" echo "Trying to add user $CHOSEN_USER"
adduser $CHOSEN_USER || return adduser $CHOSEN_USER || return
elif [ "$LIST_LENGTH" -eq 1 ]; then elif [ "$LIST_LENGTH" -eq 1 ]; then
CHOSEN_USER=${USERS[0]} CHOSEN_USER=${USERS[0]}
else else
exec 3>&1 exec 3>&1
CHOSEN_USER=$(dialog --nocancel --backtitle "$BACKTITLE" --no-collapse \ CHOSEN_USER=$(dialog --nocancel --backtitle "$BACKTITLE" --no-collapse \
--title "Select unprivileged user" --clear --menu "" $((6+${LIST_LENGTH})) 40 15 "${LIST[@]}" 2>&1 1>&3) --title "Select unprivileged user" --clear --menu "" $((6+${LIST_LENGTH})) 40 15 "${LIST[@]}" 2>&1 1>&3)
exec 3>&- exec 3>&-
fi fi
} }
......
...@@ -53,7 +53,7 @@ function initialize_lte () ...@@ -53,7 +53,7 @@ function initialize_lte ()
# Source repository: https://github.com/ssinyagin/wwan_udev_rules # Source repository: https://github.com/ssinyagin/wwan_udev_rules
if ! check_if_installed ppp then; then if ! check_if_installed ppp then; then
apt-get -y -qq install ppp >/dev/null 2>&1 apt-get -y -qq install ppp >/dev/null 2>&1
fi fi
cat >/etc/udev/rules.d/99-wwan.rules <<'EOT' cat >/etc/udev/rules.d/99-wwan.rules <<'EOT'
...@@ -224,16 +224,16 @@ function check_advanced_modes () ...@@ -224,16 +224,16 @@ function check_advanced_modes ()
# #
function create_if_config() { function create_if_config() {
address=$(ip -4 addr show dev $1 | awk '/inet/ {print $2}' | cut -d'/' -f1) address=$(ip -4 addr show dev $1 | awk '/inet/ {print $2}' | cut -d'/' -f1)
netmask=$(ip -4 addr show dev $1 | awk '/inet/ {print $2}' | cut -d'/' -f2) netmask=$(ip -4 addr show dev $1 | awk '/inet/ {print $2}' | cut -d'/' -f2)
gateway=$(route -n | grep 'UG[ \t]' | awk '{print $2}' | sed -n '1p') gateway=$(route -n | grep 'UG[ \t]' | awk '{print $2}' | sed -n '1p')
echo -e "# armbian-config created" echo -e "# armbian-config created"
echo -e "source /etc/network/interfaces.d/*\n" echo -e "source /etc/network/interfaces.d/*\n"
if [[ "$3" == "fixed" ]]; then if [[ "$3" == "fixed" ]]; then
echo -e "# Local loopback\nauto lo\niface lo init loopback\n" echo -e "# Local loopback\nauto lo\niface lo init loopback\n"
echo -e "# Interface $2\nauto $2\nallow-hotplug $2" echo -e "# Interface $2\nauto $2\nallow-hotplug $2"
echo -e "iface $2 inet static\n\taddress $address\n\tnetmask $netmask\n\tgateway $gateway\n\tdns-nameservers 8.8.8.8" echo -e "iface $2 inet static\n\taddress $address\n\tnetmask $netmask\n\tgateway $gateway\n\tdns-nameservers 8.8.8.8"
fi fi
} }
...@@ -273,7 +273,7 @@ function check_port () ...@@ -273,7 +273,7 @@ function check_port ()
# check wifi high throughput # check wifi high throughput
# #
function check_ht_capab () function check_ht_capab ()
{ {
declare -a arr=("[HT40+][LDPC][SHORT-GI-20][SHORT-GI-40][TX-STBC][RX-STBC1][DSSS_CCK-40][SMPS-STATIC]" \ 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+]" "[DSSS_CK-40][HT20+]" "") "[HT40-][SHORT-GI-40][SHORT-GI-40][DSSS_CCK-40]" "[SHORT-GI-20][SHORT-GI-40][HT40+]" "[DSSS_CK-40][HT20+]" "")
local j=0 local j=0
...@@ -336,13 +336,13 @@ function check_channels () ...@@ -336,13 +336,13 @@ function check_channels ()
# #
function netmask_to_cidr () function netmask_to_cidr ()
{ {
IFS=' ' IFS=' '
local bits=0 local bits=0
for octet in $(echo $1| sed 's/\./ /g'); do for octet in $(echo $1| sed 's/\./ /g'); do
binbits=$(echo "obase=2; ibase=10; ${octet}"| bc | sed 's/0//g') binbits=$(echo "obase=2; ibase=10; ${octet}"| bc | sed 's/0//g')
let bits+=${#binbits} let bits+=${#binbits}
done done
echo "${bits}" echo "${bits}"
} }
...@@ -362,12 +362,12 @@ exec 3>&1 ...@@ -362,12 +362,12 @@ exec 3>&1
read -r address;read -r netmask;read -r gateway read -r address;read -r netmask;read -r gateway
if [[ $? = 0 ]]; then if [[ $? = 0 ]]; then
localuuid=$(LC_ALL=C nmcli -f UUID,DEVICE connection show | grep $1 | awk '{print $1}') localuuid=$(LC_ALL=C nmcli -f UUID,DEVICE connection show | grep $1 | awk '{print $1}')
# convert netmask value to CIDR if required # convert netmask value to CIDR if required
if [[ $netmask =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then if [[ $netmask =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
CIDR=$(netmask_to_cidr ${netmask}) CIDR=$(netmask_to_cidr ${netmask})
else else
CIDR=${netmask} CIDR=${netmask}
fi fi
if [[ -n "$localuuid" ]]; then if [[ -n "$localuuid" ]]; then
# adjust existing # adjust existing
nmcli con mod $localuuid ipv4.method manual ipv4.addresses "$address/$CIDR" >/dev/null 2>&1 nmcli con mod $localuuid ipv4.method manual ipv4.addresses "$address/$CIDR" >/dev/null 2>&1
...@@ -407,10 +407,10 @@ function systemd_ip_editor () ...@@ -407,10 +407,10 @@ function systemd_ip_editor ()
2>&1 1>&3 | { 2>&1 1>&3 | {
read -r address;read -r netmask;read -r gateway read -r address;read -r netmask;read -r gateway
if [[ $? = 0 ]]; then if [[ $? = 0 ]]; then
echo -e "[Network]" >>$filename echo -e "[Network]" >>$filename
echo -e "Address=$address" >> $filename echo -e "Address=$address" >> $filename
echo -e "Gateway=$gateway" >> $filename echo -e "Gateway=$gateway" >> $filename
echo -e "DNS=8.8.8.8" >> $filename echo -e "DNS=8.8.8.8" >> $filename
fi fi
} }
fi fi
...@@ -435,10 +435,10 @@ function ip_editor () ...@@ -435,10 +435,10 @@ function ip_editor ()
2>&1 1>&3 | { 2>&1 1>&3 | {
read -r address;read -r netmask;read -r gateway read -r address;read -r netmask;read -r gateway
if [[ $? = 0 ]]; then if [[ $? = 0 ]]; then
echo -e "# armbian-config created\nsource /etc/network/interfaces.d/*\n" >$3 echo -e "# armbian-config created\nsource /etc/network/interfaces.d/*\n" >$3
echo -e "# Local loopback\nauto lo\niface lo inet loopback\n" >> $3 echo -e "# Local loopback\nauto lo\niface lo inet loopback\n" >> $3
echo -e "# Interface $2\nauto $2\nallow-hotplug $2\niface $2 inet static\ echo -e "# Interface $2\nauto $2\nallow-hotplug $2\niface $2 inet static\
\n\taddress $address\n\tnetmask $netmask\n\tgateway $gateway\n\tdns-nameservers 8.8.8.8" >> $3 \n\taddress $address\n\tnetmask $netmask\n\tgateway $gateway\n\tdns-nameservers 8.8.8.8" >> $3
fi fi
} }
...@@ -462,11 +462,11 @@ function wlan_edit_basic () ...@@ -462,11 +462,11 @@ function wlan_edit_basic ()
2>&1 1>&3 | { 2>&1 1>&3 | {
read -r ssid;read -r wpa_passphrase;read -r channel read -r ssid;read -r wpa_passphrase;read -r channel
if [[ $? = 0 ]]; then if [[ $? = 0 ]]; then
sed -i "s/^ssid=.*/ssid=$ssid/" /etc/hostapd.conf sed -i "s/^ssid=.*/ssid=$ssid/" /etc/hostapd.conf
sed -i "s/^wpa_passphrase=.*/wpa_passphrase=$wpa_passphrase/" /etc/hostapd.conf sed -i "s/^wpa_passphrase=.*/wpa_passphrase=$wpa_passphrase/" /etc/hostapd.conf
sed -i "s/^channel=.*/channel=$channel/" /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-) 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 sed -i "s/^wpa_psk=.*/wpa_psk=$wpa_psk/" /etc/hostapd.conf
fi fi
} }
} }
...@@ -553,17 +553,17 @@ function get_wlan_interface () ...@@ -553,17 +553,17 @@ function get_wlan_interface ()
local LIST=() local LIST=()
for i in "${WLAN_INTERFACES[@]}" for i in "${WLAN_INTERFACES[@]}"
do do
LIST+=( "${i[0]//[[:blank:]]/}" "" ) LIST+=( "${i[0]//[[:blank:]]/}" "" )
done done
LIST_LENGTH=$((${#LIST[@]}/2)); LIST_LENGTH=$((${#LIST[@]}/2));
if [ "$LIST_LENGTH" -eq 1 ]; then if [ "$LIST_LENGTH" -eq 1 ]; then
WIRELESS_ADAPTER=${WLAN_INTERFACES[0]} WIRELESS_ADAPTER=${WLAN_INTERFACES[0]}
else else
exec 3>&1 exec 3>&1
WIRELESS_ADAPTER=$(dialog --nocancel --backtitle "$BACKTITLE" --no-collapse \ WIRELESS_ADAPTER=$(dialog --nocancel --backtitle "$BACKTITLE" --no-collapse \
--title "Select interface" --clear --menu "" $((6+${LIST_LENGTH})) 40 15 "${LIST[@]}" 2>&1 1>&3) --title "Select interface" --clear --menu "" $((6+${LIST_LENGTH})) 40 15 "${LIST[@]}" 2>&1 1>&3)
exec 3>&- exec 3>&-
fi fi
} }
...@@ -624,26 +624,26 @@ function select_default_interface () ...@@ -624,26 +624,26 @@ function select_default_interface ()
local LIST=() local LIST=()
for i in "${ADAPTER[@]}" for i in "${ADAPTER[@]}"
do do
local IPADDR=$(LC_ALL=C ip -4 addr show dev ${i[0]} | awk '/inet/ {print $2}' | cut -d'/' -f1) local IPADDR=$(LC_ALL=C ip -4 addr show dev ${i[0]} | awk '/inet/ {print $2}' | cut -d'/' -f1)
ADD_SPEED="" ADD_SPEED=""
[[ $i == eth* || $i == en* ]] && ADD_SPEED=$(ethtool $i | grep Speed) [[ $i == eth* || $i == en* ]] && ADD_SPEED=$(ethtool $i | grep Speed)
[[ $i == wl* ]] && ADD_SPEED=$(LC_ALL=C nmcli -f RATE,DEVICE,ACTIVE dev wifi list | grep $i | grep yes | awk 'NF==4{print $1""$2}NF==1' | sed -e 's/^/ Speed: /' | tail -1) [[ $i == wl* ]] && ADD_SPEED=$(LC_ALL=C nmcli -f RATE,DEVICE,ACTIVE dev wifi list | grep $i | grep yes | awk 'NF==4{print $1""$2}NF==1' | sed -e 's/^/ Speed: /' | tail -1)
if [[ $1 == "default" ]]; then if [[ $1 == "default" ]]; then
[[ $IPADDR != "172.24.1.1" && -n $IPADDR ]] && LIST+=( "${i[0]//[[:blank:]]/}" "${IPADDR} ${ADD_SPEED}" ) [[ $IPADDR != "172.24.1.1" && -n $IPADDR ]] && LIST+=( "${i[0]//[[:blank:]]/}" "${IPADDR} ${ADD_SPEED}" )
else else
[[ $IPADDR != "172.24.1.1" ]] && LIST+=( "${i[0]//[[:blank:]]/}" "${IPADDR} ${ADD_SPEED}" ) [[ $IPADDR != "172.24.1.1" ]] && LIST+=( "${i[0]//[[:blank:]]/}" "${IPADDR} ${ADD_SPEED}" )
fi fi
done done
LIST_LENGTH=$((${#LIST[@]}/2)); LIST_LENGTH=$((${#LIST[@]}/2));
if [ "$LIST_LENGTH" -eq 0 ]; then if [ "$LIST_LENGTH" -eq 0 ]; then
DEFAULT_ADAPTER="lo" DEFAULT_ADAPTER="lo"
elif [ "$LIST_LENGTH" -eq 1 ]; then elif [ "$LIST_LENGTH" -eq 1 ]; then
DEFAULT_ADAPTER=${ADAPTER[0]} DEFAULT_ADAPTER=${ADAPTER[0]}
else else
exec 3>&1 exec 3>&1
DEFAULT_ADAPTER=$(dialog --nocancel --backtitle "$BACKTITLE" --no-collapse \ DEFAULT_ADAPTER=$(dialog --nocancel --backtitle "$BACKTITLE" --no-collapse \
--title "Select $1 interface" --clear --menu "" $((6+${LIST_LENGTH})) 74 14 "${LIST[@]}" 2>&1 1>&3) --title "Select $1 interface" --clear --menu "" $((6+${LIST_LENGTH})) 74 14 "${LIST[@]}" 2>&1 1>&3)
exec 3>&- exec 3>&-
fi fi
fi fi
...@@ -700,43 +700,43 @@ EOF ...@@ -700,43 +700,43 @@ EOF
function connect_bt_interface () function connect_bt_interface ()
{ {
IFS=$'\r\n' IFS=$'\r\n'
GLOBIGNORE='*' GLOBIGNORE='*'
dialog --backtitle "$BACKTITLE" --title "Please wait" --infobox "\nDiscovering Bluetooth devices ... " 5 37 dialog --backtitle "$BACKTITLE" --title "Please wait" --infobox "\nDiscovering Bluetooth devices ... " 5 37
BT_INTERFACES=($(hcitool scan | sed '1d')) BT_INTERFACES=($(hcitool scan | sed '1d'))
local LIST=() local LIST=()
for i in "${BT_INTERFACES[@]}" for i in "${BT_INTERFACES[@]}"
do do
local a=$(echo ${i[0]//[[:blank:]]/} | sed -e 's/^\(.\{17\}\).*/\1/') local a=$(echo ${i[0]//[[:blank:]]/} | sed -e 's/^\(.\{17\}\).*/\1/')
local b=${i[0]//$a/} local b=${i[0]//$a/}
local b=$(echo $b | sed -e 's/^[ \t]*//') local b=$(echo $b | sed -e 's/^[ \t]*//')
LIST+=( "$a" "$b") LIST+=( "$a" "$b")
done done
LIST_LENGTH=$((${#LIST[@]}/2)); LIST_LENGTH=$((${#LIST[@]}/2));
if [ "$LIST_LENGTH" -eq 0 ]; then if [ "$LIST_LENGTH" -eq 0 ]; then
BT_ADAPTER=${WLAN_INTERFACES[0]} BT_ADAPTER=${WLAN_INTERFACES[0]}
dialog --backtitle "$BACKTITLE" --title "Bluetooth" --msgbox "\nNo nearby Bluetooth devices were found!" 7 43 dialog --backtitle "$BACKTITLE" --title "Bluetooth" --msgbox "\nNo nearby Bluetooth devices were found!" 7 43
else else
exec 3>&1 exec 3>&1
BT_ADAPTER=$(dialog --backtitle "$BACKTITLE" --no-collapse --title "Select interface" \ BT_ADAPTER=$(dialog --backtitle "$BACKTITLE" --no-collapse --title "Select interface" \
--clear --menu "" $((6+${LIST_LENGTH})) 50 15 "${LIST[@]}" 2>&1 1>&3) --clear --menu "" $((6+${LIST_LENGTH})) 50 15 "${LIST[@]}" 2>&1 1>&3)
exec 3>&- exec 3>&-
if [[ $BT_ADAPTER != "" ]]; then if [[ $BT_ADAPTER != "" ]]; then
dialog --backtitle "$BACKTITLE" --title "Please wait" --infobox "\nConnecting to $BT_ADAPTER " 5 35 dialog --backtitle "$BACKTITLE" --title "Please wait" --infobox "\nConnecting to $BT_ADAPTER " 5 35
BT_EXEC=$( BT_EXEC=$(
expect -c 'set prompt "#";set address '$BT_ADAPTER';spawn bluetoothctl;expect -re $prompt;send "disconnect $address\r"; 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"; 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"; 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') send_user "\nShould be paired now.\r";sleep 2;send "quit\r";expect eof')
echo "$BT_EXEC" > /tmp/bt-connect-debug.log echo "$BT_EXEC" > /tmp/bt-connect-debug.log
if [[ $(echo "$BT_EXEC" | grep "Connection successful" ) != "" ]]; then if [[ $(echo "$BT_EXEC" | grep "Connection successful" ) != "" ]]; then
dialog --backtitle "$BACKTITLE" --title "Bluetooth" --msgbox "\nYour device is ready to use!" 7 32 dialog --backtitle "$BACKTITLE" --title "Bluetooth" --msgbox "\nYour device is ready to use!" 7 32
else else
dialog --backtitle "$BACKTITLE" --title "Bluetooth" --msgbox "\nError connecting. Try again!" 7 32 dialog --backtitle "$BACKTITLE" --title "Bluetooth" --msgbox "\nError connecting. Try again!" 7 32
fi fi
fi
fi fi
fi
} }
...@@ -367,17 +367,17 @@ unset selection ...@@ -367,17 +367,17 @@ unset selection
# Connect to wireless access point # Connect to wireless access point
# #
"WiFi" ) "WiFi" )
# disable AP mode on certain adapters # disable AP mode on certain adapters
wlan_exceptions "off" wlan_exceptions "off"
[[ "$reboot_module" == true ]] && dialog --backtitle "$BACKTITLE" --title " Warning " --msgbox "\nReboot is required for this adapter to switch to STA mode" 7 62 && reboot [[ "$reboot_module" == true ]] && dialog --backtitle "$BACKTITLE" --title " Warning " --msgbox "\nReboot is required for this adapter to switch to STA mode" 7 62 && reboot
nmtui-connect nmtui-connect
;; ;;
# Connect to 3G/4G network # Connect to 3G/4G network
# #
"LTE" ) "LTE" )
if ! is_package_manager_running; then if ! is_package_manager_running; then
if [[ $LTE_MODEM == *online* ]]; then if [[ $LTE_MODEM == *online* ]]; then
dialog --title " LTE modem is connected " --colors --backtitle "$BACKTITLE" --yes-label "Back" --no-label "Disconnect" --yesno "\n\Z1Disconnect:\Z0 kill mobile connection\n\n" 7 42 dialog --title " LTE modem is connected " --colors --backtitle "$BACKTITLE" --yes-label "Back" --no-label "Disconnect" --yesno "\n\Z1Disconnect:\Z0 kill mobile connection\n\n" 7 42
[[ $? = 1 ]] && lte "$LTE_MODEM_ID" "off" [[ $? = 1 ]] && lte "$LTE_MODEM_ID" "off"
...@@ -385,28 +385,28 @@ unset selection ...@@ -385,28 +385,28 @@ unset selection
dialog --title " LTE modem is disconnected " --colors --backtitle "$BACKTITLE" --yes-label "Back" --no-label "Connect" --yesno "\n\Z1Connect:\Z0 dial mobile connection\n\n" 7 42 dialog --title " LTE modem is disconnected " --colors --backtitle "$BACKTITLE" --yes-label "Back" --no-label "Connect" --yesno "\n\Z1Connect:\Z0 dial mobile connection\n\n" 7 42
[[ $? = 1 ]] && lte "$LTE_MODEM_ID" "on" [[ $? = 1 ]] && lte "$LTE_MODEM_ID" "on"
fi fi
fi fi
;; ;;
# Connect to wireless access point # Connect to wireless access point
# #
"Clear" ) "Clear" )
# remove managed interfaces # remove managed interfaces
systemctl daemon-reload systemctl daemon-reload
nmcli con delete $(nmcli --fields NAME,UUID,TYPE con | grep wifi | awk '{print $2}') nmcli con delete $(nmcli --fields NAME,UUID,TYPE con | grep wifi | awk '{print $2}')
sed 's/interface-name:wl.*//' -i /etc/NetworkManager/conf.d/10-ignore-interfaces.conf sed 's/interface-name:wl.*//' -i /etc/NetworkManager/conf.d/10-ignore-interfaces.conf
sed 's/,$//' -i /etc/NetworkManager/conf.d/10-ignore-interfaces.conf sed 's/,$//' -i /etc/NetworkManager/conf.d/10-ignore-interfaces.conf
rm -f /etc/network/interfaces.d/armbian.ap.* rm -f /etc/network/interfaces.d/armbian.ap.*
rm -f /etc/dnsmasq.conf rm -f /etc/dnsmasq.conf
systemctl stop dnsmasq systemctl stop dnsmasq
systemctl disable dnsmasq systemctl disable dnsmasq
iptables -t nat -D POSTROUTING 1 >/dev/null 2>&1 iptables -t nat -D POSTROUTING 1 >/dev/null 2>&1
systemctl stop armbian-restore-iptables.service systemctl stop armbian-restore-iptables.service
systemctl disable armbian-restore-iptables.service systemctl disable armbian-restore-iptables.service
rm -f /etc/iptables.ipv4.nat rm -f /etc/iptables.ipv4.nat
rm -f /var/run/hostapd/* >/dev/null 2>&1 rm -f /var/run/hostapd/* >/dev/null 2>&1
reload-nety reload-nety
;; ;;
...@@ -688,69 +688,69 @@ unset selection ...@@ -688,69 +688,69 @@ unset selection
} }
function raise_dev { function raise_dev {
i=0; i=0;
while [[ -z "$TEMP" && $i<5 ]]; do while [[ -z "$TEMP" && $i<5 ]]; do
TEMP=$(${VPNDIR}vpncmd /client localhost /cmd accountlist | grep Status | grep Connected) TEMP=$(${VPNDIR}vpncmd /client localhost /cmd accountlist | grep Status | grep Connected)
sleep 1 sleep 1
i=$((i+1)) i=$((i+1))
done done
dhclient vpn_se dhclient vpn_se
} }
if pgrep -x "vpnclient" > /dev/null if pgrep -x "vpnclient" > /dev/null
then then
${VPNDIR}vpnclient stop >/dev/null 2>&1
${VPNDIR}vpnclient start >/dev/null 2>&1
if [[ -z $(${VPNDIR}vpncmd /client localhost /cmd nicList | grep Enabled) ]]; then
${VPNDIR}vpncmd /client localhost /cmd niccreate se >/dev/null 2>&1
fi
if [[ -z $(${VPNDIR}vpncmd /client localhost /cmd accountlist | grep "VPN Server") ]]; then
dialog --backtitle "$BACKTITLE" --no-label " Cancel " --yes-label " Import " --title " VPN " --yesno "\nA VPN configuration was not found.\n\nPlace valid file at /etc/server.vpn" 9 45
if [[ $? = 0 && -f /etc/server.vpn ]]; then
${VPNDIR}vpncmd /client localhost /cmd accountimport //etc//server.vpn >/dev/null 2>&1
${VPNDIR}vpnclient stop >/dev/null 2>&1 ${VPNDIR}vpnclient stop >/dev/null 2>&1
${VPNDIR}vpnclient start >/dev/null 2>&1 ${VPNDIR}vpnclient start >/dev/null 2>&1
if [[ -z $(${VPNDIR}vpncmd /client localhost /cmd nicList | grep Enabled) ]]; then [[ $? = 0 ]] && dialog --backtitle "$BACKTITLE" --title " VPN " --msgbox "\nConfiguration was successfully imported!" 7 43
${VPNDIR}vpncmd /client localhost /cmd niccreate se >/dev/null 2>&1 fi
fi fi
if [[ -z $(${VPNDIR}vpncmd /client localhost /cmd accountlist | grep "VPN Server") ]]; then
dialog --backtitle "$BACKTITLE" --no-label " Cancel " --yes-label " Import " --title " VPN " --yesno "\nA VPN configuration was not found.\n\nPlace valid file at /etc/server.vpn" 9 45
if [[ $? = 0 && -f /etc/server.vpn ]]; then
${VPNDIR}vpncmd /client localhost /cmd accountimport //etc//server.vpn >/dev/null 2>&1
${VPNDIR}vpnclient stop >/dev/null 2>&1
${VPNDIR}vpnclient start >/dev/null 2>&1
[[ $? = 0 ]] && dialog --backtitle "$BACKTITLE" --title " VPN " --msgbox "\nConfiguration was successfully imported!" 7 43
fi
fi
# raise devices # raise devices
raise_dev raise_dev
if [[ -n $(${VPNDIR}vpncmd /client localhost /cmd accountlist | grep Status | grep Connected) ]]; then if [[ -n $(${VPNDIR}vpncmd /client localhost /cmd accountlist | grep Status | grep Connected) ]]; then
get_numbers get_numbers
echo "ip route add $VPNSERVERIP via $IP dev $ADAPTER" echo "ip route add $VPNSERVERIP via $IP dev $ADAPTER"
echo "ip route del default" echo "ip route del default"
echo "ip route add default via $GW dev vpn_se" echo "ip route add default via $GW dev vpn_se"
read read
dialog --title "VPN client is connected to $VPNSERVERIP" --colors --backtitle "$BACKTITLE" --help-button --help-label "Cancel" --yes-label "Stop" --no-label " Import " --yesno "\n\Z1Stop: \Z0 stop\n\n\Z1Import:\Z0 import new config from /etc/armbian.vpn" 9 70 dialog --title "VPN client is connected to $VPNSERVERIP" --colors --backtitle "$BACKTITLE" --help-button --help-label "Cancel" --yes-label "Stop" --no-label " Import " --yesno "\n\Z1Stop: \Z0 stop\n\n\Z1Import:\Z0 import new config from /etc/armbian.vpn" 9 70
fi fi
response=$? response=$?
if [[ $response = 0 ]]; then if [[ $response = 0 ]]; then
get_numbers get_numbers
echo "ip route del $VPNSERVERIP" echo "ip route del $VPNSERVERIP"
echo "ip route del default" echo "ip route del default"
echo "ip route add default via $IP dev $ADAPTER" echo "ip route add default via $IP dev $ADAPTER"
read read
dialog --backtitle "$BACKTITLE" --nocancel --nook --infobox "\nClosing VPN connection" 5 27 dialog --backtitle "$BACKTITLE" --nocancel --nook --infobox "\nClosing VPN connection" 5 27
${VPNDIR}vpnclient stop >/dev/null 2>&1 ${VPNDIR}vpnclient stop >/dev/null 2>&1
fi fi
else else
dialog --title "VPN client is disconnected" --colors --backtitle "$BACKTITLE" --help-button --help-label "Cancel" --yes-label "Connect" --no-label " Import " --yesno "\n\Z1Connect:\Z0 Connect with your VPN server \n\n\Z1Import:\Z0 import new config from /etc/armbian.vpn" 9 70 dialog --title "VPN client is disconnected" --colors --backtitle "$BACKTITLE" --help-button --help-label "Cancel" --yes-label "Connect" --no-label " Import " --yesno "\n\Z1Connect:\Z0 Connect with your VPN server \n\n\Z1Import:\Z0 import new config from /etc/armbian.vpn" 9 70
response=$? response=$?
if [[ $response = 0 ]]; then if [[ $response = 0 ]]; then
${VPNDIR}vpnclient start >/dev/null 2>&1 ${VPNDIR}vpnclient start >/dev/null 2>&1
# raise devices # raise devices
raise_dev raise_dev
get_numbers get_numbers
echo "ip route add $VPNSERVERIP via $IP dev $ADAPTER" echo "ip route add $VPNSERVERIP via $IP dev $ADAPTER"
echo "ip route del default" echo "ip route del default"
echo "ip route add default via $GW dev vpn_se" echo "ip route add default via $GW dev vpn_se"
read read
fi fi
[[ $response = 1 ]] && vpn_reconfigure [[ $response = 1 ]] && vpn_reconfigure
fi fi
;; ;;
...@@ -859,43 +859,43 @@ unset selection ...@@ -859,43 +859,43 @@ unset selection
# #
"ZSH" ) "ZSH" )
if ! is_package_manager_running; then if ! is_package_manager_running; then
if ! check_if_installed zsh ; then if ! check_if_installed zsh ; then
debconf-apt-progress -- apt-get update debconf-apt-progress -- apt-get update
debconf-apt-progress -- apt-get install -y zsh tmux debconf-apt-progress -- apt-get install -y zsh tmux
fi fi
rm -rf /etc/oh-my-zsh rm -rf /etc/oh-my-zsh
git clone --quiet https://github.com/robbyrussell/oh-my-zsh.git /etc/oh-my-zsh git clone --quiet https://github.com/robbyrussell/oh-my-zsh.git /etc/oh-my-zsh
cp /etc/oh-my-zsh/templates/zshrc.zsh-template /etc/skel/.zshrc cp /etc/oh-my-zsh/templates/zshrc.zsh-template /etc/skel/.zshrc
mkdir -p /etc/skel/.oh-my-zsh/cache mkdir -p /etc/skel/.oh-my-zsh/cache
# change shell for future users # change shell for future users
sed -i "s/^SHELL=.*/SHELL=\/usr\/bin\/zsh/" /etc/default/useradd sed -i "s/^SHELL=.*/SHELL=\/usr\/bin\/zsh/" /etc/default/useradd
# we have common settings # we have common settings
sed -i "s/^export ZSH=.*/export ZSH=\/etc\/oh-my-zsh/" /etc/skel/.zshrc sed -i "s/^export ZSH=.*/export ZSH=\/etc\/oh-my-zsh/" /etc/skel/.zshrc
# user cache # user cache
sed -i "/^export ZSH=.*/a export ZSH_CACHE_DIR=~\/.oh-my-zsh\/cache" /etc/skel/.zshrc sed -i "/^export ZSH=.*/a export ZSH_CACHE_DIR=~\/.oh-my-zsh\/cache" /etc/skel/.zshrc
# define theme # define theme
sed -i 's/^ZSH_THEME=.*/ZSH_THEME="risto"/' /etc/skel/.zshrc sed -i 's/^ZSH_THEME=.*/ZSH_THEME="risto"/' /etc/skel/.zshrc
# define default plugins # define default plugins
sed -i 's/^plugins=.*/plugins=(git git-extras debian tmux screen history extract colorize web-search docker)/' /etc/skel/.zshrc sed -i 's/^plugins=.*/plugins=(git git-extras debian tmux screen history extract colorize web-search docker)/' /etc/skel/.zshrc
# change shell for root # change shell for root
chsh -s $(grep /zsh$ /etc/shells | tail -1) chsh -s $(grep /zsh$ /etc/shells | tail -1)
# copy cache directory
cp -R --attributes-only /etc/skel/.oh-my-zsh /root/.oh-my-zsh
cp /etc/skel/.zshrc /root/.zshrc
# and for selected normal user
add_choose_user
if [ -n "$CHOSEN_USER" ]; then
chsh -s $(grep /zsh$ /etc/shells | tail -1) $CHOSEN_USER
# copy cache directory # copy cache directory
cp -R --attributes-only /etc/skel/.oh-my-zsh /home/$CHOSEN_USER/.oh-my-zsh cp -R --attributes-only /etc/skel/.oh-my-zsh /root/.oh-my-zsh
cp /etc/skel/.zshrc /home/$CHOSEN_USER/.zshrc cp /etc/skel/.zshrc /root/.zshrc
chown -R ${CHOSEN_USER}:${CHOSEN_USER} /home/${CHOSEN_USER}/{.zshrc,.oh-my-zsh} # and for selected normal user
fi add_choose_user
# add a cronjob to update oh-my-zsh once per month if [ -n "$CHOSEN_USER" ]; then
(crontab -l 2>/dev/null; echo "0 0 1 * * cd /etc/oh-my-zsh ; git pull origin master >/dev/null 2>/dev/null") | crontab - chsh -s $(grep /zsh$ /etc/shells | tail -1) $CHOSEN_USER
if [[ -z $scripted ]]; then # copy cache directory
dialog --backtitle "$BACKTITLE" --title "Info" --colors --msgbox "\nYour default shell was switched to: \Z1ZSH\Z0\n\nPlease logout & login from this session!" 9 47 cp -R --attributes-only /etc/skel/.oh-my-zsh /home/$CHOSEN_USER/.oh-my-zsh
fi cp /etc/skel/.zshrc /home/$CHOSEN_USER/.zshrc
chown -R ${CHOSEN_USER}:${CHOSEN_USER} /home/${CHOSEN_USER}/{.zshrc,.oh-my-zsh}
fi
# add a cronjob to update oh-my-zsh once per month
(crontab -l 2>/dev/null; echo "0 0 1 * * cd /etc/oh-my-zsh ; git pull origin master >/dev/null 2>/dev/null") | crontab -
if [[ -z $scripted ]]; then
dialog --backtitle "$BACKTITLE" --title "Info" --colors --msgbox "\nYour default shell was switched to: \Z1ZSH\Z0\n\nPlease logout & login from this session!" 9 47
fi
fi fi
;; ;;
...@@ -943,28 +943,28 @@ unset selection ...@@ -943,28 +943,28 @@ unset selection
unset PACKAGE_LIST unset PACKAGE_LIST
# basic packages # basic packages
check_if_installed linux-u-boot-${BOARD}-${BRANCH} && PACKAGE_LIST+=" linux-u-boot-${BOARD}-${BRANCH}" check_if_installed linux-u-boot-${BOARD}-${BRANCH} && PACKAGE_LIST+=" linux-u-boot-${BOARD}-${BRANCH}"
check_if_installed linux-image-${BRANCH}-${LINUXFAMILY} && PACKAGE_LIST+=" linux-image-${BRANCH}-${LINUXFAMILY}" check_if_installed linux-image-${BRANCH}-${LINUXFAMILY} && PACKAGE_LIST+=" linux-image-${BRANCH}-${LINUXFAMILY}"
check_if_installed linux-dtb-${BRANCH}-${LINUXFAMILY} && PACKAGE_LIST+=" linux-dtb-${BRANCH}-${LINUXFAMILY}" check_if_installed linux-dtb-${BRANCH}-${LINUXFAMILY} && PACKAGE_LIST+=" linux-dtb-${BRANCH}-${LINUXFAMILY}"
check_if_installed linux-headers-${BRANCH}-${LINUXFAMILY} && PACKAGE_LIST+=" linux-headers-${BRANCH}-${LINUXFAMILY}" check_if_installed linux-headers-${BRANCH}-${LINUXFAMILY} && PACKAGE_LIST+=" linux-headers-${BRANCH}-${LINUXFAMILY}"
# new BSP # new BSP
check_if_installed armbian-${LINUXFAMILY} && PACKAGE_LIST+=" armbian-${LINUXFAMILY}" check_if_installed armbian-${LINUXFAMILY} && PACKAGE_LIST+=" armbian-${LINUXFAMILY}"
check_if_installed armbian-${BOARD} && PACKAGE_LIST+=" armbian-${BOARD}" check_if_installed armbian-${BOARD} && PACKAGE_LIST+=" armbian-${BOARD}"
check_if_installed armbian-${DISTROID} && PACKAGE_LIST+=" armbian-${DISTROID}" check_if_installed armbian-${DISTROID} && PACKAGE_LIST+=" armbian-${DISTROID}"
check_if_installed armbian-${DISTROID}-desktop-xfce && PACKAGE_LIST+=" armbian-${DISTROID}-desktop-xfce" check_if_installed armbian-${DISTROID}-desktop-xfce && PACKAGE_LIST+=" armbian-${DISTROID}-desktop-xfce"
check_if_installed armbian-firmware && PACKAGE_LIST+=" armbian-firmware" check_if_installed armbian-firmware && PACKAGE_LIST+=" armbian-firmware"
check_if_installed armbian-firmware-full && PACKAGE_LIST+=" armbian-firmware-full" check_if_installed armbian-firmware-full && PACKAGE_LIST+=" armbian-firmware-full"
local words=( $PACKAGE_LIST ) local words=( $PACKAGE_LIST )
local command="unhold" local command="unhold"
IFS=" " IFS=" "
[[ $1 == "Freeze" ]] && local command="hold" [[ $1 == "Freeze" ]] && local command="hold"
for word in $PACKAGE_LIST; do apt-mark $command $word; done | dialog --backtitle "$BACKTITLE" --title "Packages ${1,,}" --progressbox $((${#words[@]}+2)) 64 for word in $PACKAGE_LIST; do apt-mark $command $word; done | dialog --backtitle "$BACKTITLE" --title "Packages ${1,,}" --progressbox $((${#words[@]}+2)) 64
fi
fi fi
fi
;; ;;
...@@ -1145,9 +1145,9 @@ unset selection ...@@ -1145,9 +1145,9 @@ unset selection
# #
"Bootscript" ) "Bootscript" )
if [[ -f /boot/boot.ini ]]; then if [[ -f /boot/boot.ini ]]; then
dialog --title " Edit boot.ini script " --ok-label "Save" \ dialog --title " Edit boot.ini script " --ok-label "Save" \
--no-collapse --editbox /boot/boot.ini 30 0 2> /boot/boot.ini.out --no-collapse --editbox /boot/boot.ini 30 0 2> /boot/boot.ini.out
[[ $? = 0 ]] && mv /boot/boot.ini.out /boot/boot.ini [[ $? = 0 ]] && mv /boot/boot.ini.out /boot/boot.ini
fi fi
;; ;;
...@@ -1478,13 +1478,13 @@ unset selection ...@@ -1478,13 +1478,13 @@ unset selection
if ! is_package_manager_running; then if ! is_package_manager_running; then
aval_dtbs aval_dtbs
if [[ $exitstatus = 0 ]]; then if [[ $exitstatus = 0 ]]; then
BOX_LENGTH=$((${#TARGET_BOARD}+28)); BOX_LENGTH=$((${#TARGET_BOARD}+28));
dialog --title "Switching board config" --backtitle "$BACKTITLE" --yes-label "Reboot" --no-label "Cancel" --yesno "\nReboot to $TARGET_BOARD settings?" 7 $BOX_LENGTH dialog --title "Switching board config" --backtitle "$BACKTITLE" --yes-label "Reboot" --no-label "Cancel" --yesno "\nReboot to $TARGET_BOARD settings?" 7 $BOX_LENGTH
if [[ $? = 0 ]]; then if [[ $? = 0 ]]; then
sed -i "s/^fdt_file=.*/fdt_file=$TARGET_BOARD/" /boot/armbianEnv.txt 2> /dev/null && grep -q "fdt_file=$TARGET_BOARD" /boot/armbianEnv.txt 2> /dev/null || echo "fdt_file=$TARGET_BOARD" >> /boot/armbianEnv.txt sed -i "s/^fdt_file=.*/fdt_file=$TARGET_BOARD/" /boot/armbianEnv.txt 2> /dev/null && grep -q "fdt_file=$TARGET_BOARD" /boot/armbianEnv.txt 2> /dev/null || echo "fdt_file=$TARGET_BOARD" >> /boot/armbianEnv.txt
[[ "$LINUXFAMILY" = odroidxu4 ]] && sed -i "s/^fdt_file/board_name/" /boot/armbianEnv.txt && sed -i "s/^BOARD_NAME.*/BOARD_NAME=\"Odroid ${TARGET_BOARD^^}\"/" /etc/armbian-release [[ "$LINUXFAMILY" = odroidxu4 ]] && sed -i "s/^fdt_file/board_name/" /boot/armbianEnv.txt && sed -i "s/^BOARD_NAME.*/BOARD_NAME=\"Odroid ${TARGET_BOARD^^}\"/" /etc/armbian-release
reboot; reboot;
fi fi
fi fi
fi fi
;; ;;
......
...@@ -96,13 +96,13 @@ while true; do ...@@ -96,13 +96,13 @@ while true; do
[[ "$LINUXFAMILY" = odroidc* || "$LINUXFAMILY" = odroidn2 && "$BRANCH" = "default" ]] && LIST+=( "Display" "Set the display resolution" ) [[ "$LINUXFAMILY" = odroidc* || "$LINUXFAMILY" = odroidn2 && "$BRANCH" = "default" ]] && LIST+=( "Display" "Set the display resolution" )
# desktop # desktop
if [[ -n $DISPLAY_MANAGER ]]; then if [[ -n $DISPLAY_MANAGER ]]; then
LIST+=( "Desktop" "Disable desktop or change login type" ) LIST+=( "Desktop" "Disable desktop or change login type" )
else else
if [[ -n $DESKTOP_INSTALLED ]]; then if [[ -n $DESKTOP_INSTALLED ]]; then
LIST+=( "Desktop" "Enable desktop" ) LIST+=( "Desktop" "Enable desktop" )
else else
LIST+=( "Default" "Install desktop with browser and extras" ) LIST+=( "Default" "Install desktop with browser and extras" )
fi fi
fi fi
# overlayroot # overlayroot
...@@ -379,32 +379,32 @@ while true; do ...@@ -379,32 +379,32 @@ while true; do
fi fi
if [[ -n $DISPLAY_MANAGER ]]; then if [[ -n $DISPLAY_MANAGER ]]; then
if [[ $(service xrdp status 2> /dev/null | grep -w active) ]]; then if [[ $(service xrdp status 2> /dev/null | grep -w active) ]]; then
LIST+=( "RDP" "Disable remote desktop access from Windows" ) LIST+=( "RDP" "Disable remote desktop access from Windows" )
else else
LIST+=( "RDP" "Enable remote desktop access from Windows" ) LIST+=( "RDP" "Enable remote desktop access from Windows" )
fi fi
if ! check_if_installed thunderbird ; then if ! check_if_installed thunderbird ; then
LIST+=( "Thunderbird" "Install full featured email client" ) LIST+=( "Thunderbird" "Install full featured email client" )
else else
LIST+=( "Thunderbird" "Remove full featured email client" ) LIST+=( "Thunderbird" "Remove full featured email client" )
fi fi
if ! check_if_installed gimp ; then if ! check_if_installed gimp ; then
LIST+=( "Gimp" "Install photo manipulation tool" ) LIST+=( "Gimp" "Install photo manipulation tool" )
else else
LIST+=( "Gimp" "Remove photo manipulation tool" ) LIST+=( "Gimp" "Remove photo manipulation tool" )
fi fi
if ! check_if_installed libreoffice-writer ; then if ! check_if_installed libreoffice-writer ; then
LIST+=( "Writer" "Libreoffice: Writer only" ) LIST+=( "Writer" "Libreoffice: Writer only" )
LIST+=( "Suite" "Libreoffice: Full suite" )
else
if ! check_if_installed libreoffice-base ; then
LIST+=( "Suite" "Libreoffice: Full suite" ) LIST+=( "Suite" "Libreoffice: Full suite" )
else LIST+=( "Libre" "Remove Libre office packages" )
if ! check_if_installed libreoffice-base ; then else
LIST+=( "Suite" "Libreoffice: Full suite" ) LIST+=( "Libre" "Remove Libre office packages" )
LIST+=( "Libre" "Remove Libre office packages" )
else
LIST+=( "Libre" "Remove Libre office packages" )
fi
fi fi
fi
fi fi
# count number of menu items to adjust window sizee # count number of menu items to adjust window sizee
......
...@@ -114,13 +114,13 @@ function check_status ...@@ -114,13 +114,13 @@ function check_status
LIST+=( "Syncthing" "$DESCRIPTION" "$SYNCTHING_STATUS" ) LIST+=( "Syncthing" "$DESCRIPTION" "$SYNCTHING_STATUS" )
# Hass.io # Hass.io
HASS_STATUS="$([[ -f /etc/hassio.json ]] && echo "on" || echo "off" )" HASS_STATUS="$([[ -f /etc/hassio.json ]] && echo "on" || echo "off" )"
alive_port "Home assistant smarthome suite" "8123" alive_port "Home assistant smarthome suite" "8123"
LIST+=( "Hassio" "$DESCRIPTION" "$HASS_STATUS" ) LIST+=( "Hassio" "$DESCRIPTION" "$HASS_STATUS" )
# OpenHab # OpenHab
OPENHAB_STATUS="$([[ -f /usr/bin/openhab-cli ]] && echo "on" || echo "off" )" OPENHAB_STATUS="$([[ -f /usr/bin/openhab-cli ]] && echo "on" || echo "off" )"
alive_port "Openhab2 smarthome suite" "8080" alive_port "Openhab2 smarthome suite" "8080"
LIST+=( "OpenHAB" "$DESCRIPTION" "$OPENHAB_STATUS" ) LIST+=( "OpenHAB" "$DESCRIPTION" "$OPENHAB_STATUS" )
# VPN # VPN
...@@ -196,7 +196,7 @@ function check_status ...@@ -196,7 +196,7 @@ function check_status
if [[ "$DOCKER_STATUS" == "on" ]]; then if [[ "$DOCKER_STATUS" == "on" ]]; then
curl --output /dev/null --silent --head --fail http://localhost/authentication/login/?next= curl --output /dev/null --silent --head --fail http://localhost/authentication/login/?next=
MAYAN_STATUS=$([[ $? -eq 0 ]] && echo "on" || echo "off") MAYAN_STATUS=$([[ $? -eq 0 ]] && echo "on" || echo "off")
else else
MAYAN_STATUS="off" MAYAN_STATUS="off"
fi fi
...@@ -306,22 +306,22 @@ declare -a PACKETS=($1) ...@@ -306,22 +306,22 @@ declare -a PACKETS=($1)
#skupaj=$(apt-get -s -y -qq install $1 | wc -l) #skupaj=$(apt-get -s -y -qq install $1 | wc -l)
skupaj=${#PACKETS[@]} skupaj=${#PACKETS[@]}
while [[ $i -lt $skupaj ]]; do while [[ $i -lt $skupaj ]]; do
procent=$(echo "scale=2;($j/$skupaj)*100"|bc) procent=$(echo "scale=2;($j/$skupaj)*100"|bc)
x=${PACKETS[$i]} x=${PACKETS[$i]}
if [ $(dpkg-query -W -f='${Status}' $x 2>/dev/null | grep -c "ok installed") -eq 0 ]; then if [ $(dpkg-query -W -f='${Status}' $x 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
printf '%.0f\n' $procent | dialog \ printf '%.0f\n' $procent | dialog \
--backtitle "$BACKTITLE" \ --backtitle "$BACKTITLE" \
--title "Installing" \ --title "Installing" \
--gauge "\n$2\n\n$x" 10 70 --gauge "\n$2\n\n$x" 10 70
if [ "$(DEBIAN_FRONTEND=noninteractive apt-get -qq -y install $x >${TEMP_DIR}/install.log 2>&1 || echo 'Installation failed' \ if [ "$(DEBIAN_FRONTEND=noninteractive apt-get -qq -y install $x >${TEMP_DIR}/install.log 2>&1 || echo 'Installation failed' \
| grep 'Installation failed')" != "" ]; then | grep 'Installation failed')" != "" ]; then
echo -e "[\e[0;31m error \x1B[0m] Installation failed" echo -e "[\e[0;31m error \x1B[0m] Installation failed"
tail ${TEMP_DIR}/install.log tail ${TEMP_DIR}/install.log
exit exit
fi fi
fi fi
i=$[$i+1] i=$[$i+1]
j=$[$j+1] j=$[$j+1]
done done
echo "" echo ""
} }
...@@ -335,24 +335,15 @@ alive_port () ...@@ -335,24 +335,15 @@ alive_port ()
# Displays URL to the service $1 on port $2 or just that is active if $3 = boolean $4 = path # Displays URL to the service $1 on port $2 or just that is active if $3 = boolean $4 = path
# #
if [[ -n $(netstat -lnt | awk '$6 == "LISTEN" && $4 ~ ".'$2'"') ]]; then if [[ -n $(netstat -lnt | awk '$6 == "LISTEN" && $4 ~ ".'$2'"') ]]; then
if [[ $3 == boolean ]]; then if [[ $3 == boolean ]]; then
DESCRIPTION="$1 is \Z1active\Z0"; DESCRIPTION="$1 is \Z1active\Z0";
elif [[ $3 == ssl ]]; then
elif [[ $3 == ssl ]]; then
DESCRIPTION="Active on https://${serverIP}:\Z1$2\Z0$4"; DESCRIPTION="Active on https://${serverIP}:\Z1$2\Z0$4";
else
else
DESCRIPTION="Active on http://${serverIP}:\Z1$2\Z0$4"; DESCRIPTION="Active on http://${serverIP}:\Z1$2\Z0$4";
fi fi
else else
DESCRIPTION="$1"; DESCRIPTION="$1";
fi fi
} }
...@@ -553,7 +544,7 @@ install_omv (){ ...@@ -553,7 +544,7 @@ install_omv (){
# Install OpenMediaVault on Debian # Install OpenMediaVault on Debian
# #
if [ -f /etc/armbian-release ]; then if [ -f /etc/armbian-release ]; then
. /etc/armbian-release . /etc/armbian-release
fi fi
# Don't allow installation on Ubuntu # Don't allow installation on Ubuntu
...@@ -578,7 +569,7 @@ fancy_wget "$wgeturl" "-O ${TEMP_DIR}/omv_install.sh" ...@@ -578,7 +569,7 @@ fancy_wget "$wgeturl" "-O ${TEMP_DIR}/omv_install.sh"
# Remove Crony on Stretch since OMV4 depends on NTP # Remove Crony on Stretch since OMV4 depends on NTP
if [[ "$distribution" == "stretch" ]]; then if [[ "$distribution" == "stretch" ]]; then
apt-get -y -qq remove chrony apt-get -y -qq remove chrony
fi fi
# Execute install script # Execute install script
...@@ -639,8 +630,8 @@ if [[ "$family" == "Ubuntu" ]]; then ...@@ -639,8 +630,8 @@ if [[ "$family" == "Ubuntu" ]]; then
debconf-apt-progress -- apt-get -y install libssl-doc libssl1.0.0 zlib1g-dev tvheadend xmltv-util debconf-apt-progress -- apt-get -y install libssl-doc libssl1.0.0 zlib1g-dev tvheadend xmltv-util
else else
if [ ! -f /etc/apt/sources.list.d/tvheadend.list ]; then if [ ! -f /etc/apt/sources.list.d/tvheadend.list ]; then
echo "deb https://www.deb-multimedia.org ${distribution} main non-free" >> /etc/apt/sources.list.d/tvheadend.list echo "deb https://www.deb-multimedia.org ${distribution} main non-free" >> /etc/apt/sources.list.d/tvheadend.list
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 5C808C2B65558117 >/dev/null 2>&1 apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 5C808C2B65558117 >/dev/null 2>&1
fi fi
URL="https://security.debian.org/debian-security/pool/updates/main/o/openssl/libssl1.0.0_1.0.1t-1+deb8u9_"$(dpkg --print-architecture)".deb" URL="https://security.debian.org/debian-security/pool/updates/main/o/openssl/libssl1.0.0_1.0.1t-1+deb8u9_"$(dpkg --print-architecture)".deb"
fancy_wget "$URL" "-O ${TEMP_DIR}/package.deb" fancy_wget "$URL" "-O ${TEMP_DIR}/package.deb"
...@@ -891,8 +882,8 @@ systemctl start syncthing@${CHOSEN_USER}.service >/dev/null 2>&1 ...@@ -891,8 +882,8 @@ systemctl start syncthing@${CHOSEN_USER}.service >/dev/null 2>&1
# wait until config file is created # wait until config file is created
while : while :
do do
if [[ -f /home/${CHOSEN_USER}/.config/syncthing/config.xml ]]; then break; fi if [[ -f /home/${CHOSEN_USER}/.config/syncthing/config.xml ]]; then break; fi
sleep 1 sleep 1
done done
# change to server IP # change to server IP
sed -i "s/127.0.0.1/${serverIP}/" /home/${CHOSEN_USER}/.config/syncthing/config.xml sed -i "s/127.0.0.1/${serverIP}/" /home/${CHOSEN_USER}/.config/syncthing/config.xml
...@@ -922,8 +913,8 @@ install_emby_server () ...@@ -922,8 +913,8 @@ install_emby_server ()
# #
# Emby server # Emby server
# #
ARCH=$(dpkg --print-architecture) ARCH=$(dpkg --print-architecture)
URL=$(curl -s https://api.github.com/repos/MediaBrowser/Emby.Releases/releases/latest | grep "/emby-server-deb.*${ARCH}.deb" | cut -d : -f 2,3 | tr -d \") URL=$(curl -s https://api.github.com/repos/MediaBrowser/Emby.Releases/releases/latest | grep "/emby-server-deb.*${ARCH}.deb" | cut -d : -f 2,3 | tr -d \")
fancy_wget "$URL" "-O ${TEMP_DIR}/emby.deb" fancy_wget "$URL" "-O ${TEMP_DIR}/emby.deb"
dpkg -i ${TEMP_DIR}/emby.deb >/dev/null 2>&1 dpkg -i ${TEMP_DIR}/emby.deb >/dev/null 2>&1
apt-get -yy -f install apt-get -yy -f install
...@@ -1093,10 +1084,10 @@ install_packet "debconf-utils unzip build-essential html2text apt-transport-http ...@@ -1093,10 +1084,10 @@ install_packet "debconf-utils unzip build-essential html2text apt-transport-http
URL=$(wget -q $PREFIX -O - | html2text | grep rtm | awk ' { print $(NF) }' | tail -1) URL=$(wget -q $PREFIX -O - | html2text | grep rtm | awk ' { print $(NF) }' | tail -1)
SUFIX="${URL/-tree/}" SUFIX="${URL/-tree/}"
if [ "$(dpkg --print-architecture | grep armhf)" != "" ]; then if [ "$(dpkg --print-architecture | grep armhf)" != "" ]; then
DLURL=$PREFIX$URL"/Linux/SoftEther_VPN_Client/32bit_-_ARM_EABI/softether-vpnclient-$SUFIX-linux-arm_eabi-32bit.tar.gz" DLURL=$PREFIX$URL"/Linux/SoftEther_VPN_Client/32bit_-_ARM_EABI/softether-vpnclient-$SUFIX-linux-arm_eabi-32bit.tar.gz"
else else
install_packet "gcc-multilib" "Install libraries" install_packet "gcc-multilib" "Install libraries"
DLURL=$PREFIX$URL"/Linux/SoftEther_VPN_Client/32bit_-_Intel_x86/softether-vpnclient-$SUFIX-linux-x86-32bit.tar.gz" DLURL=$PREFIX$URL"/Linux/SoftEther_VPN_Client/32bit_-_Intel_x86/softether-vpnclient-$SUFIX-linux-x86-32bit.tar.gz"
fi fi
wget -q $DLURL -O - | tar -xz wget -q $DLURL -O - | tar -xz
cd vpnclient cd vpnclient
...@@ -1209,7 +1200,7 @@ packets="amavisd-new spamassassin clamav clamav-daemon unzip bzip2 arj p7zip unr ...@@ -1209,7 +1200,7 @@ packets="amavisd-new spamassassin clamav clamav-daemon unzip bzip2 arj p7zip unr
cabextract apt-listchanges libnet-ldap-perl libauthen-sasl-perl clamav-docs daemon libio-string-perl libio-socket-ssl-perl \ cabextract apt-listchanges libnet-ldap-perl libauthen-sasl-perl clamav-docs daemon libio-string-perl libio-socket-ssl-perl \
libnet-ident-perl zip libnet-dns-perl postgrey" libnet-ident-perl zip libnet-dns-perl postgrey"
if [[ $distribution != "bionic" ]] && [[ $distribution != "buster" ]]; then if [[ $distribution != "bionic" ]] && [[ $distribution != "buster" ]]; then
packets=$packets" zoo" packets=$packets" zoo"
fi fi
if [[ $distribution != "buster" ]]; then packets=$packets" ripole"; fi if [[ $distribution != "buster" ]]; then packets=$packets" ripole"; fi
install_packet "$packets" "amavisd, spamassassin, clamav" install_packet "$packets" "amavisd, spamassassin, clamav"
...@@ -1251,15 +1242,15 @@ install_phpmyadmin () ...@@ -1251,15 +1242,15 @@ install_phpmyadmin ()
# Phpmyadmin unattended installation # Phpmyadmin unattended installation
# #
if [[ "$family" != "Ubuntu" ]]; then if [[ "$family" != "Ubuntu" ]]; then
DEBIAN_FRONTEND=noninteractive debconf-apt-progress -- apt-get -y install phpmyadmin DEBIAN_FRONTEND=noninteractive debconf-apt-progress -- apt-get -y install phpmyadmin
else else
debconf-set-selections <<< "phpmyadmin phpmyadmin/internal/skip-preseed boolean true" debconf-set-selections <<< "phpmyadmin phpmyadmin/internal/skip-preseed boolean true"
debconf-set-selections <<< "phpmyadmin phpmyadmin/reconfigure-webserver multiselect true" debconf-set-selections <<< "phpmyadmin phpmyadmin/reconfigure-webserver multiselect true"
debconf-set-selections <<< "phpmyadmin phpmyadmin/dbconfig-install boolean false" debconf-set-selections <<< "phpmyadmin phpmyadmin/dbconfig-install boolean false"
echo "phpmyadmin phpmyadmin/internal/skip-preseed boolean true" | debconf-set-selections echo "phpmyadmin phpmyadmin/internal/skip-preseed boolean true" | debconf-set-selections
echo "phpmyadmin phpmyadmin/reconfigure-webserver multiselect" | debconf-set-selections echo "phpmyadmin phpmyadmin/reconfigure-webserver multiselect" | debconf-set-selections
echo "phpmyadmin phpmyadmin/dbconfig-install boolean false" | debconf-set-selections echo "phpmyadmin phpmyadmin/dbconfig-install boolean false" | debconf-set-selections
debconf-apt-progress -- apt-get install -y phpmyadmin debconf-apt-progress -- apt-get install -y phpmyadmin
fi fi
# Apache2 needs additional hack # Apache2 needs additional hack
WWW_RECONFIG=$(expect -c " WWW_RECONFIG=$(expect -c "
...@@ -1322,22 +1313,22 @@ EOT ...@@ -1322,22 +1313,22 @@ EOT
a2enmod actions proxy_fcgi setenvif fastcgi alias httpoxy suexec rewrite ssl actions include dav_fs dav auth_digest cgi headers >/dev/null 2>&1 a2enmod actions proxy_fcgi setenvif fastcgi alias httpoxy suexec rewrite ssl actions include dav_fs dav auth_digest cgi headers >/dev/null 2>&1
case $distribution in case $distribution in
jessie) jessie)
a2enconf php5-fpm >/dev/null 2>&1 a2enconf php5-fpm >/dev/null 2>&1
;; ;;
xenial) xenial)
a2enconf php7.0-fpm >/dev/null 2>&1 a2enconf php7.0-fpm >/dev/null 2>&1
;; ;;
stretch) stretch)
a2enconf php7.0-fpm >/dev/null 2>&1 a2enconf php7.0-fpm >/dev/null 2>&1
;; ;;
bionic) bionic)
a2enconf php7.2-fpm >/dev/null 2>&1 a2enconf php7.2-fpm >/dev/null 2>&1
;; ;;
buster) buster)
a2enconf php7.3-fpm >/dev/null 2>&1 a2enconf php7.3-fpm >/dev/null 2>&1
;; ;;
esac esac
service apache2 restart >> /dev/null service apache2 restart >> /dev/null
} }
...@@ -1374,37 +1365,37 @@ local temp="pkg_${distribution}" ...@@ -1374,37 +1365,37 @@ local temp="pkg_${distribution}"
install_packet "${pkg} ${!temp}" "Nginx for $family $distribution" install_packet "${pkg} ${!temp}" "Nginx for $family $distribution"
case $distribution in case $distribution in
jessie) jessie)
phpenmod mcrypt mbstring phpenmod mcrypt mbstring
debconf-apt-progress -- apt-get install -y python-certbot -t jessie-backports debconf-apt-progress -- apt-get install -y python-certbot -t jessie-backports
service php5-fpm reload >> /dev/null service php5-fpm reload >> /dev/null
;; ;;
xenial) xenial)
phpenmod mcrypt mbstring phpenmod mcrypt mbstring
tz=$(cat /etc/timezone | sed 's/\//\\\//g') tz=$(cat /etc/timezone | sed 's/\//\\\//g')
sed -i "s/^cgi.fix_pathinfo=.*/cgi.fix_pathinfo=0/" /etc/php/7.0/fpm/php.ini sed -i "s/^cgi.fix_pathinfo=.*/cgi.fix_pathinfo=0/" /etc/php/7.0/fpm/php.ini
sed -i "s/^date.timezone=.*/date.timezone=""$tz""/" /etc/php/7.0/fpm/php.ini sed -i "s/^date.timezone=.*/date.timezone=""$tz""/" /etc/php/7.0/fpm/php.ini
service php7.0-fpm reload >> /dev/null service php7.0-fpm reload >> /dev/null
;; ;;
stretch) stretch)
tz=$(cat /etc/timezone | sed 's/\//\\\//g') tz=$(cat /etc/timezone | sed 's/\//\\\//g')
sed -i "s/^cgi.fix_pathinfo=.*/cgi.fix_pathinfo=0/" /etc/php/7.0/fpm/php.ini sed -i "s/^cgi.fix_pathinfo=.*/cgi.fix_pathinfo=0/" /etc/php/7.0/fpm/php.ini
sed -i "s/^date.timezone=.*/date.timezone=""$tz""/" /etc/php/7.0/fpm/php.ini sed -i "s/^date.timezone=.*/date.timezone=""$tz""/" /etc/php/7.0/fpm/php.ini
service php7.0-fpm reload >> /dev/null service php7.0-fpm reload >> /dev/null
phpenmod mcrypt mbstring phpenmod mcrypt mbstring
;; ;;
bionic) bionic)
tz=$(cat /etc/timezone | sed 's/\//\\\//g') tz=$(cat /etc/timezone | sed 's/\//\\\//g')
sed -i "s/^cgi.fix_pathinfo=.*/cgi.fix_pathinfo=0/" /etc/php/7.2/fpm/php.ini sed -i "s/^cgi.fix_pathinfo=.*/cgi.fix_pathinfo=0/" /etc/php/7.2/fpm/php.ini
sed -i "s/^date.timezone=.*/date.timezone=""$tz""/" /etc/php/7.2/fpm/php.ini sed -i "s/^date.timezone=.*/date.timezone=""$tz""/" /etc/php/7.2/fpm/php.ini
service php7.2-fpm reload >> /dev/null service php7.2-fpm reload >> /dev/null
phpenmod mbstring phpenmod mbstring
;; ;;
buster) buster)
tz=$(cat /etc/timezone | sed 's/\//\\\//g') tz=$(cat /etc/timezone | sed 's/\//\\\//g')
sed -i "s/^cgi.fix_pathinfo=.*/cgi.fix_pathinfo=0/" /etc/php/7.3/fpm/php.ini sed -i "s/^cgi.fix_pathinfo=.*/cgi.fix_pathinfo=0/" /etc/php/7.3/fpm/php.ini
sed -i "s/^date.timezone=.*/date.timezone=""$tz""/" /etc/php/7.3/fpm/php.ini sed -i "s/^date.timezone=.*/date.timezone=""$tz""/" /etc/php/7.3/fpm/php.ini
service php7.3-fpm reload >> /dev/null service php7.3-fpm reload >> /dev/null
phpenmod mbstring phpenmod mbstring
;; ;;
esac esac
...@@ -1568,10 +1559,10 @@ cd ${TEMP_DIR}/ispconfig3_install/install/ ...@@ -1568,10 +1559,10 @@ cd ${TEMP_DIR}/ispconfig3_install/install/
php -q install.php --autoinstall=${TEMP_DIR}/isp.conf.php &>> /var/log/ispconfig_config.log php -q install.php --autoinstall=${TEMP_DIR}/isp.conf.php &>> /var/log/ispconfig_config.log
dialog --colors --backtitle "$BACKTITLE" --no-collapse --title " Auto updating SSL certificate " --clear --yesno "\nDo you want to secure ISPConfig control panel and all services with free Let's Encrypt SSL certificate?" 8 80 dialog --colors --backtitle "$BACKTITLE" --no-collapse --title " Auto updating SSL certificate " --clear --yesno "\nDo you want to secure ISPConfig control panel and all services with free Let's Encrypt SSL certificate?" 8 80
if [[ $? == 0 ]]; then if [[ $? == 0 ]]; then
dialog --colors --backtitle "$BACKTITLE" --no-collapse --title " Instructions " --clear --msgbox "\n1. Access admin panel with your browser: \Z1https://$serverIP:8080\Z0\n\nUsername: \Z1admin\Z0\nPassword: \Z11234\Z0 \n\n\n2. Go to Sites > Website > \Z1Add new website\Z0\n\nDomain: \Z1$(hostname -f)\Z0\nAuto-Subdomain: \Z1None\Z0\nSSL: \Z1enable\Z0\nLet's Encrypt SSL: \Z1enable\Z0\n\n\n3. Go to Tools > \Z1Password and language\Z0\n\nChange ISPConfig control panel password.\n\nSave and Logout. \n\n\n4. Wait until SSL is not working here: \Z1https://$(hostname -f)\Z0 \n\nIt can take up to a few minutes.\n\n\n5. Proceed with install (\Z1Press ENTER\Z0):" 33 80 dialog --colors --backtitle "$BACKTITLE" --no-collapse --title " Instructions " --clear --msgbox "\n1. Access admin panel with your browser: \Z1https://$serverIP:8080\Z0\n\nUsername: \Z1admin\Z0\nPassword: \Z11234\Z0 \n\n\n2. Go to Sites > Website > \Z1Add new website\Z0\n\nDomain: \Z1$(hostname -f)\Z0\nAuto-Subdomain: \Z1None\Z0\nSSL: \Z1enable\Z0\nLet's Encrypt SSL: \Z1enable\Z0\n\n\n3. Go to Tools > \Z1Password and language\Z0\n\nChange ISPConfig control panel password.\n\nSave and Logout. \n\n\n4. Wait until SSL is not working here: \Z1https://$(hostname -f)\Z0 \n\nIt can take up to a few minutes.\n\n\n5. Proceed with install (\Z1Press ENTER\Z0):" 33 80
curl -sSL https://github.com/ahrasis/LE4ISPC/archive/master.zip > master.zip 2> /dev/null curl -sSL https://github.com/ahrasis/LE4ISPC/archive/master.zip > master.zip 2> /dev/null
unzip -qq master.zip unzip -qq master.zip
bash LE4ISPC-master/${server}/le4ispc.sh 2>&1 bash LE4ISPC-master/${server}/le4ispc.sh 2>&1
fi fi
} }
...@@ -1714,10 +1705,10 @@ if ! is_package_manager_running; then ...@@ -1714,10 +1705,10 @@ if ! is_package_manager_running; then
selection=${selection//Hassio/} selection=${selection//Hassio/}
fi fi
if [[ "$selection" == *OpenHAB* && "$OPENHAB_STATUS" != "on" ]]; then if [[ "$selection" == *OpenHAB* && "$OPENHAB_STATUS" != "on" ]]; then
install_openhab install_openhab
selection=${selection//OpenHAB/} selection=${selection//OpenHAB/}
fi fi
if [[ "$selection" == *server* && "$VPN_SERVER_STATUS" != "on" ]]; then if [[ "$selection" == *server* && "$VPN_SERVER_STATUS" != "on" ]]; then
install_vpn_server install_vpn_server
...@@ -1728,9 +1719,9 @@ if ! is_package_manager_running; then ...@@ -1728,9 +1719,9 @@ if ! is_package_manager_running; then
install_vpn_client install_vpn_client
selection=${selection//\"VPN client\"/} selection=${selection//\"VPN client\"/}
fi fi
if [[ "$selection" == *NCP* && "$NCP_STATUS" != "on" ]]; then if [[ "$selection" == *NCP* && "$NCP_STATUS" != "on" ]]; then
install_ncp install_ncp
selection=${selection//NCP/} selection=${selection//NCP/}
fi fi
if [[ "$selection" == *OMV* && "$OMV_STATUS" != "on" ]]; then if [[ "$selection" == *OMV* && "$OMV_STATUS" != "on" ]]; then
......
...@@ -4,53 +4,52 @@ vflag= ...@@ -4,53 +4,52 @@ vflag=
cflag= cflag=
if (( $# < 1 )) if (( $# < 1 ))
then then
### URL of your XML file ### URL of your XML file
wget -qO - "http://xml.tv.data" wget -qO - "http://xml.tv.data"
exit 0 exit 0
fi fi
for arg for arg
do do
delim="" delim=""
case "$arg" in case "$arg" in
#translate --gnu-long-options to -g (short options) #translate --gnu-long-options to -g (short options)
--description) args="${args}-d ";; --description) args="${args}-d ";;
--version) args="${args}-v ";; --version) args="${args}-v ";;
--capabilities) args="${args}-c ";; --capabilities) args="${args}-c ";;
#pass through anything else #pass through anything else
*) [[ "${arg:0:1}" == "-" ]] || delim="\"" *) [[ "${arg:0:1}" == "-" ]] || delim="\""
args="${args}${delim}${arg}${delim} ";; args="${args}${delim}${arg}${delim} ";;
esac esac
done done
#Reset the positional parameters to the short options #Reset the positional parameters to the short options
eval set -- $args eval set -- $args
while getopts "dvc" option while getopts "dvc" option
do do
case $option in case $option in
d) dflag=1;; d) dflag=1;;
v) vflag=1;; v) vflag=1;;
c) cflag=1;; c) cflag=1;;
\?) printf "unknown option: -%s\n" $OPTARG \?) printf "unknown option: -%s\n" $OPTARG
printf "Usage: %s: [--description] [--version] [--capabilities] \n" $(basename $0) printf "Usage: %s: [--description] [--version] [--capabilities] \n" $(basename $0)
exit 2 exit 2
;; ;;
esac >&2 esac >&2
done done
if [ "$dflag" ] if [ "$dflag" ]
then then
printf "tv_grag_file is a simple grabber that just read the ~/.xmltv/tv_grab_file.xmltv file\n" printf "tv_grag_file is a simple grabber that just read the ~/.xmltv/tv_grab_file.xmltv file\n"
fi fi
if [ "$vflag" ] if [ "$vflag" ]
then then
printf "0.1\n" printf "0.1\n"
fi fi
if [ "$cflag" ] if [ "$cflag" ]
then then
printf "baseline\n" printf "baseline\n"
fi fi
exit 0 exit 0
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment