Unverified Commit d9fb9a25 authored by Igor Pečovnik's avatar Igor Pečovnik Committed by GitHub
Browse files

AR-50: Optimise Docker installation (#74)

* AR-50: Optimise Docker installation by downloading only selected arhitecture

* AR-50: Optimising Hass.io installer

* Further cleaning
parent 9c4bf842
...@@ -51,6 +51,8 @@ ...@@ -51,6 +51,8 @@
# install_ISPConfig # install_ISPConfig
# #
# load functions, local first # load functions, local first
# #
...@@ -81,14 +83,6 @@ fi ...@@ -81,14 +83,6 @@ fi
#
# not sure if needed
#
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
[[ -z $LC_ALL ]] && export LC_ALL="C"
function check_status function check_status
{ {
# #
...@@ -333,26 +327,38 @@ echo "" ...@@ -333,26 +327,38 @@ echo ""
} }
alive_port () 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
} }
alive_process () alive_process ()
{ {
# #
...@@ -364,9 +370,6 @@ if pgrep -x "$2" > /dev/null 2>&1; then DESCRIPTION="$1 is \Z1active\Z0"; else D ...@@ -364,9 +370,6 @@ if pgrep -x "$2" > /dev/null 2>&1; then DESCRIPTION="$1 is \Z1active\Z0"; else D
install_basic (){ install_basic (){
# #
# Set hostname, FQDN, add to sources list # Set hostname, FQDN, add to sources list
...@@ -782,7 +785,8 @@ fi ...@@ -782,7 +785,8 @@ fi
install_docker () install_docker ()
{ {
echo "deb https://download.docker.com/linux/${family,,} $distribution edge" > /etc/apt/sources.list.d/docker.list echo "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/${family,,} $distribution edge" >\
/etc/apt/sources.list.d/docker.list
curl -fsSL "https://download.docker.com/linux/${family,,}/gpg" | apt-key add -qq - > /dev/null 2>&1 curl -fsSL "https://download.docker.com/linux/${family,,}/gpg" | apt-key add -qq - > /dev/null 2>&1
debconf-apt-progress -- apt-get update debconf-apt-progress -- apt-get update
debconf-apt-progress -- apt-get install -y -qq --no-install-recommends docker-ce debconf-apt-progress -- apt-get install -y -qq --no-install-recommends docker-ce
...@@ -892,25 +896,36 @@ chmod +x /etc/cron.daily/seed-armbian-torrent ...@@ -892,25 +896,36 @@ chmod +x /etc/cron.daily/seed-armbian-torrent
install_hassio () install_hassio ()
{ {
# #
# Install Home assistant smart home suite hass.io # Install Home assistant smart home suite hass.io / Docker instance by using official installer
# #
LIST=("intel-nuc" "Intel NUC" "odroid-c2" "Hardkernel Odroid C2" "odroid-xu" "Hardkernel Odroid XU4" "orangepi-prime" "Allwinner H5 boards" "qemuarm" "Virtualized ARM" "qemuarm-64" "Virtualized ARM64" "qemux86" "Virtualized x86" "qemux86-64" "Virtualied x64" "raspberrypi" "1st generation" "raspberrypi2" "2nd generation" "raspberrypi3" "3rd generation" "raspberrypi3-64" "3rd generation arm64 userland" "tinker" "Tinkerboard") local arch=$(dpkg --print-architecture)
LIST_LENGTH=$((${#LIST[@]}/2));
exec 3>&1 case $arch in
#TARGET_BOARD=$(dialog --menu "Choose machine type:" 0 0 0 "${LIST[@]}") armhf)
TARGET_BOARD=$(dialog --cancel-label "Cancel" --backtitle "$BACKTITLE" --no-collapse --title "Choose machine type:" --clear --menu "" $((6+${LIST_LENGTH})) 52 25 "${LIST[@]}" 2>&1 1>&3) local machine=raspberrypi2
exitstatus=$?; ;;
exec 3>&- arm64)
if [ $exitstatus = 0 ]; then local machine=raspberrypi4-64
;;
amd64)
local machine=intel-nuc
;;
*)
exit 1
;;
esac
if [ $? == 0 ]; then
install_docker install_docker
debconf-apt-progress -- apt-get install -y apparmor-utils apt-transport-https avahi-daemon ca-certificates curl dbus jq network-manager socat software-properties-common debconf-apt-progress -- apt-get install -y apparmor-utils apt-transport-https avahi-daemon ca-certificates \
local arch=$(dpkg --print-architecture) dbus jq network-manager socat software-properties-common
[[ "$arch" == "arm64" ]] && arch="aarch64" curl -sL "https://raw.githubusercontent.com/home-assistant/hassio-installer/master/hassio_install.sh" | \
docker pull homeassistant/${arch}-homeassistant bash -s -- -m ${machine}
curl -sL "https://raw.githubusercontent.com/home-assistant/hassio-installer/master/hassio_install.sh" > ${TEMP_DIR}/hass.io.bash dialog --backtitle "$BACKTITLE" --title "Please wait" \
bash ${TEMP_DIR}/hass.io.bash -m ${TARGET_BOARD} --msgbox "\nIt can take several minutes before Home Assistant UI becomes available! " 7 75
dialog --backtitle "$BACKTITLE" --title "Please wait" --msgbox "\nIt can take several minutes before Home Assistant UI becomes available! " 7 75
fi fi
} }
...@@ -922,12 +937,15 @@ install_openhab () ...@@ -922,12 +937,15 @@ install_openhab ()
# #
# Install Openhab2 smart home suite openhab.org # Install Openhab2 smart home suite openhab.org
# #
wget -qO - 'https://bintray.com/user/downloadSubjectPublicKey?username=openhab' | apt-key add - >/dev/null 2>&1 wget -qO - 'https://bintray.com/user/downloadSubjectPublicKey?username=openhab' | apt-key add - >/dev/null 2>&1
echo 'deb https://dl.bintray.com/openhab/apt-repo2 stable main' | tee /etc/apt/sources.list.d/openhab2.list >/dev/null 2>&1 echo 'deb https://dl.bintray.com/openhab/apt-repo2 stable main' | tee /etc/apt/sources.list.d/openhab2.list >/dev/null 2>&1
debconf-apt-progress -- apt-get update debconf-apt-progress -- apt-get update
debconf-apt-progress -- apt-get install -y openhab2 openhab2-addons default-jre debconf-apt-progress -- apt-get install -y openhab2 openhab2-addons default-jre
service openhab2 start service openhab2 start
dialog --backtitle "$BACKTITLE" --title "Please wait" --msgbox "\nIt can take several minutes before OpenHAB UI becomes available! " 7 68 dialog --backtitle "$BACKTITLE" --title "Please wait" --msgbox \
"\nIt can take several minutes before OpenHAB UI becomes available! " 7 68
} }
...@@ -982,6 +1000,9 @@ install_plex_media_server () ...@@ -982,6 +1000,9 @@ install_plex_media_server ()
debconf-apt-progress -- apt-get -y install plexmediaserver debconf-apt-progress -- apt-get -y install plexmediaserver
} }
install_emby_server () install_emby_server ()
{ {
# #
...@@ -995,6 +1016,8 @@ install_emby_server () ...@@ -995,6 +1016,8 @@ install_emby_server ()
} }
install_radarr () install_radarr ()
{ {
# #
...@@ -1622,9 +1645,9 @@ service fail2ban restart >> /dev/null ...@@ -1622,9 +1645,9 @@ service fail2ban restart >> /dev/null
install_ISPConfig (){ install_ISPConfig (){
#------------------------------------------------------------------------------------------------------------------------------------------ #
# Install ISPConfig 3 # Install ISPConfig 3
#------------------------------------------------------------------------------------------------------------------------------------------ #
cd ${TEMP_DIR} cd ${TEMP_DIR}
wget -q https://www.ispconfig.org/downloads/ISPConfig-3-stable.tar.gz -O - | tar -xz wget -q https://www.ispconfig.org/downloads/ISPConfig-3-stable.tar.gz -O - | tar -xz
cd ${TEMP_DIR}/ispconfig3_install/install/ cd ${TEMP_DIR}/ispconfig3_install/install/
...@@ -1642,9 +1665,9 @@ fi ...@@ -1642,9 +1665,9 @@ fi
#------------------------------------------------------------------------------------------------------------------------------------------ #
# Main choices # Main choices
#------------------------------------------------------------------------------------------------------------------------------------------ #
# check for root # check for root
# #
...@@ -1826,10 +1849,10 @@ if ! is_package_manager_running; then ...@@ -1826,10 +1849,10 @@ if ! is_package_manager_running; then
selection=${selection//\"Pi hole\"/} selection=${selection//\"Pi hole\"/}
fi fi
if [[ "$selection" == *Docker* && "$DOCKER_STATUS" != "on" ]]; then if [[ "$selection" == *Docker* && "$DOCKER_STATUS" != "on" ]]; then
install_docker install_docker
selection=${selection//Docker/} selection=${selection//Docker/}
fi fi
if [[ "$selection" == *Transmission* && "$TRANSMISSION_STATUS" != "on" ]]; then if [[ "$selection" == *Transmission* && "$TRANSMISSION_STATUS" != "on" ]]; then
install_transmission install_transmission
......
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