Update 'Installer.sh'

Added dialog to ensure the device has an static ip.
Added option to install SmartPing and it's dependencies when Domoticz is selected.
Added unzip as default pre-requirement.
Fixed NodeJS by installing it's dependencies first with the install.list, afterwards install the program.
Added Personalisation for username Jarno
Added different greetings depending on the selected options in the installer menu.
This commit is contained in:
b.waal 2023-09-12 20:40:00 +02:00
parent 204c8ca7c6
commit 62ef92c74d

View File

@ -86,6 +86,15 @@ if [[ $AGREE != "yes" ]]; then
INSTALL=no INSTALL=no
fi fi
fi fi
if (whiptail --title "Pi Automation" --yesno "Is this device configured with a static IP?." 8 78); then
echo ""
else
whiptail --title "Pi Automation" --msgbox "Configure a static IP first!" 8 78
clear
exit
fi
if [[ $INSTALL == no ]]; then if [[ $INSTALL == no ]]; then
whiptail --title "Pi Automation" --msgbox "Installation canceled!" 8 78 whiptail --title "Pi Automation" --msgbox "Installation canceled!" 8 78
clear clear
@ -131,6 +140,15 @@ if [[ $SKIPoptions != "yes" ]]; then
"Monitor-Service" "Autologin the Pi user to show system and service statuses. (usefull with TFT)" OFF 3>&1 1>&2 2>&3) "Monitor-Service" "Autologin the Pi user to show system and service statuses. (usefull with TFT)" OFF 3>&1 1>&2 2>&3)
fi fi
if [[ $OPTIONS == *"Domoticz"* ]]; then
if (whiptail --title "Domoticz Options" --yesno "Use a Smart-Pinger that tracks your phones presence?\nThis is done by searching for your phones Wifi and Bluetooth status." 8 78); then
SMARTPING=yes
whiptail --title "Important" --msgbox "Make sure to set up your mobile device to use a static ip!" 8 78
else
SMARTPING=no
fi
fi
if [[ $SKIPhomer != "yes" ]]; then if [[ $SKIPhomer != "yes" ]]; then
if [[ $OPTIONS == *"Homer"* ]]; then if [[ $OPTIONS == *"Homer"* ]]; then
ISP=$(whiptail --title "Configure Options" --radiolist \ ISP=$(whiptail --title "Configure Options" --radiolist \
@ -206,28 +224,34 @@ sleep 3
dphys-swapfile swapoff ; dphys-swapfile uninstall ; update-rc.d dphys-swapfile remove dphys-swapfile swapoff ; dphys-swapfile uninstall ; update-rc.d dphys-swapfile remove
systemctl disable ModemManager systemctl disable ModemManager
echo "python3-dev python3-pip" >> /tmp/install.list echo "python3-dev python3-pip unzip" >> /tmp/install.list
if [[ $OPTIONS == *"Domoticz"* ]]; then if [[ $OPTIONS == *"Domoticz"* ]]; then
echo "apt-utils git unzip cron libudev-dev libsqlite3-0 libcurl4 libusb-0.1-4" >> /tmp/install.list echo "apt-utils git cron libudev-dev libsqlite3-0 libcurl4 libusb-0.1-4" >> /tmp/install.list
if [[ $SMARTPING == "yes" ]]; then
echo "fping" >> /tmp/install.list
fi
fi fi
if [[ $OPTIONS == *"Node-RED"* ]]; then if [[ $OPTIONS == *"Node-RED"* ]]; then
echo "build-essential git mosquitto mosquitto-clients" >> /tmp/install.list echo "build-essential git mosquitto mosquitto-clients" >> /tmp/install.list
fi fi
if [[ $OPTIONS == *"Zigbee2MQTT"* ]]; then if [[ $OPTIONS == *"Zigbee2MQTT"* ]]; then
echo "git make g++ gcc mosquitto mosquitto-clients" >> /tmp/install.list echo "git make g++ gcc mosquitto mosquitto-clients" >> /tmp/install.list
if [[ $OPTIONS != *"Node-RED"* ]]; then if [[ $OPTIONS != *"Node-RED"* ]]; then
echo "ca-certificates gnupg nodejs" >> /tmp/install.list echo "ca-certificates gnupg curl" >> /tmp/install.list
mkdir -p /etc/apt/keyrings mkdir -p /etc/apt/keyrings
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
fi fi
fi fi
if [[ $OPTIONS == *"Unattended-Upgrades"* ]]; then if [[ $OPTIONS == *"Unattended-Upgrades"* ]]; then
echo "unattended-upgrades apt-listchanges" >> /tmp/install.list echo "unattended-upgrades apt-listchanges" >> /tmp/install.list
fi fi
if [[ $OPTIONS == *"Homer"* ]]; then if [[ $OPTIONS == *"Homer"* ]]; then
echo "nginx unzip" >> /tmp/install.list echo "nginx" >> /tmp/install.list
fi fi
##-----------## ##-----------##
# Updater # # Updater #
##-----------## ##-----------##
@ -243,6 +267,14 @@ echo "ufw" >> /tmp/install.list
echo "gcc g++ gawk autoconf automake python3-cmarkgfm libssl-dev attr libxxhash-dev libattr1-dev liblz4-dev libzstd-dev acl libacl1-dev" >> /tmp/install.list echo "gcc g++ gawk autoconf automake python3-cmarkgfm libssl-dev attr libxxhash-dev libattr1-dev liblz4-dev libzstd-dev acl libacl1-dev" >> /tmp/install.list
xargs < /tmp/install.list xargs $PKGI xargs < /tmp/install.list xargs $PKGI
#Run updater again for installation NodeJS since now the required dependencies are installed on the system.
if [[ $OPTIONS != *"Node-RED"* ]]; then
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
echo "nodejs" > /tmp/install.list
$PKGUD
xargs < /tmp/install.list xargs $PKGI
fi
##-------------## ##-------------##
# Installer # # Installer #
@ -312,6 +344,12 @@ if [[ $OPTIONS == *"Domoticz"* ]]; then
chmod +x /etc/init.d/domoticz.sh chmod +x /etc/init.d/domoticz.sh
update-rc.d domoticz.sh defaults update-rc.d domoticz.sh defaults
systemctl start domoticz systemctl start domoticz
if [[ $SMARTPING == "yes" ]]; then
mkdir -p /var/log/pid/
mkdir -p /var/pinger
wget $GIT/$BRANCH/Domoticz/SmartPinger.sh -O /opt/pinger/Smartping-NAME.sh
wget $GIT/$BRANCH/Domoticz/SmartPinger.service -O /etc/systemd/system/Smartping-NAME.service
fi
fi fi
@ -424,6 +462,23 @@ if [[ $OPTIONS == *"Homer"* ]]; then
fi fi
fi fi
##-------------------##
# Personalization #
##-------------------##
if [[ $NAME == "Jarno" ]]; then
if [[ $OPTIONS == *"Domoticz"* ]]; then
wget $GIT/$BRANCH/Domoticz/Customisation/custom.css -O /opt/domoticz/www/styles/dark-th3me/custom.css
wget $GIT/$BRANCH/Domoticz/Customisation/bosduif.jpg -O /opt/domoticz/www/styles/dark-th3me/images/domoticz.jpg
fi
if [[ $OPTIONS == *"Homer"* ]]; then
wget $GIT/$BRANCH/Homer/Customisation/light.jpeg -O /var/www/html/assets/wallpaper-light.jpeg
wget $GIT/$BRANCH/Homer/Customisation/dark.jpeg -O /var/www/html/assets/wallpaper.jpeg
fi
fi
##-----------------## ##-----------------##
# Optimizing Pi # # Optimizing Pi #
##-----------------## ##-----------------##
@ -495,7 +550,13 @@ TERM=ansi whiptail --title "Pi Automation" --infobox "Finishing." 8 78
sleep 3 sleep 3
wget $GIT/$BRANCH/Updater.sh -O /opt/updater.sh wget $GIT/$BRANCH/Updater.sh -O /opt/updater.sh
wget $GIT/$BRANCH/MOTD/greetings.sh -O /etc/profile.d/greeting.sh
if [[ $SMARTPING == "no" ]]; then
wget $GIT/$BRANCH/MOTD/greetings.sh -O /etc/profile.d/greeting.sh
else
wget $GIT/$BRANCH/MOTD/greetings-pinger.sh -O /etc/profile.d/greeting.sh
fi
sed -i -e "s/%name%/$NAME/g" /etc/profile.d/greeting.sh sed -i -e "s/%name%/$NAME/g" /etc/profile.d/greeting.sh
mkdir -p /opt/backups/timestamps/ mkdir -p /opt/backups/timestamps/
@ -529,4 +590,4 @@ then
else else
whiptail --title "Done!" --msgbox "The Raspberry Pi will reboot. Press OK to continue." 8 78 whiptail --title "Done!" --msgbox "The Raspberry Pi will reboot. Press OK to continue." 8 78
reboot reboot
fi fi