mirror of
https://github.com/okunze/Argon40-ArgonOne-Script.git
synced 2025-12-13 23:00:37 +01:00
Automated Change by GitHub Action
This commit is contained in:
committed by
github-actions[bot]
parent
b58a168f89
commit
f3386d5f01
@@ -228,6 +228,8 @@ else
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "Installing/updating dependencies..."
|
||||||
|
|
||||||
for curpkg in ${pkglist[@]}; do
|
for curpkg in ${pkglist[@]}; do
|
||||||
sudo apt-get install -y $curpkg
|
sudo apt-get install -y $curpkg
|
||||||
RESULT=$(argon_check_pkg "$curpkg")
|
RESULT=$(argon_check_pkg "$curpkg")
|
||||||
@@ -240,6 +242,8 @@ for curpkg in ${pkglist[@]}; do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
echo "Updating configuration ..."
|
||||||
|
|
||||||
# Ubuntu Mate for RPi has raspi-config too
|
# Ubuntu Mate for RPi has raspi-config too
|
||||||
command -v raspi-config &> /dev/null
|
command -v raspi-config &> /dev/null
|
||||||
if [ $? -eq 0 ]
|
if [ $? -eq 0 ]
|
||||||
@@ -271,8 +275,9 @@ then
|
|||||||
rm $TMPCONFIGFILE
|
rm $TMPCONFIGFILE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Added to enabled NVMe for pi5
|
# Additional config for pi5
|
||||||
set_nvme_default
|
set_nvme_default
|
||||||
|
set_maxusbcurrent
|
||||||
|
|
||||||
# Fan Setup
|
# Fan Setup
|
||||||
basename="argonone"
|
basename="argonone"
|
||||||
@@ -289,6 +294,7 @@ daemonfanservice=/lib/systemd/system/$daemonname.service
|
|||||||
|
|
||||||
daemonhddconfigfile=/etc/${daemonname}-hdd.conf
|
daemonhddconfigfile=/etc/${daemonname}-hdd.conf
|
||||||
|
|
||||||
|
echo "Installing/Updating scripts and services ..."
|
||||||
|
|
||||||
if [ -f "$eepromrpiscript" ]
|
if [ -f "$eepromrpiscript" ]
|
||||||
then
|
then
|
||||||
@@ -304,6 +310,13 @@ then
|
|||||||
sudo chmod 755 $upsconfigscript
|
sudo chmod 755 $upsconfigscript
|
||||||
fi
|
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
|
# Fan Config Script
|
||||||
sudo wget $ARGONDOWNLOADSERVER/scripts/argonone-fanconfig.sh -O $fanconfigscript --quiet
|
sudo wget $ARGONDOWNLOADSERVER/scripts/argonone-fanconfig.sh -O $fanconfigscript --quiet
|
||||||
sudo chmod 755 $fanconfigscript
|
sudo chmod 755 $fanconfigscript
|
||||||
@@ -705,6 +718,8 @@ fi
|
|||||||
shortcutfile="/home/$destfoldername/Desktop/argonone-config.desktop"
|
shortcutfile="/home/$destfoldername/Desktop/argonone-config.desktop"
|
||||||
if [ -d "/home/$destfoldername/Desktop" ]
|
if [ -d "/home/$destfoldername/Desktop" ]
|
||||||
then
|
then
|
||||||
|
echo "Creating/Updating Desktop Elements ..."
|
||||||
|
|
||||||
terminalcmd="lxterminal --working-directory=/home/$destfoldername/ -t"
|
terminalcmd="lxterminal --working-directory=/home/$destfoldername/ -t"
|
||||||
if [ -f "/home/$destfoldername/.twisteros.twid" ]
|
if [ -f "/home/$destfoldername/.twisteros.twid" ]
|
||||||
then
|
then
|
||||||
@@ -735,6 +750,8 @@ fi
|
|||||||
|
|
||||||
configcmd="$(basename -- $configscript)"
|
configcmd="$(basename -- $configscript)"
|
||||||
|
|
||||||
|
echo "Initializing Services ..."
|
||||||
|
|
||||||
if [ "$setupmode" = "Setup" ]
|
if [ "$setupmode" = "Setup" ]
|
||||||
then
|
then
|
||||||
if [ -f "/usr/bin/$configcmd" ]
|
if [ -f "/usr/bin/$configcmd" ]
|
||||||
@@ -772,10 +789,12 @@ else
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
if [ "$CHECKPLATFORM" = "Raspbian" ]
|
if [ "$CHECKPLATFORM" = "Raspbian" ]
|
||||||
then
|
then
|
||||||
if [ -f "$eepromrpiscript" ]
|
if [ -f "$eepromrpiscript" ]
|
||||||
then
|
then
|
||||||
|
echo "Checking EEPROM ..."
|
||||||
sudo apt-get update && sudo apt-get upgrade -y
|
sudo apt-get update && sudo apt-get upgrade -y
|
||||||
sudo rpi-eeprom-update
|
sudo rpi-eeprom-update
|
||||||
# EEPROM Config Script
|
# EEPROM Config Script
|
||||||
@@ -785,8 +804,6 @@ else
|
|||||||
echo "WARNING: EEPROM not updated. Please run this under Raspberry Pi OS"
|
echo "WARNING: EEPROM not updated. Please run this under Raspberry Pi OS"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
set_maxusbcurrent
|
|
||||||
|
|
||||||
|
|
||||||
echo "*********************"
|
echo "*********************"
|
||||||
echo " $setupmode Completed "
|
echo " $setupmode Completed "
|
||||||
|
|||||||
@@ -98,9 +98,13 @@ then
|
|||||||
sudo systemctl stop argonupsrtcd.service
|
sudo systemctl stop argonupsrtcd.service
|
||||||
sudo systemctl disable argonupsrtcd.service
|
sudo systemctl disable argonupsrtcd.service
|
||||||
|
|
||||||
|
sudo systemctl --global stop argononeupsduser.service
|
||||||
|
sudo systemctl --global disable argononeupsduser.service
|
||||||
|
|
||||||
# Remove files
|
# Remove files
|
||||||
sudo rm /lib/systemd/system/argononeupsd.service
|
sudo rm /lib/systemd/system/argononeupsd.service
|
||||||
sudo rm /lib/systemd/system/argonupsrtcd.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
|
find "/home" -maxdepth 1 -type d | while read line; do
|
||||||
shortcutfile="$line/Desktop/argonone-ups.desktop"
|
shortcutfile="$line/Desktop/argonone-ups.desktop"
|
||||||
@@ -128,7 +132,7 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Delete config files
|
# 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
|
do
|
||||||
if [ -f "/etc/${configfile}.conf" ]
|
if [ -f "/etc/${configfile}.conf" ]
|
||||||
then
|
then
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
VERSIONINFO="2507001"
|
VERSIONINFO="2511001"
|
||||||
|
|
||||||
echo "Version $VERSIONINFO"
|
echo "Version $VERSIONINFO"
|
||||||
if [ -z "$1" ]
|
if [ -z "$1" ]
|
||||||
|
|||||||
@@ -368,4 +368,7 @@ def mainloop(stdscr):
|
|||||||
except Exception as closeerr:
|
except Exception as closeerr:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
curses.wrapper(mainloop)
|
try:
|
||||||
|
curses.wrapper(mainloop)
|
||||||
|
except Exception as wrapperr:
|
||||||
|
pass
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ if os.path.exists("/etc/argon/argoneonoled.py"):
|
|||||||
OLED_CONFIGFILE = "/etc/argoneonoled.conf"
|
OLED_CONFIGFILE = "/etc/argoneonoled.conf"
|
||||||
UNIT_CONFIGFILE = "/etc/argonunits.conf"
|
UNIT_CONFIGFILE = "/etc/argonunits.conf"
|
||||||
|
|
||||||
|
SHUTDOWN_FLAGFILE = "/dev/shm/argonshutdownflag.txt"
|
||||||
|
|
||||||
# This function converts the corresponding fanspeed for the given temperature
|
# This function converts the corresponding fanspeed for the given temperature
|
||||||
# The configuration data is a list of strings in the form "<temperature>=<speed>"
|
# The configuration data is a list of strings in the form "<temperature>=<speed>"
|
||||||
|
|
||||||
@@ -257,6 +259,13 @@ def display_loop(readq):
|
|||||||
screenenabled = []
|
screenenabled = []
|
||||||
|
|
||||||
while len(screenenabled) > 0:
|
while len(screenenabled) > 0:
|
||||||
|
try:
|
||||||
|
if os.path.isfile(SHUTDOWN_FLAGFILE):
|
||||||
|
display_defaultimg()
|
||||||
|
return
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
if len(curlist) == 0 and screenjogflag == 1:
|
if len(curlist) == 0 and screenjogflag == 1:
|
||||||
# Reset Screen Saver
|
# Reset Screen Saver
|
||||||
screensavermode = False
|
screensavermode = False
|
||||||
@@ -565,9 +574,18 @@ def display_defaultimg():
|
|||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
cmd = sys.argv[1].upper()
|
cmd = sys.argv[1].upper()
|
||||||
if cmd == "SHUTDOWN":
|
if cmd == "SHUTDOWN":
|
||||||
|
try:
|
||||||
|
with open(SHUTDOWN_FLAGFILE, "w") as f:
|
||||||
|
f.write("signalled")
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
# Signal poweroff
|
# Signal poweroff
|
||||||
argonregister_signalpoweroff(bus)
|
argonregister_signalpoweroff(bus)
|
||||||
|
|
||||||
|
if OLED_ENABLED == True:
|
||||||
|
display_defaultimg()
|
||||||
|
|
||||||
elif cmd == "FANOFF":
|
elif cmd == "FANOFF":
|
||||||
# Turn off fan
|
# Turn off fan
|
||||||
argonregister_setfanspeed(bus,0)
|
argonregister_setfanspeed(bus,0)
|
||||||
|
|||||||
@@ -6,9 +6,108 @@ import gpiod
|
|||||||
import os
|
import os
|
||||||
import time
|
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
|
# 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
|
# 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):
|
def argonpowerbutton_monitor(writeq):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -28,7 +127,7 @@ def argonpowerbutton_monitor(writeq):
|
|||||||
while True:
|
while True:
|
||||||
hasevent = lineobj.event_wait(10)
|
hasevent = lineobj.event_wait(10)
|
||||||
if hasevent:
|
if hasevent:
|
||||||
pulsetime = 1
|
pulsetime = 0
|
||||||
eventdata = lineobj.event_read()
|
eventdata = lineobj.event_read()
|
||||||
if eventdata.type == gpiod.LineEvent.RISING_EDGE:
|
if eventdata.type == gpiod.LineEvent.RISING_EDGE:
|
||||||
# Time pulse data
|
# Time pulse data
|
||||||
@@ -73,7 +172,7 @@ def argonpowerbutton_monitorswitch(writeq):
|
|||||||
while True:
|
while True:
|
||||||
hasevent = lineobj.event_wait(10)
|
hasevent = lineobj.event_wait(10)
|
||||||
if hasevent:
|
if hasevent:
|
||||||
pulsetime = 1
|
pulsetime = 0
|
||||||
eventdata = lineobj.event_read()
|
eventdata = lineobj.event_read()
|
||||||
if eventdata.type == gpiod.LineEvent.RISING_EDGE:
|
if eventdata.type == gpiod.LineEvent.RISING_EDGE:
|
||||||
# Time pulse data
|
# Time pulse data
|
||||||
|
|||||||
@@ -6,9 +6,99 @@ import RPi.GPIO as GPIO
|
|||||||
import os
|
import os
|
||||||
import time
|
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
|
# 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
|
# 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):
|
def argonpowerbutton_monitor(writeq):
|
||||||
try:
|
try:
|
||||||
# Pin Assignments
|
# Pin Assignments
|
||||||
|
|||||||
Reference in New Issue
Block a user