diff --git a/source/argon1.sh b/source/argon1.sh index 5f034f5..82ca22f 100644 --- a/source/argon1.sh +++ b/source/argon1.sh @@ -25,7 +25,7 @@ argon_time_error() { echo "**********************************************" echo "Possible Network Time Protocol Server issue" echo "Try running the following to correct:" - echo " curl -k https://download.argon40.com/tools/setntpserver.sh | bash" + echo " curl -k http://files.iamnet.com.ph/argon/setup/tools/setntpserver.sh | bash" } if [ $NEEDSTIMESYNC -eq 1 ] @@ -35,7 +35,7 @@ fi # Helper variables -ARGONDOWNLOADSERVER=https://download.argon40.com +ARGONDOWNLOADSERVER=http://files.iamnet.com.ph/argon/setup INSTALLATIONFOLDER=/etc/argon @@ -71,7 +71,6 @@ else FIRMWARE= fi CONFIG=/boot${FIRMWARE}/config.txt -TMPCONFIG=/dev/shm/argontmp.bak set_config_var() { if ! grep -q -E "$1=$2" $3 ; then @@ -135,7 +134,8 @@ set_nvme_default() { } set_maxusbcurrent() { if is_pifive ; then - set_config_var max_usb_current 1 $CONFIG + #set_config_var max_usb_current 1 $CONFIG + set_config_var usb_max_current_enable 1 $CONFIG fi } @@ -208,6 +208,9 @@ then if [ "$CHECKDEVICE" = "eon" ] then pkglist=($gpiopkg python3-smbus i2c-tools smartmontools) + elif [ "$CHECKDEVICE" = "oneoled" ] + then + pkglist=($gpiopkg python3-smbus i2c-tools python3-luma.oled python3-pil python3-pyqt5) else pkglist=($gpiopkg python3-smbus i2c-tools) fi @@ -217,11 +220,19 @@ else if [ "$CHECKDEVICE" = "eon" ] then pkglist=($gpiopkg python3-smbus i2c-tools smartmontools) + elif [ "$CHECKDEVICE" = "oneoled" ] + then + pkglist=($gpiopkg python3-smbus i2c-tools python3-luma.oled python3-pil python3-pyqt5) else pkglist=($gpiopkg python3-smbus i2c-tools) fi fi +echo "********************************************************************" +echo "INSTALLER: Add/update packages" +echo "********************************************************************" + + for curpkg in ${pkglist[@]}; do sudo apt-get install -y $curpkg RESULT=$(argon_check_pkg "$curpkg") @@ -234,6 +245,11 @@ for curpkg in ${pkglist[@]}; do fi done + +echo "********************************************************************" +echo "INSTALLER: I2C and Serial config" +echo "********************************************************************" + # Ubuntu Mate for RPi has raspi-config too command -v raspi-config &> /dev/null if [ $? -eq 0 ] @@ -255,6 +271,22 @@ then fi fi + +echo "********************************************************************" +echo "INSTALLER: dtoverlay=dwc2,dr_mode" +echo "********************************************************************" + +if [ "$CHECKDEVICE" = "oneoled" ] +then + set_config_var dtoverlay=dwc2,dr_mode host $CONFIG +fi + + + +echo "********************************************************************" +echo "INSTALLER: NVMe for pi5" +echo "********************************************************************" + # Added to enabled NVMe for pi5 set_nvme_default @@ -262,6 +294,7 @@ set_nvme_default basename="argonone" daemonname=$basename"d" irconfigscript=$INSTALLATIONFOLDER/${basename}-ir +upsconfigscript=$INSTALLATIONFOLDER/${basename}-upsconfig.sh fanconfigscript=$INSTALLATIONFOLDER/${basename}-fanconfig.sh eepromrpiscript="/usr/bin/rpi-eeprom-config" eepromconfigscript=$INSTALLATIONFOLDER/${basename}-eepromconfig.py @@ -273,6 +306,11 @@ daemonfanservice=/lib/systemd/system/$daemonname.service daemonhddconfigfile=/etc/${daemonname}-hdd.conf +echo "********************************************************************" +echo "INSTALLER: Downloading files for: $CHECKDEVICE" +echo "********************************************************************" + + if [ -f "$eepromrpiscript" ] then # EEPROM Config Script @@ -280,6 +318,13 @@ then sudo chmod 755 $eepromconfigscript fi +if is_pifive +then + # UPS Config Script + sudo wget $ARGONDOWNLOADSERVER/scripts/argonone-upsconfig.sh -O $upsconfigscript --quiet + sudo chmod 755 $upsconfigscript +fi + # Fan Config Script sudo wget $ARGONDOWNLOADSERVER/scripts/argonone-fanconfig.sh -O $fanconfigscript --quiet sudo chmod 755 $fanconfigscript @@ -287,7 +332,12 @@ sudo chmod 755 $fanconfigscript # Fan Daemon/Service Files sudo wget $ARGONDOWNLOADSERVER/scripts/argononed.py -O $powerbuttonscript --quiet -sudo wget $ARGONDOWNLOADSERVER/scripts/argononed.service -O $daemonfanservice --quiet +if [ "$CHECKDEVICE" = "oneoled" ] +then + sudo wget $ARGONDOWNLOADSERVER/scripts/argononeoledd.service -O $daemonfanservice --quiet +else + sudo wget $ARGONDOWNLOADSERVER/scripts/argononed.service -O $daemonfanservice --quiet +fi sudo chmod 644 $daemonfanservice if [ ! "$CHECKDEVICE" = "fanhat" ] @@ -329,6 +379,10 @@ sudo wget $ARGONDOWNLOADSERVER/scripts/argon-unitconfig.sh -O $unitconfigscript sudo chmod 755 $unitconfigscript +echo "********************************************************************" +echo "INSTALLER: Create default settings if none" +echo "********************************************************************" + # Generate default Fan config file if non-existent if [ ! -f $daemonconfigfile ]; then sudo touch $daemonconfigfile @@ -377,10 +431,6 @@ then daemonrtcservice=/lib/systemd/system/$daemonname.service rtcdaemonscript=$INSTALLATIONFOLDER/$daemonname.py - oledconfigscript=$INSTALLATIONFOLDER/${basename}-oledconfig.sh - oledlibscript=$INSTALLATIONFOLDER/${basename}oled.py - oledconfigfile=/etc/argoneonoled.conf - # Generate default RTC config file if non-existent if [ ! -f $rtcconfigfile ]; then sudo touch $rtcconfigfile @@ -390,6 +440,34 @@ then echo '# Argon RTC Configuration' >> $rtcconfigfile echo '#' >> $rtcconfigfile fi + + # RTC Config Script + sudo wget $ARGONDOWNLOADSERVER/scripts/argoneon-rtcconfig.sh -O $rtcconfigscript --quiet + sudo chmod 755 $rtcconfigscript + + # RTC Daemon/Service Files + sudo wget $ARGONDOWNLOADSERVER/scripts/argonrtc.py -O $INSTALLATIONFOLDER/argonrtc.py --quiet + sudo wget $ARGONDOWNLOADSERVER/scripts/argoneond.py -O $rtcdaemonscript --quiet + sudo wget $ARGONDOWNLOADSERVER/scripts/argoneond.service -O $daemonrtcservice --quiet + sudo chmod 644 $daemonrtcservice +fi + + +if [ "$CHECKDEVICE" = "eon" ] || [ "$CHECKDEVICE" = "oneoled" ] +then + + echo "********************************************************************" + echo "INSTALLER: OLED Files" + echo "********************************************************************" + + # OLED Setup + basename="argoneon" + daemonname=$basename"d" + + oledconfigscript=$INSTALLATIONFOLDER/${basename}-oledconfig.sh + oledlibscript=$INSTALLATIONFOLDER/${basename}oled.py + oledconfigfile=/etc/argoneonoled.conf + # Generate default OLED config file if non-existent if [ ! -f $oledconfigfile ]; then sudo touch $oledconfigfile @@ -399,25 +477,25 @@ then echo '# Argon OLED Configuration' >> $oledconfigfile echo '#' >> $oledconfigfile echo 'switchduration=30' >> $oledconfigfile - echo 'screenlist="clock cpu storage raid ram temp ip"' >> $oledconfigfile + if [ "$CHECKDEVICE" = "eon" ] + then + echo 'screenlist="clock cpu storage raid ram temp ip"' >> $oledconfigfile + else + echo 'screenlist="clock cpu storage ram temp ip"' >> $oledconfigfile + fi fi - - # RTC Config Script - sudo wget $ARGONDOWNLOADSERVER/scripts/argoneon-rtcconfig.sh -O $rtcconfigscript --quiet - sudo chmod 755 $rtcconfigscript - - # RTC Daemon/Service Files - sudo wget $ARGONDOWNLOADSERVER/scripts/argoneond.py -O $rtcdaemonscript --quiet - sudo wget $ARGONDOWNLOADSERVER/scripts/argoneond.service -O $daemonrtcservice --quiet - sudo wget $ARGONDOWNLOADSERVER/scripts/argoneonoled.py -O $oledlibscript --quiet - sudo chmod 644 $daemonrtcservice - # OLED Config Script - sudo wget $ARGONDOWNLOADSERVER/scripts/argoneon-oledconfig.sh -O $oledconfigscript --quiet + if [ "$CHECKDEVICE" = "eon" ] + then + sudo wget $ARGONDOWNLOADSERVER/scripts/argoneonoled.py -O $oledlibscript --quiet + sudo wget $ARGONDOWNLOADSERVER/scripts/argoneon-oledconfig.sh -O $oledconfigscript --quiet + else + sudo wget $ARGONDOWNLOADSERVER/scripts/argononeoled.py -O $oledlibscript --quiet + sudo wget $ARGONDOWNLOADSERVER/scripts/argonone-oledconfig.sh -O $oledconfigscript --quiet + fi sudo chmod 755 $oledconfigscript - if [ ! -d $INSTALLATIONFOLDER/oled ] then sudo mkdir $INSTALLATIONFOLDER/oled @@ -447,6 +525,12 @@ sudo touch $configscript # To ensure we can write the following lines sudo chmod 666 $configscript + + +echo "********************************************************************" +echo "INSTALLER: Creating argon-config script" +echo "********************************************************************" + echo '#!/bin/bash' >> $configscript echo 'echo "--------------------------"' >> $configscript @@ -484,7 +568,10 @@ echo 'while [ $mainloopflag -eq 1 ]' >> $configscript echo 'do' >> $configscript echo ' echo' >> $configscript echo ' echo "Choose Option:"' >> $configscript -echo ' echo " 1. Configure Fan"' >> $configscript +if [ ! "$CHECKDEVICE" = "oneoled" ] +then + echo ' echo " 1. Configure Fan"' >> $configscript +fi blstrdacoption=0 @@ -492,13 +579,27 @@ if [ "$CHECKDEVICE" = "fanhat" ] then uninstalloption="4" else - echo ' echo " 2. Configure IR"' >> $configscript + if [ ! "$CHECKDEVICE" = "oneoled" ] + then + echo ' echo " 2. Configure IR"' >> $configscript + fi if [ "$CHECKDEVICE" = "eon" ] then # ArgonEON Has RTC echo ' echo " 3. Configure RTC and/or Schedule"' >> $configscript echo ' echo " 4. Configure OLED"' >> $configscript uninstalloption="7" + elif [ "$CHECKDEVICE" = "oneoled" ] + then + echo ' echo " 1. Configure OLED"' >> $configscript + echo ' echo " 2. Argon Industria UPS"' >> $configscript + uninstalloption="5" + elif is_pifive + then + echo ' echo " 3. Argon Industria UPS"' >> $configscript + uninstalloption="7" + blstrdacoption=$(($uninstalloption-3)) + echo " echo \" $blstrdacoption. Configure BLSTR DAC (v3/v5 only)\"" >> $configscript else uninstalloption="6" blstrdacoption=$(($uninstalloption-3)) @@ -525,6 +626,7 @@ echo ' mainloopflag=0' >> $configscript echo ' elif [ $newmode -eq 1 ]' >> $configscript echo ' then' >> $configscript +# Option 1 if [ "$CHECKDEVICE" = "eon" ] then echo ' echo "Choose Triggers:"' >> $configscript @@ -544,40 +646,60 @@ then echo " $fanconfigscript hdd" >> $configscript echo ' mainloopflag=0' >> $configscript echo ' fi' >> $configscript - +elif [ "$CHECKDEVICE" = "oneoled" ] +then + echo " $oledconfigscript" >> $configscript + echo ' mainloopflag=0' >> $configscript else echo " $fanconfigscript" >> $configscript echo ' mainloopflag=0' >> $configscript fi +# Options 2 onwards if [ ! "$CHECKDEVICE" = "fanhat" ] then - echo ' elif [ $newmode -eq 2 ]' >> $configscript - echo ' then' >> $configscript - echo " $irconfigscript" >> $configscript - echo ' mainloopflag=0' >> $configscript - - if [ "$CHECKDEVICE" = "eon" ] + if [ "$CHECKDEVICE" = "oneoled" ] then - echo ' elif [ $newmode -eq 3 ]' >> $configscript + echo ' elif [ $newmode -eq 2 ]' >> $configscript echo ' then' >> $configscript - echo " $rtcconfigscript" >> $configscript + echo " $upsconfigscript" >> $configscript echo ' mainloopflag=0' >> $configscript - echo ' elif [ $newmode -eq 4 ]' >> $configscript - echo ' then' >> $configscript - echo " $oledconfigscript" >> $configscript - echo ' mainloopflag=0' >> $configscript - fi - if [ $blstrdacoption -gt 0 ] - then - echo " elif [ \$newmode -eq $blstrdacoption ]" >> $configscript + else + echo ' elif [ $newmode -eq 2 ]' >> $configscript echo ' then' >> $configscript - echo " $blstrdacconfigscript" >> $configscript + echo " $irconfigscript" >> $configscript echo ' mainloopflag=0' >> $configscript + + if [ "$CHECKDEVICE" = "eon" ] + then + echo ' elif [ $newmode -eq 3 ]' >> $configscript + echo ' then' >> $configscript + echo " $rtcconfigscript" >> $configscript + echo ' mainloopflag=0' >> $configscript + echo ' elif [ $newmode -eq 4 ]' >> $configscript + echo ' then' >> $configscript + echo " $oledconfigscript" >> $configscript + echo ' mainloopflag=0' >> $configscript + elif is_pifive + then + echo ' elif [ $newmode -eq 3 ]' >> $configscript + echo ' then' >> $configscript + echo " $upsconfigscript" >> $configscript + echo ' mainloopflag=0' >> $configscript + fi + + if [ $blstrdacoption -gt 0 ] + then + echo " elif [ \$newmode -eq $blstrdacoption ]" >> $configscript + echo ' then' >> $configscript + echo " $blstrdacconfigscript" >> $configscript + echo ' mainloopflag=0' >> $configscript + fi fi fi +# Standard options echo " elif [ \$newmode -eq $unitsoption ]" >> $configscript echo ' then' >> $configscript echo " $unitconfigscript" >> $configscript @@ -596,14 +718,29 @@ echo 'done' >> $configscript sudo chmod 755 $configscript + +echo "********************************************************************" +echo "INSTALLER: Desktop shortcut" +echo "********************************************************************" + # Desktop Icon -shortcutfile="/home/pi/Desktop/argonone-config.desktop" -if [ "$CHECKPLATFORM" = "Raspbian" ] && [ -d "/home/pi/Desktop" ] +destfoldername=$USERNAME +if [ -z "$destfoldername" ] then - terminalcmd="lxterminal --working-directory=/home/pi/ -t" - if [ -f "/home/pi/.twisteros.twid" ] + destfoldername=$USER +fi +if [ -z "$destfoldername" ] +then + destfoldername="pi" +fi + +shortcutfile="/home/$destfoldername/Desktop/argonone-config.desktop" +if [ "$CHECKPLATFORM" = "Raspbian" ] && [ -d "/home/$destfoldername/Desktop" ] +then + terminalcmd="lxterminal --working-directory=/home/$destfoldername/ -t" + if [ -f "/home/$destfoldername/.twisteros.twid" ] then - terminalcmd="xfce4-terminal --default-working-directory=/home/pi/ -T" + terminalcmd="xfce4-terminal --default-working-directory=/home/$destfoldername/ -T" fi imagefile=ar1config.png if [ "$CHECKDEVICE" = "eon" ] @@ -630,6 +767,11 @@ fi configcmd="$(basename -- $configscript)" + +echo "********************************************************************" +echo "INSTALLER: Start/restart services/daemon" +echo "********************************************************************" + if [ "$setupmode" = "Setup" ] then if [ -f "/usr/bin/$configcmd" ] @@ -638,7 +780,7 @@ then fi sudo ln -s $configscript /usr/bin/$configcmd - if [ "$CHECKDEVICE" = "one" ] + if [ "$CHECKDEVICE" = "one" ] || [ "$CHECKDEVICE" = "oneoled" ] then sudo ln -s $configscript /usr/bin/argonone-config sudo ln -s $uninstallscript /usr/bin/argonone-uninstall @@ -667,6 +809,10 @@ else fi fi +echo "********************************************************************" +echo "INSTALLER: EEPROM Check/updates" +echo "********************************************************************" + if [ "$CHECKPLATFORM" = "Raspbian" ] then if [ -f "$eepromrpiscript" ]