|
| 1 | +#!/usr/bin/php |
| 2 | +<?php |
| 3 | +$skipJSsettings = true; |
| 4 | +require_once('/opt/fpp/www/config.php'); |
| 5 | +require_once('/opt/fpp/www/common.php'); |
| 6 | +require_once('/opt/fpp/www/common/settings.php'); |
| 7 | +function HandleSettings() { |
| 8 | + global $settings; |
| 9 | + if (array_key_exists("TimeZone", $settings)) ApplySetting("TimeZone", $settings["TimeZone"]); |
| 10 | + if (array_key_exists("ntpServer", $settings)) ApplySetting("ntpServer", $settings["ntpServer"]); |
| 11 | + if (array_key_exists("ForceHDMI", $settings)) ApplySetting("ForceHDMI", $settings["ForceHDMI"]); |
| 12 | + if (array_key_exists("ForceHDMIResolution", $settings)) ApplySetting("ForceHDMIResolution", $settings["ForceHDMIResolution"]); |
| 13 | + if (array_key_exists("ForceHDMIResolutionPort2", $settings)) ApplySetting("ForceHDMIResolutionPort2", $settings["ForceHDMIResolutionPort2"]); |
| 14 | + if (array_key_exists("wifiDrivers", $settings)) ApplySetting("wifiDrivers", $settings["wifiDrivers"]); |
| 15 | + if (array_key_exists("GPIOFan", $settings)) ApplySetting("GPIOFan", $settings["GPIOFan"]); |
| 16 | + if (array_key_exists("Kiosk", $settings)) ApplySetting("Kiosk", $settings["Kiosk"]); |
| 17 | + if (array_key_exists("EnableBBBHDMI", $settings)) ApplySetting("EnableBBBHDMI", $settings["EnableBBBHDMI"]); |
| 18 | + if (array_key_exists("Service_rsync", $settings)) ApplyServiceSetting("Service_rsync", $settings["Service_rsync"], "--now"); |
| 19 | + if (array_key_exists("Service_smbd_nmbd", $settings)) ApplyServiceSetting("Service_smbd_nmbd", $settings["Service_smbd_nmbd"], "--now"); |
| 20 | + if (array_key_exists("Service_vsftpd", $settings)) ApplyServiceSetting("Service_vsftpd", $settings["Service_vsftpd"], "--now"); |
| 21 | +} |
| 22 | +function HandleExpandFS() { |
| 23 | + global $settings; |
| 24 | + if ($settings['Platform'] == "BeagleBone Black") { |
| 25 | + $command = "sudo /opt/fpp/SD/BBB-grow_partition.sh 2>&1"; |
| 26 | + } else if ($settings['Platform'] == "Raspberry Pi") { |
| 27 | + $command = "sudo /usr/bin/raspi-config --expand-rootfs"; |
| 28 | + } |
| 29 | + system($command); |
| 30 | + system("/sbin/reboot -f"); |
| 31 | + exit(0); |
| 32 | +} |
| 33 | +$actions = explode(",", $settings["BootActions"]); |
| 34 | +$action = array_shift($actions); |
| 35 | +while ($action != NULL) { |
| 36 | + echo "Performing boot action: " . $action . "\n"; |
| 37 | + |
| 38 | + // save the actions we haven't handled yet back out to settings in case |
| 39 | + // we reboot or something we can keep processing |
| 40 | + $newactions = implode(",", $actions); |
| 41 | + if ($newactions == "") { |
| 42 | + DeleteSettingFromFile("BootActions"); |
| 43 | + } else { |
| 44 | + WriteSettingToFile("BootActions", $newactions); |
| 45 | + } |
| 46 | + |
| 47 | + if ($action == "settings") { |
| 48 | + HandleSettings(); |
| 49 | + } else if ($action == "expandfs") { |
| 50 | + HandleExpandFS(); |
| 51 | + } |
| 52 | + $action = array_shift($actions); |
| 53 | +} |
0 commit comments