Commit 2039b519 authored by Igor Pecovnik's avatar Igor Pecovnik
Browse files

main software menu rfc

parent a1213e8b
......@@ -36,8 +36,8 @@ function main(){
KERNELID=$(uname -r)
[[ -z "${ARMBIAN// }" ]] && ARMBIAN="$DISTRO $DISTROID"
DEFAULT_ADAPTER=$(ip -4 route ls | grep default | grep -Po '(?<=dev )(\S+)')
local ipadd=$(ip -4 addr show dev $DEFAULT_ADAPTER | awk '/inet/ {print $2}' | cut -d'/' -f1)
BACKTITLE="Configuration utility, $ARMBIAN, $ipadd"
LOCALIPADD=$(ip -4 addr show dev $DEFAULT_ADAPTER | awk '/inet/ {print $2}' | cut -d'/' -f1)
BACKTITLE="Configuration utility, $ARMBIAN, $LOCALIPADD"
TITLE="$BOARD_NAME "
[[ -z "${DEFAULT_ADAPTER// }" ]] && DEFAULT_ADAPTER="lo"
OVERLAYDIR="/boot/dtb/overlay";
......
......@@ -11,7 +11,8 @@
# choose_webserver
# server_conf
# install_packet
# check_port
# alive_port
# alive_process
# install_basic
# create_ispconfig_configuration
# install_cups
......@@ -78,30 +79,39 @@ export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
function check_status
{
#
# Check if service is already installed
# Check if service is already installed and show it's status
#
dialog --backtitle "$BACKTITLE" --title "Please wait" --infobox "\nLoading install info ... " 5 28
LIST=()
LIST_CONST=3
# Samba
SAMBA_STATUS="$(check_if_installed samba && echo "on" || echo "off" )"
LIST+=( "Samba" "Windows compatible file sharing" "$SAMBA_STATUS" )
# cups
alive_port "Windows compatible file sharing" "445" "boolean"
LIST+=( "Samba" "$DESCRIPTION" "$SAMBA_STATUS" )
# CUPS
CUPS_STATUS="$(check_if_installed cups && echo "on" || echo "off" )"
LIST+=( "CUPS" "Common UNIX Printing System (CUPS)" "$CUPS_STATUS" )
# tvheadend
if [[ "$family" == "Ubuntu" ]]; then
TVHEADEND_STATUS="$(check_if_installed tvheadend && echo "on" || echo "off" )"
LIST+=( "TV headend" "TV streaming / proxy" "$TVHEADEND_STATUS" )
fi
# synthing
alive_port "Common UNIX Printing System (CUPS)" "631" "boolean"
LIST+=( "CUPS" "$DESCRIPTION" "$CUPS_STATUS" )
# TV headend
TVHEADEND_STATUS="$(check_if_installed tvheadend && echo "on" || echo "off" )"
alive_port "TV streaming server" "9981"
LIST+=( "TV headend" "$DESCRIPTION" "$TVHEADEND_STATUS" )
# Synthing
SYNCTHING_STATUS="$([[ -d /usr/bin/syncthing ]] && echo "on" || echo "off" )"
LIST+=( "Syncthing" "Personal cloud @syncthing.net" "$SYNCTHING_STATUS" )
alive_port "Personal cloud @syncthing.net" "8384" "boolean"
LIST+=( "Syncthing" "$DESCRIPTION" "$SYNCTHING_STATUS" )
# Exagear
if [[ "$(check_if_installed xserver-xorg && echo "on")" == "on" && "$family" == "Ubuntu" ]]; then
EXAGEAR_STATUS="$(check_if_installed exagear-armbian && echo "on" || echo "off" )"
LIST+=( "ExaGear" "32bit x86 Linux/Windows emulator trial" "$EXAGEAR_STATUS" )
fi
if [[ "$(dpkg --print-architecture)" == "armhf" || "$(dpkg --print-architecture)" == "amd64" ]]; then
LIST_CONST=2
# vpn server
......@@ -111,30 +121,48 @@ if [[ "$(dpkg --print-architecture)" == "armhf" || "$(dpkg --print-architecture)
VPN_CLIENT_STATUS="$([[ -d /usr/local/vpnclient ]] && echo "on" || echo "off" )"
LIST+=( "VPN client" "Softether VPN client" "$VPN_CLIENT_STATUS" )
fi
# OMV
OMV_STATUS="$(check_if_installed openmediavault && echo "on" || echo "off" )"
[[ "$family" != "Ubuntu" ]] && LIST+=( "OMV" "OpenMediaVault NAS solution" "$OMV_STATUS" ) && LIST_CONST=3
# Plex
# Plex media server
PLEX_STATUS="$((check_if_installed plexmediaserver || check_if_installed plexmediaserver-installer) && echo "on" || echo "off" )"
LIST+=( "Plex" "Plex media server" "$PLEX_STATUS" )
alive_port "Plex media server" "32400"
LIST+=( "Plex" "$DESCRIPTION" "$PLEX_STATUS" )
# Radarr
RADARR_STATUS="$([[ -d /opt/Radarr ]] && echo "on" || echo "off" )"
LIST+=( "Radarr" "Automatically downloading movies" "$RADARR_STATUS" )
alive_port "Movies downloading server" "7878"
LIST+=( "Radarr" "$DESCRIPTION" "$RADARR_STATUS" )
# Sonarr
SONARR_STATUS="$([[ -d /opt/NzbDrone ]] && echo "on" || echo "off" )"
LIST+=( "Sonarr" "Automatically downloading TV shows" "$SONARR_STATUS" )
alive_port "TV shows downloading server" "8989"
LIST+=( "Sonarr" "$DESCRIPTION" "$SONARR_STATUS" )
# MINIdlna
MINIDLNA_STATUS="$(check_if_installed minidlna && echo "on" || echo "off" )"
LIST+=( "Minidlna" "Lightweight DLNA/UPnP-AV server" "$MINIDLNA_STATUS" )
alive_port "Lightweight DLNA/UPnP-AV server" "8200" "boolean"
LIST+=( "Minidlna" "$DESCRIPTION" "$MINIDLNA_STATUS" )
# Pi hole
PI_HOLE_STATUS="$([[ -d /etc/pihole ]] && echo "on" || echo "off" )"
LIST+=( "Pi hole" "Ad blocker" "$PI_HOLE_STATUS" )
alive_process "Ad blocker" "pihole-FTL"
LIST+=( "Pi hole" "$DESCRIPTION" "$PI_HOLE_STATUS" )
# Transmission
TRANSMISSION_STATUS="$(check_if_installed transmission-daemon && echo "on" || echo "off" )"
LIST+=( "Transmission" "Torrent downloading" "$TRANSMISSION_STATUS" )
alive_port "Torrent download server" "9091" "boolean"
LIST+=( "Transmission" "$DESCRIPTION" "$TRANSMISSION_STATUS" )
# UrBackup
URBACKUP_STATUS="$((check_if_installed urbackup-server || check_if_installed urbackup-server-dbg) && echo "on" || echo "off" )"
LIST+=( "UrBackup" "Open Source client/server backup system" "$URBACKUP_STATUS" )
alive_port "Client/server backup system" "51413" "boolean"
LIST+=( "UrBackup" "$DESCRIPTION" "$URBACKUP_STATUS" )
# ISPconfig
ISPCONFIG_STATUS="$([[ -d /usr/local/ispconfig ]] && echo "on" || echo "off" )"
LIST+=( "ISPConfig" "SMTP mail, IMAP, POP3 & LAMP/LEMP web server" "$ISPCONFIG_STATUS" )
......@@ -231,24 +259,40 @@ echo ""
}
alive_port ()
{
#
# Displays URL to the service $1 on port $2 or just that is active if $3 = boolean
#
DEFAULT_ADAPTER=$(ip -4 route ls | grep default | grep -Po '(?<=dev )(\S+)')
LOCALIPADD=$(ip -4 addr show dev $DEFAULT_ADAPTER | awk '/inet/ {print $2}' | cut -d'/' -f1)
if [[ -n $(netstat -lnt | awk '$6 == "LISTEN" && $4 ~ ".'$2'"') ]]; then
if [[ $3 == boolean ]]; then
DESCRIPTION="$1 is \Z1active\Z0";
else
DESCRIPTION="Active on http://${LOCALIPADD}:\Z1$2\Z0";
fi
else
DESCRIPTION="$1";
fi
}
check_port ()
alive_process ()
{
#
# Display warning with black background if service $2 is not running on a port $1
# check if process name $2 is running. Display it's name $1 or $1 is active if active
#
temp_rc=$(mktemp)
cat <<-'EOF' > $temp_rc
screen_color = (BLACK,BLACK,ON)
EOF
[[ -z $(netstat -lnt | awk '$6 == "LISTEN" && $4 ~ ".'$1'"') ]] && DIALOGRC=$temp_rc dialog --colors --no-shadow --backtitle \
"$BACKTITLE" --title " \Z1Warning\Z0 " --msgbox "\nThere is no sign of service $2 on port $1" 7 $((41+${#2}+${#1}))
if pgrep -x "$2" > /dev/null 2>&1; then DESCRIPTION="$1 is \Z1active\Z0"; else DESCRIPTION="$1"; fi
}
install_basic (){
#
# Set hostname, FQDN, add to sources list
......@@ -555,7 +599,6 @@ echo "* * * * * root for i in \`pgrep \"ftpd|nfsiod|smbd|afpd|cnid\"\` ; do ioni
chmod 600 /etc/cron.d/make_nas_processes_faster
/usr/sbin/omv-initsystem
check_port 80 "OMV web"
}
......@@ -1361,7 +1404,7 @@ while true; do
check_status
LISTLENGHT="$((${#LIST[@]}/2))"
exec 3>&1
selection=$(dialog --backtitle "$BACKTITLE" --title "Installing to $family $distribution" --clear --cancel-label \
selection=$(dialog --backtitle "$BACKTITLE" --title "Installing to $family $distribution" --colors --clear --cancel-label \
"Exit" --checklist "\nChoose what you want to install:\n " $(($LISTLENGHT+$LIST_CONST)) 70 15 "${LIST[@]}" 2>&1 1>&3)
exit_status=$?
exec 3>&-
......@@ -1374,25 +1417,27 @@ while true; do
# cycle trought all install options
i=0
while [ "$i" -lt "$LISTLENGHT" ]; do
if [[ "$selection" == *Samba* && "$SAMBA_STATUS" != "on" ]]; then
install_samba
check_port 445 "Samba"
selection=${selection//Samba/}
fi
if [[ "$selection" == *CUPS* && "$CUPS_STATUS" != "on" ]]; then
install_cups
check_port 631 "CUPS"
selection=${selection//CUPS/}
fi
if [[ "$selection" == *headend* && "$TVHEADEND_STATUS" != "on" ]]; then
install_tvheadend
selection=${selection//\"TV headend\"/}
fi
if [[ "$selection" == *Minidlna* && "$MINIDLNA_STATUS" != "on" ]]; then
install_packet "minidlna" "Install lightweight DLNA/UPnP-AV server"
check_port 8200 "minidlna"
selection=${selection//Minidlna/}
fi
if [[ "$selection" == *ISPConfig* && "$ISPCONFIG_STATUS" != "on" ]]; then
......@@ -1412,62 +1457,61 @@ while true; do
install_Jailkit; install_Fail2BanDovecot; install_Fail2BanRulesDovecot;
install_ISPConfig
read -n 1 -s -p "Press any key to continue"
selection=${selection//ISPConfig/}
fi
if [[ "$selection" == *Syncthing* && "$SYNCTHING_STATUS" != "on" ]]; then
install_syncthing
check_port 8384 "Syncthing"
read -n 1 -s -p "Press any key to continue"
selection=${selection//Syncthing/}
fi
if [[ "$selection" == *ExaGear* && "$EXAGEAR_STATUS" != "on" ]]; then
debconf-apt-progress -- apt-get update
debconf-apt-progress -- apt-get -y install exagear-armbian exagear-desktop exagear-dsound-server exagear-guest-ubuntu-1604
selection=${selection//ExaGear/}
fi
if [[ "$selection" == *server* && "$VPN_SERVER_STATUS" != "on" ]]; then
install_vpn_server
read -n 1 -s -p "Press any key to continue"
selection=${selection//\"VPN server\"/}
fi
if [[ "$selection" == *client* && "$VPN_CLIENT_STATUS" != "on" ]]; then
install_vpn_client
read -n 1 -s -p "Press any key to continue"
selection=${selection//\"VPN client\"/}
fi
if [[ "$selection" == *OMV* && "$OMV_STATUS" != "on" ]]; then
install_omv
read -n 1 -s -p "Press any key to continue"
selection=${selection//OMV/}
fi
if [[ "$selection" == *Plex* && "$PLEX_STATUS" != "on" ]]; then
install_plex_media_server
sleep 2
check_port 32400 "Plex Media server"
selection=${selection//Plex/}
fi
if [[ "$selection" == *Radarr* && "$RADARR_STATUS" != "on" ]]; then
install_radarr
sleep 2
check_port 7878 "Radarr movie downloader"
selection=${selection//Radarr/}
fi
if [[ "$selection" == *Sonarr* && "$SONARR_STATUS" != "on" ]]; then
install_sonarr
sleep 2
check_port 8989 "Sonarr movie downloader"
selection=${selection//Sonarr/}
fi
if [[ "$selection" == *hole* && "$PI_HOLE_STATUS" != "on" ]]; then
curl -L "https://install.pi-hole.net" | bash
read -n 1 -s -p "Press any key to continue"
selection=${selection//\"Pi hole\"/}
fi
if [[ "$selection" == *Transmission* && "$TRANSMISSION_STATUS" != "on" ]]; then
install_transmission
check_port 9091 transmission
dialog --title "Seed Armbian torrents" --backtitle "$BACKTITLE" --yes-label "Yes" --no-label "Cancel" --yesno "\n\
Do you want to help community and seed armbian torrent files? It will ensure faster download for everyone. We need around 50Gb of your space." 10 44
selection=${selection//Transmission/}
dialog --title "Seed Armbian torrents" --backtitle "$BACKTITLE" --yes-label "Yes" --no-label "Cancel" --yesno "\
\nDo you want to help community and seed armbian torrent files? It will ensure faster download for everyone.\
\n\nWe need around 80Gb of your space." 11 44
if [[ $? = 0 ]]; then
install_transmission_seed_armbian_torrents
fi
......@@ -1475,13 +1519,13 @@ while true; do
if [[ "$selection" == *UrBackup* && "$URBACKUP_STATUS" != "on" ]]; then
install_urbackup
check_port 51413 "UrBackup"
selection=${selection//UrBackup/}
fi
# reread statuses
check_status
i=$[$i+1]
done
# reread statuses
check_status
done
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