From f3386d5f01da5c1b288df8dc61b27a5398acf8fb Mon Sep 17 00:00:00 2001 From: okunze <65952933+okunze@users.noreply.github.com> Date: Fri, 28 Nov 2025 21:08:17 +0000 Subject: [PATCH] Automated Change by GitHub Action --- source/argon1.sh | 23 ++++- source/scripts/argon-uninstall.sh | 6 +- source/scripts/argon-versioninfo.sh | 2 +- source/scripts/argondashboard.py | 5 +- source/scripts/argononed.py | 18 ++++ source/scripts/argonpowerbutton-libgpiod.py | 103 +++++++++++++++++++- source/scripts/argonpowerbutton-rpigpio.py | 90 +++++++++++++++++ 7 files changed, 239 insertions(+), 8 deletions(-) diff --git a/source/argon1.sh b/source/argon1.sh index 9d52aa0..7607a9d 100644 --- a/source/argon1.sh +++ b/source/argon1.sh @@ -228,6 +228,8 @@ else fi fi +echo "Installing/updating dependencies..." + for curpkg in ${pkglist[@]}; do sudo apt-get install -y $curpkg RESULT=$(argon_check_pkg "$curpkg") @@ -240,6 +242,8 @@ for curpkg in ${pkglist[@]}; do fi done +echo "Updating configuration ..." + # Ubuntu Mate for RPi has raspi-config too command -v raspi-config &> /dev/null if [ $? -eq 0 ] @@ -271,8 +275,9 @@ then rm $TMPCONFIGFILE fi -# Added to enabled NVMe for pi5 +# Additional config for pi5 set_nvme_default +set_maxusbcurrent # Fan Setup basename="argonone" @@ -289,6 +294,7 @@ daemonfanservice=/lib/systemd/system/$daemonname.service daemonhddconfigfile=/etc/${daemonname}-hdd.conf +echo "Installing/Updating scripts and services ..." if [ -f "$eepromrpiscript" ] then @@ -304,6 +310,13 @@ then sudo chmod 755 $upsconfigscript fi +for TMPDIRECTORY in "/lib/systemd/system" "/lib/systemd/system-shutdown" +do + sudo mkdir -p "$TMPDIRECTORY" + sudo chmod 755 $TMPDIRECTORY + sudo chown root:root "$TMPDIRECTORY" +done + # Fan Config Script sudo wget $ARGONDOWNLOADSERVER/scripts/argonone-fanconfig.sh -O $fanconfigscript --quiet sudo chmod 755 $fanconfigscript @@ -705,6 +718,8 @@ fi shortcutfile="/home/$destfoldername/Desktop/argonone-config.desktop" if [ -d "/home/$destfoldername/Desktop" ] then + echo "Creating/Updating Desktop Elements ..." + terminalcmd="lxterminal --working-directory=/home/$destfoldername/ -t" if [ -f "/home/$destfoldername/.twisteros.twid" ] then @@ -735,6 +750,8 @@ fi configcmd="$(basename -- $configscript)" +echo "Initializing Services ..." + if [ "$setupmode" = "Setup" ] then if [ -f "/usr/bin/$configcmd" ] @@ -772,10 +789,12 @@ else fi fi + if [ "$CHECKPLATFORM" = "Raspbian" ] then if [ -f "$eepromrpiscript" ] then + echo "Checking EEPROM ..." sudo apt-get update && sudo apt-get upgrade -y sudo rpi-eeprom-update # EEPROM Config Script @@ -785,8 +804,6 @@ else echo "WARNING: EEPROM not updated. Please run this under Raspberry Pi OS" fi -set_maxusbcurrent - echo "*********************" echo " $setupmode Completed " diff --git a/source/scripts/argon-uninstall.sh b/source/scripts/argon-uninstall.sh index e296951..2693fcb 100644 --- a/source/scripts/argon-uninstall.sh +++ b/source/scripts/argon-uninstall.sh @@ -98,9 +98,13 @@ then sudo systemctl stop argonupsrtcd.service sudo systemctl disable argonupsrtcd.service + sudo systemctl --global stop argononeupsduser.service + sudo systemctl --global disable argononeupsduser.service + # Remove files sudo rm /lib/systemd/system/argononeupsd.service sudo rm /lib/systemd/system/argonupsrtcd.service + sudo rm /etc/systemd/user/argononeupsduser.service find "/home" -maxdepth 1 -type d | while read line; do shortcutfile="$line/Desktop/argonone-ups.desktop" @@ -128,7 +132,7 @@ then fi # Delete config files -for configfile in argonunits argononed argononed-hdd argoneonrtc argoneonoled argonupsrtc +for configfile in argonunits argononed argononed-hdd argoneonrtc argoneonoled argonupsrtc argononeupd do if [ -f "/etc/${configfile}.conf" ] then diff --git a/source/scripts/argon-versioninfo.sh b/source/scripts/argon-versioninfo.sh index 11cfafd..5a4caef 100644 --- a/source/scripts/argon-versioninfo.sh +++ b/source/scripts/argon-versioninfo.sh @@ -1,6 +1,6 @@ #!/bin/bash -VERSIONINFO="2507001" +VERSIONINFO="2511001" echo "Version $VERSIONINFO" if [ -z "$1" ] diff --git a/source/scripts/argondashboard.py b/source/scripts/argondashboard.py index d5c4032..78a1877 100644 --- a/source/scripts/argondashboard.py +++ b/source/scripts/argondashboard.py @@ -368,4 +368,7 @@ def mainloop(stdscr): except Exception as closeerr: pass -curses.wrapper(mainloop) +try: + curses.wrapper(mainloop) +except Exception as wrapperr: + pass diff --git a/source/scripts/argononed.py b/source/scripts/argononed.py index d38ee27..6d26017 100644 --- a/source/scripts/argononed.py +++ b/source/scripts/argononed.py @@ -42,6 +42,8 @@ if os.path.exists("/etc/argon/argoneonoled.py"): OLED_CONFIGFILE = "/etc/argoneonoled.conf" UNIT_CONFIGFILE = "/etc/argonunits.conf" +SHUTDOWN_FLAGFILE = "/dev/shm/argonshutdownflag.txt" + # This function converts the corresponding fanspeed for the given temperature # The configuration data is a list of strings in the form "=" @@ -257,6 +259,13 @@ def display_loop(readq): screenenabled = [] while len(screenenabled) > 0: + try: + if os.path.isfile(SHUTDOWN_FLAGFILE): + display_defaultimg() + return + except: + pass + if len(curlist) == 0 and screenjogflag == 1: # Reset Screen Saver screensavermode = False @@ -565,9 +574,18 @@ def display_defaultimg(): if len(sys.argv) > 1: cmd = sys.argv[1].upper() if cmd == "SHUTDOWN": + try: + with open(SHUTDOWN_FLAGFILE, "w") as f: + f.write("signalled") + except: + pass + # Signal poweroff argonregister_signalpoweroff(bus) + if OLED_ENABLED == True: + display_defaultimg() + elif cmd == "FANOFF": # Turn off fan argonregister_setfanspeed(bus,0) diff --git a/source/scripts/argonpowerbutton-libgpiod.py b/source/scripts/argonpowerbutton-libgpiod.py index 8f8c6d8..0c19433 100644 --- a/source/scripts/argonpowerbutton-libgpiod.py +++ b/source/scripts/argonpowerbutton-libgpiod.py @@ -6,9 +6,108 @@ import gpiod import os import time +# Debug Logger +def argonpowerbutton_debuglog(typestr, logstr): + try: + DEBUGFILE="/dev/shm/argononegpiodebuglog.txt" + tmpstrpadding = " " + + with open(DEBUGFILE, "a") as txt_file: + txt_file.write("["+time.asctime(time.localtime(time.time()))+"] "+typestr.upper()+" "+logstr.strip().replace("\n","\n"+tmpstrpadding)+"\n") + except: + pass + + # This function is the thread that monitors activity in our shutdown pin # The pulse width is measured, and the corresponding shell command will be issued +def argonpowerbutton_getconfigval(keyname, datatype="int"): + keyname = keyname.lower() + fname = "/etc/argononeupd.conf" + try: + with open(fname, "r") as fp: + for curline in fp: + if not curline: + continue + tmpline = curline.replace(" ", "").replace("\t", "") + if not tmpline: + continue + if tmpline[0] == "#": + continue + tmppair = tmpline.split("=") + if len(tmppair) != 2: + continue + + tmpvar = tmppair[0].lower() + if tmpvar != keyname: + continue + + try: + if datatype == "int": + return int(tmppair[1]) + elif datatype == "float": + return float(tmppair[1]) + return tmppair[1] + except: + continue + except: + pass + if datatype == "int": + return -1 + elif datatype == "float": + return -1 + return "" + +def argonpowerbutton_monitorlid(writeq): + try: + argonpowerbutton_debuglog("lid-monitor", "Starting") + monitormode = True + # 0 - Lid is closed, 1 - Lid is open + # Pin Assignments + LINE_LIDMONITOR=27 + try: + # Pi5 mapping + chip = gpiod.Chip('4') + except Exception as gpioerr: + # Old mapping + chip = gpiod.Chip('0') + + lineobj = chip.get_line(LINE_LIDMONITOR) + lineobj.request(consumer="argon", type=gpiod.LINE_REQ_EV_BOTH_EDGES, flags=gpiod.LINE_REQ_FLAG_BIAS_PULL_UP) + while monitormode == True: + hasevent = lineobj.event_wait(10) + if hasevent: + eventdata = lineobj.event_read() + if eventdata.type == gpiod.LineEvent.FALLING_EDGE: + targetsecs = argonpowerbutton_getconfigval("lidshutdownsecs") + if targetsecs > 0: + argonpowerbutton_debuglog("lid-monitor", "Close Detect; Wait for :"+str(targetsecs)) + else: + argonpowerbutton_debuglog("lid-monitor", "Close Detected; Do nothing") + # Time pulse data + time.sleep(1) + pulsetimesec = 1 + while lineobj.get_value() == 0: + if targetsecs > 0: + if pulsetimesec >= targetsecs: + argonpowerbutton_debuglog("lid-monitor", "Target Reached, shutting down") + monitormode = False + os.system("shutdown now -h") + break + + time.sleep(1) + pulsetimesec += 1 + argonpowerbutton_debuglog("lid-monitor", "Open Detected") + + lineobj.release() + chip.close() + except Exception as liderror: + try: + argonpowerbutton_debuglog("lid-monitor-error", str(liderror)) + except: + argonpowerbutton_debuglog("lid-monitor-error", "Error aborting") + #pass + def argonpowerbutton_monitor(writeq): try: @@ -28,7 +127,7 @@ def argonpowerbutton_monitor(writeq): while True: hasevent = lineobj.event_wait(10) if hasevent: - pulsetime = 1 + pulsetime = 0 eventdata = lineobj.event_read() if eventdata.type == gpiod.LineEvent.RISING_EDGE: # Time pulse data @@ -73,7 +172,7 @@ def argonpowerbutton_monitorswitch(writeq): while True: hasevent = lineobj.event_wait(10) if hasevent: - pulsetime = 1 + pulsetime = 0 eventdata = lineobj.event_read() if eventdata.type == gpiod.LineEvent.RISING_EDGE: # Time pulse data diff --git a/source/scripts/argonpowerbutton-rpigpio.py b/source/scripts/argonpowerbutton-rpigpio.py index 4472654..0d40c8c 100644 --- a/source/scripts/argonpowerbutton-rpigpio.py +++ b/source/scripts/argonpowerbutton-rpigpio.py @@ -6,9 +6,99 @@ import RPi.GPIO as GPIO import os import time +# Debug Logger +def argonpowerbutton_debuglog(typestr, logstr): + try: + DEBUGFILE="/dev/shm/argononegpiodebuglog.txt" + tmpstrpadding = " " + + with open(DEBUGFILE, "a") as txt_file: + txt_file.write("["+time.asctime(time.localtime(time.time()))+"] "+typestr.upper()+" "+logstr.strip().replace("\n","\n"+tmpstrpadding)+"\n") + except: + pass + + # This function is the thread that monitors activity in our shutdown pin # The pulse width is measured, and the corresponding shell command will be issued +def argonpowerbutton_getconfigval(keyname, datatype="int"): + keyname = keyname.lower() + fname = "/etc/argononeupd.conf" + try: + with open(fname, "r") as fp: + for curline in fp: + if not curline: + continue + tmpline = curline.replace(" ", "").replace("\t", "") + if not tmpline: + continue + if tmpline[0] == "#": + continue + tmppair = tmpline.split("=") + if len(tmppair) != 2: + continue + + tmpvar = tmppair[0].lower() + if tmpvar != keyname: + continue + + try: + if datatype == "int": + return int(tmppair[1]) + elif datatype == "float": + return float(tmppair[1]) + return tmppair[1] + except: + continue + except: + pass + if datatype == "int": + return -1 + elif datatype == "float": + return -1 + return "" + +def argonpowerbutton_monitorlid(writeq): + try: + argonpowerbutton_debuglog("lid-monitor", "Starting") + monitormode = True + # 0 - Lid is closed, 1 - Lid is open + # Pin Assignments + PIN_LIDMONITOR=27 + + GPIO.setwarnings(False) + GPIO.setmode(GPIO.BCM) + GPIO.setup(PIN_LIDMONITOR, GPIO.IN, pull_up_down=GPIO.PUD_UP) + + while monitormode == True: + pulsetimesec = 1 + GPIO.wait_for_edge(PIN_LIDMONITOR, GPIO.FALLING) + targetsecs = argonpowerbutton_getconfigval("lidshutdownsecs") + if targetsecs > 0: + argonpowerbutton_debuglog("lid-monitor", "Close Detect; Wait for :"+str(targetsecs)) + else: + argonpowerbutton_debuglog("lid-monitor", "Close Detected; Do nothing") + # Time pulse data + time.sleep(1) + while GPIO.input(PIN_LIDMONITOR) == GPIO.LOW: + if targetsecs > 0: + if pulsetimesec >= targetsecs: + argonpowerbutton_debuglog("lid-monitor", "Target Reached, shutting down") + monitormode = False + os.system("shutdown now -h") + break + time.sleep(1) + pulsetimesec += 1 + argonpowerbutton_debuglog("lid-monitor", "Open Detected") + except Exception as liderror: + try: + argonpowerbutton_debuglog("lid-monitor-error", str(liderror)) + except: + argonpowerbutton_debuglog("lid-monitor-error", "Error aborting") + #pass + GPIO.cleanup() + + def argonpowerbutton_monitor(writeq): try: # Pin Assignments