Fahrinurlaub

Members
  • Posts

    2
  • Joined

  • Last visited

  1. Great! Thanks so much for the prompt reply! This is exactly what I missed. Now everything works as expected.
  2. Dear all, My small server based on the Cubietruck board and Armbian OS (ARMBIAN 5.38 stable Debian GNU/Linux 9 (stretch) 4.14.18-sunxi) runs flawlessly since over 2.5 years now. And I am very happy with this setup. Lately, I installed a battery (5.3 Ah 3.7 V) in order to have the server a bit portable. The battery. driven system runs approx 9 - 10 h. Since I want to prevent that the battery drains out completely I configured the following cronjob: */15 * * * * /home/ncuser/nc_batt_cap_shutdown.sh > /dev/null 2>&1 The content of the script looks as follows: #!/bin/bash ### Script idea taken from: # http://www.schulz-alex.de/cms/index.php/homeautomation-homecontrol/hardwareplattformen/cubietruck/59-akku-fuer-cubietruck LOG_NEW="" LOG_FILE=/home/ncuser/battery_cap_shutdown.log BATPARAM=`cat /sys/class/power_supply/axp20x-battery/uevent` source /sys/class/power_supply/axp20x-battery/uevent AC_POWER_SUPPLY_PRESENT=`cat /sys/class/power_supply/axp20x-ac/present` ### Execute script only if AC adapter is not plugged in if [ ${AC_POWER_SUPPLY_PRESENT} -eq 0 ]; then ### No AC adapter plugged in if [[ ${POWER_SUPPLY_PRESENT} -eq 0 || ${POWER_SUPPLY_ONLINE} -eq 0 ]]; then ### If no battery installed or battery is not discharged exit fi if [[ ${POWER_SUPPLY_ONLINE} -eq 1 && ${POWER_SUPPLY_CAPACITY} -le 10 ]]; then if [ ! -f "$LOG_FILE" ]; then ### Create log file if it is not yet there touch $LOG_FILE fi LOG_NEW+="$(date +'%d.%m.%Y %H:%M:%S')\tBattery capacity too low: ${POWER_SUPPLY_CAPACITY}\n" LOG_NEW+="$(date +'%d.%m.%Y %H:%M:%S')\tOutput server battery state:\n${BATPARAM}\n" LOG_NEW+="$(date +'%d.%m.%Y %H:%M:%S')\tShut down system\n" SUBJECT="[Server] - Shutdown - Battery capacity too low: ${POWER_SUPPLY_CAPACITY}" TO="email@domain.tld" LOG_NEW+="$(date +'%d.%m.%Y %H:%M:%S')\tSend email with battery state info to: ${TO}\n" printf "$LOG_NEW" >> "$LOG_FILE" echo -e "$LOG_NEW" | sudo -u ncuser mutt -s "$SUBJECT" "$TO" -a $LOG_FILE ### Shutdown command taken from: # http://chris.cnie.de/raspberrypi/cubietruck.html sudo shutdown -P -h +0 # sudo poweroff -h exit fi else ### AC adapter plugged in => exit, no battery support required exit fi It runs fine except that it does not shut down. Below the set value of 10 % battery capacity it keeps on sending an email every 15 minutes until the battery is sucked empty. However, logged in using SSH and initiating one of the following commands will execute as expected: sudo shutdown -P -h +0 sudo poweroff -h I searched the forum and other sources on the internet and found some hints to kernels that behaved similarly in the past but I am still not able to find a suitable solution. What am I doing wrong? How did others implemented this use scenario? I would be greatful if somebody points me into the right direction. Thanks a lot in advance. Cheers, George