Update Installer.sh

Added datestamps to use in the Updater.sh script.
Now saving username entered in the installer.
This commit is contained in:
Beeranco 2023-08-13 15:14:28 +02:00 committed by GitHub
parent 1c3c02e96c
commit 6c2c97cfda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,11 +6,13 @@
OUTPUT='>/dev/null 2>&1' OUTPUT='>/dev/null 2>&1'
APTMODE="debconf-apt-progress -- apt" APTMODE="debconf-apt-progress -- apt"
DATE=$(date +"%m-%d-%Y")
IP=`hostname -I`
IP=$(echo $IP | tr -d ' ')
REPO=PiAutomation REPO=PiAutomation
GIT=https://raw.githubusercontent.com/Beeranco GIT=https://raw.githubusercontent.com/Beeranco
BRANCH=main BRANCH=main
##-----------## ##-----------##
# Check OS # # Check OS #
##-----------## ##-----------##
@ -53,7 +55,7 @@ if [[ $INSTALL == no ]]; then
fi fi
NAME=$(whiptail --nocancel --inputbox "What is your name?" 8 39 John --title "Welcome" 3>&1 1>&2 2>&3) NAME=$(whiptail --nocancel --inputbox "What is your name?" 8 39 John --title "Welcome" 3>&1 1>&2 2>&3)
HOST=$(whiptail --nocancel --inputbox "What is the name of this machine?" 8 39 Raspberry --title "Welcome $NAME!" 3>&1 1>&2 2>&3) HOST=$(whiptail --nocancel --inputbox "What is the name of this machine? (only az-AZ characters are allowd)" 8 39 Raspberry --title "Welcome $NAME!" 3>&1 1>&2 2>&3)
##-------------## ##-------------##
# Pre-Check # # Pre-Check #
@ -212,6 +214,7 @@ fi
# Store Vars # # Store Vars #
##--------------## ##--------------##
echo $NAME > /etc/username
echo $OPTIONS > /etc/installedmodules echo $OPTIONS > /etc/installedmodules
sed -i 's/\s\+/\n/g' /etc/installedmodules sed -i 's/\s\+/\n/g' /etc/installedmodules
sed -i 's/\"//g' /etc/installedmodules sed -i 's/\"//g' /etc/installedmodules
@ -220,20 +223,24 @@ sed -i 's/\"//g' /etc/installedmodules
# Finishing # # Finishing #
##-------------## ##-------------##
IP=`hostname -I`
IP=$(echo $IP | tr -d ' ')
wget $GIT/$REPO/$BRANCH/Updater.sh -O /opt/updater.sh wget $GIT/$REPO/$BRANCH/Updater.sh -O /opt/updater.sh
wget $GIT/$REPO/$BRANCH/MOTD/greetings.sh -O /etc/profile.d/greeting.sh wget $GIT/$REPO/$BRANCH/MOTD/greetings.sh -O /etc/profile.d/greeting.sh
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/
echo "Installed on: $DATE" > /opt/backups/timestamps/OS.update
if grep -q Domoticz "/etc/installedmodules"; then if grep -q Domoticz "/etc/installedmodules"; then
echo "Installed on: $DATE" > /opt/backups/timestamps/Domoticz.update
whiptail --title "Remember" --msgbox "After a reboot Domoticz is accessible on:\nhttp://$IP:8080" 8 78 whiptail --title "Remember" --msgbox "After a reboot Domoticz is accessible on:\nhttp://$IP:8080" 8 78
fi fi
if grep -q Node-RED "/etc/installedmodules"; then if grep -q Node-RED "/etc/installedmodules"; then
echo "Installed on: $DATE" > /opt/backups/timestamps/NodeRED.update
whiptail --title "Remember" --msgbox "After a reboot Node-RED is accessible on:\nhttp://$IP:1880" 8 78 whiptail --title "Remember" --msgbox "After a reboot Node-RED is accessible on:\nhttp://$IP:1880" 8 78
fi fi
if grep -q Zigbee2MQTT "/etc/installedmodules"; then if grep -q Zigbee2MQTT "/etc/installedmodules"; then
echo "Installed on: $DATE" > /opt/backups/timestamps/Zigbee2MQTT.update
whiptail --title "Remember" --msgbox "After a reboot Zigbee2MQTT is accessible on:\nhttp://$IP:5002" 8 78 whiptail --title "Remember" --msgbox "After a reboot Zigbee2MQTT is accessible on:\nhttp://$IP:5002" 8 78
fi fi