Automated Change by GitHub Actions

This commit is contained in:
okunze 2023-06-09 21:02:31 +00:00 committed by github-actions[bot]
parent 3c9023ed94
commit 5c5f9efa6a
2 changed files with 51 additions and 33 deletions

View File

@ -26,6 +26,10 @@ then
if [ "$ID" = "raspbian" ] if [ "$ID" = "raspbian" ]
then then
CHECKPLATFORM="Raspbian" CHECKPLATFORM="Raspbian"
elif [ "$ID" = "debian" ]
then
# For backwards compatibility, continue using raspbian
CHECKPLATFORM="Raspbian"
elif [ "$ID" = "ubuntu" ] elif [ "$ID" = "ubuntu" ]
then then
CHECKPLATFORM="Ubuntu" CHECKPLATFORM="Ubuntu"
@ -71,6 +75,9 @@ daemonconfigfile=/etc/$daemonname.conf
configscript=/usr/bin/argonone-config configscript=/usr/bin/argonone-config
removescript=/usr/bin/argonone-uninstall removescript=/usr/bin/argonone-uninstall
powerbuttonshutdownscript=$powerbuttonscript
daemonfanservice=/lib/systemd/system/$daemonname.service daemonfanservice=/lib/systemd/system/$daemonname.service
if [ ! -f $daemonconfigfile ]; then if [ ! -f $daemonconfigfile ]; then
@ -107,6 +114,7 @@ argon_create_file $shutdownscript
echo "#!/usr/bin/python3" >> $shutdownscript echo "#!/usr/bin/python3" >> $shutdownscript
echo 'import sys' >> $shutdownscript echo 'import sys' >> $shutdownscript
echo 'import time' >> $shutdownscript
echo 'import smbus' >> $shutdownscript echo 'import smbus' >> $shutdownscript
echo 'import RPi.GPIO as GPIO' >> $shutdownscript echo 'import RPi.GPIO as GPIO' >> $shutdownscript
echo 'rev = GPIO.RPI_REVISION' >> $shutdownscript echo 'rev = GPIO.RPI_REVISION' >> $shutdownscript
@ -116,12 +124,14 @@ echo 'else:' >> $shutdownscript
echo ' bus = smbus.SMBus(0)' >> $shutdownscript echo ' bus = smbus.SMBus(0)' >> $shutdownscript
echo 'if len(sys.argv)>1:' >> $shutdownscript echo 'if len(sys.argv)>1:' >> $shutdownscript
echo " bus.write_byte(0x1a,0)" >> $shutdownscript echo ' address=0x1a' >> $shutdownscript
# Fan off
echo " bus.write_byte(address,0)" >> $shutdownscript
# powercut signal # powercut signal
echo ' if sys.argv[1] == "poweroff" or sys.argv[1] == "halt":' >> $shutdownscript echo ' if sys.argv[1] == "poweroff" or sys.argv[1] == "halt":' >> $shutdownscript
echo " try:" >> $shutdownscript echo " try:" >> $shutdownscript
echo " bus.write_byte(0x1a,0xFF)" >> $shutdownscript echo " bus.write_byte(address,0xFF)" >> $shutdownscript
echo " except:" >> $shutdownscript echo " except:" >> $shutdownscript
echo " rev=0" >> $shutdownscript echo " rev=0" >> $shutdownscript
@ -143,23 +153,23 @@ echo ' bus = smbus.SMBus(1)' >> $powerbuttonscript
echo 'else:' >> $powerbuttonscript echo 'else:' >> $powerbuttonscript
echo ' bus = smbus.SMBus(0)' >> $powerbuttonscript echo ' bus = smbus.SMBus(0)' >> $powerbuttonscript
echo 'GPIO.setwarnings(False)' >> $powerbuttonscript echo 'GPIO.setwarnings(False)' >> $powerbuttonshutdownscript
echo 'GPIO.setmode(GPIO.BCM)' >> $powerbuttonscript echo 'GPIO.setmode(GPIO.BCM)' >> $powerbuttonshutdownscript
echo 'shutdown_pin=4' >> $powerbuttonscript echo 'shutdown_pin=4' >> $powerbuttonshutdownscript
echo 'GPIO.setup(shutdown_pin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)' >> $powerbuttonscript echo 'GPIO.setup(shutdown_pin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)' >> $powerbuttonshutdownscript
echo 'def shutdown_check():' >> $powerbuttonscript echo 'def shutdown_check():' >> $powerbuttonshutdownscript
echo ' while True:' >> $powerbuttonscript echo ' while True:' >> $powerbuttonshutdownscript
echo ' pulsetime = 1' >> $powerbuttonscript echo ' pulsetime = 1' >> $powerbuttonshutdownscript
echo ' GPIO.wait_for_edge(shutdown_pin, GPIO.RISING)' >> $powerbuttonscript echo ' GPIO.wait_for_edge(shutdown_pin, GPIO.RISING)' >> $powerbuttonshutdownscript
echo ' time.sleep(0.01)' >> $powerbuttonscript echo ' time.sleep(0.01)' >> $powerbuttonshutdownscript
echo ' while GPIO.input(shutdown_pin) == GPIO.HIGH:' >> $powerbuttonscript echo ' while GPIO.input(shutdown_pin) == GPIO.HIGH:' >> $powerbuttonshutdownscript
echo ' time.sleep(0.01)' >> $powerbuttonscript echo ' time.sleep(0.01)' >> $powerbuttonshutdownscript
echo ' pulsetime += 1' >> $powerbuttonscript echo ' pulsetime += 1' >> $powerbuttonshutdownscript
echo ' if pulsetime >=2 and pulsetime <=3:' >> $powerbuttonscript echo ' if pulsetime >=2 and pulsetime <=3:' >> $powerbuttonshutdownscript
echo ' os.system("reboot")' >> $powerbuttonscript echo ' os.system("reboot")' >> $powerbuttonshutdownscript
echo ' elif pulsetime >=4 and pulsetime <=5:' >> $powerbuttonscript echo ' elif pulsetime >=4 and pulsetime <=5:' >> $powerbuttonshutdownscript
echo ' os.system("shutdown now -h")' >> $powerbuttonscript echo ' os.system("shutdown now -h")' >> $powerbuttonshutdownscript
echo 'def get_fanspeed(tempval, configlist):' >> $powerbuttonscript echo 'def get_fanspeed(tempval, configlist):' >> $powerbuttonscript
echo ' for curconfig in configlist:' >> $powerbuttonscript echo ' for curconfig in configlist:' >> $powerbuttonscript
@ -211,11 +221,12 @@ echo ' return []' >> $powerbuttonscript
echo ' return newconfig' >> $powerbuttonscript echo ' return newconfig' >> $powerbuttonscript
echo 'def temp_check():' >> $powerbuttonscript echo 'def temp_check():' >> $powerbuttonscript
echo ' address=0x1a' >> $powerbuttonscript
echo ' fanconfig = ["65=100", "60=55", "55=10"]' >> $powerbuttonscript echo ' fanconfig = ["65=100", "60=55", "55=10"]' >> $powerbuttonscript
echo ' tmpconfig = load_config("'$daemonconfigfile'")' >> $powerbuttonscript echo ' tmpconfig = load_config("'$daemonconfigfile'")' >> $powerbuttonscript
echo ' if len(tmpconfig) > 0:' >> $powerbuttonscript echo ' if len(tmpconfig) > 0:' >> $powerbuttonscript
echo ' fanconfig = tmpconfig' >> $powerbuttonscript echo ' fanconfig = tmpconfig' >> $powerbuttonscript
echo ' address=0x1a' >> $powerbuttonscript
echo ' prevblock=0' >> $powerbuttonscript echo ' prevblock=0' >> $powerbuttonscript
echo ' while True:' >> $powerbuttonscript echo ' while True:' >> $powerbuttonscript
@ -241,14 +252,14 @@ echo ' temp=""' >> $powerbuttonscript
echo ' time.sleep(30)' >> $powerbuttonscript echo ' time.sleep(30)' >> $powerbuttonscript
echo 'try:' >> $powerbuttonscript echo 'try:' >> $powerbuttonscript
echo ' t1 = Thread(target = shutdown_check)' >> $powerbuttonscript echo ' t1 = Thread(target = shutdown_check)' >> $powerbuttonshutdownscript
echo ' t2 = Thread(target = temp_check)' >> $powerbuttonscript echo ' t2 = Thread(target = temp_check)' >> $powerbuttonscript
echo ' t1.start()' >> $powerbuttonscript echo ' t1.start()' >> $powerbuttonshutdownscript
echo ' t2.start()' >> $powerbuttonscript echo ' t2.start()' >> $powerbuttonscript
echo 'except:' >> $powerbuttonscript echo 'except:' >> $powerbuttonscript
echo ' t1.stop()' >> $powerbuttonscript echo ' t1.stop()' >> $powerbuttonshutdownscript
echo ' t2.stop()' >> $powerbuttonscript echo ' t2.stop()' >> $powerbuttonscript
echo ' GPIO.cleanup()' >> $powerbuttonscript echo ' GPIO.cleanup()' >> $powerbuttonshutdownscript
sudo chmod 755 $powerbuttonscript sudo chmod 755 $powerbuttonscript

View File

@ -1,11 +1,18 @@
#!/bin/bash #!/bin/bash
CHECKPLATFORM="Others"
# Check if Raspbian # Check if Raspbian
grep -q -F 'Raspbian' /etc/os-release &> /dev/null CHECKPLATFORM="Others"
if [ $? -eq 0 ] if [ -f "/etc/os-release" ]
then then
source /etc/os-release
if [ "$ID" = "raspbian" ]
then
CHECKPLATFORM="Raspbian" CHECKPLATFORM="Raspbian"
elif [ "$ID" = "debian" ]
then
# For backwards compatibility, continue using raspbian
CHECKPLATFORM="Raspbian"
fi
fi fi
echo "--------------------------------" echo "--------------------------------"