diff --git a/docker/fxsupport/linux/commands.sh b/docker/fxsupport/linux/commands.sh index 6f9bb02..3b5c9cc 100644 --- a/docker/fxsupport/linux/commands.sh +++ b/docker/fxsupport/linux/commands.sh @@ -51,7 +51,7 @@ do TIME=${TIME:-999999} echo "Setting LED: Color=$COLOR, Time=$TIME" - python /usr/bin/fula/control_led.py "$COLOR" "$TIME" 100 + python /usr/bin/fula/control_led.py "$COLOR" "$TIME" 100 & ;; ".command_reboot") # Perform the reboot diff --git a/docker/fxsupport/linux/control_led.py b/docker/fxsupport/linux/control_led.py index f2f9a3f..7d659b2 100644 --- a/docker/fxsupport/linux/control_led.py +++ b/docker/fxsupport/linux/control_led.py @@ -1,5 +1,6 @@ import os import time +import datetime import argparse import logging import psutil @@ -22,6 +23,62 @@ 'dark_green': {'red': 0, 'green': 50, 'blue': 0} } +if os.path.exists("/sys/module/rockchipdrm"): + led_r_pin="red" + led_b_pin="blue" + led_g_pin="green" +else: + import RPi.GPIO as GPIO + led_r_pin=24 + led_b_pin=16 + led_g_pin=12 + GPIO.setmode(GPIO.BCM) + GPIO.setwarnings(False) + GPIO.setup(led_r_pin, GPIO.OUT) + GPIO.setup(led_b_pin, GPIO.OUT) + GPIO.setup(led_g_pin, GPIO.OUT) + +def write_persistence_file(color, time_param, brightness, persist): + logging.info(f"Writing to persistence file: Color={color}, Time={time_param}, Brightness={brightness}, Persist={persist}") + if persist: + with open('/home/pi/control_led.per', 'w') as f: + current_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") + logging.info("write_persistence_file") + f.write(f"{current_time}\n{color}\n{time_param}\n{brightness}") + +def read_persistence_file(): + logging.info("Reading persistence file") + try: + with open('/home/pi/control_led.per', 'r') as f: + saved_time_str = f.readline().strip() + color = f.readline().strip() + time_param_str = f.readline().strip() + brightness_str = f.readline().strip() + logging.info(f"Reading persistence file: Color={color}, time_param_str={time_param_str}, brightness_str={brightness_str}") + + time_param = int(time_param_str) + brightness = int(brightness_str) + saved_time = datetime.datetime.strptime(saved_time_str, "%Y-%m-%d %H:%M:%S") + current_time = datetime.datetime.now() + elapsed = (current_time - saved_time).total_seconds() + logging.info(f"Reading persistence file: Color={color}, time_param={time_param}, saved_time={saved_time}") + if time_param != 999999: + remaining_time = max(0, time_param - int(elapsed)) + if remaining_time <= 0: + os.remove('/home/pi/control_led.per') + return None, None, None + else: + remaining_time = 999999 + return color, remaining_time, brightness + except FileNotFoundError: + pass + except ValueError as e: + logging.error(f"Error parsing time_param or brightness as integers: {e}") + except Exception as e: + logging.error(f"Unexpected error reading persistence file: {e}") + return None, None, None + + def turn_off_all_leds(): for color in ['red', 'green', 'blue']: set_led_brightness(color, 0) @@ -38,23 +95,9 @@ def kill_led_processes_except_self(): for proc in psutil.process_iter(['pid', 'name', 'cmdline']): # Exclude current process from being killed if proc.info['pid'] != current_pid and proc.info['cmdline'] and 'control_led.py' in ' '.join(proc.info['cmdline']): + logging.info(f'{proc.info["pid"]} is killed in {current_pid}.') proc.kill() # kill the process -if os.path.exists("/sys/module/rockchipdrm"): - led_r_pin="red" - led_b_pin="blue" - led_g_pin="green" -else: - import RPi.GPIO as GPIO - led_r_pin=24 - led_b_pin=16 - led_g_pin=12 - GPIO.setmode(GPIO.BCM) - GPIO.setwarnings(False) - GPIO.setup(led_r_pin, GPIO.OUT) - GPIO.setup(led_b_pin, GPIO.OUT) - GPIO.setup(led_g_pin, GPIO.OUT) - # function to control individual LED def individual_led_control(color, brightness=100): if color in color_combinations: @@ -77,38 +120,56 @@ def set_led_brightness(color, brightness): # Assuming GPIO.LOW simulates full brightness without actual PWM support GPIO.output({"red": led_r_pin, "green": led_g_pin, "blue": led_b_pin}.get(color), GPIO.LOW) + +def execute_led_control(color, time_param, brightness): + """Executes the LED control command and optionally checks for persisted state.""" + logging.info(f"Executing LED control: Color={color}, Time={time_param}, Brightness={brightness}") + kill_led_processes_except_self() + individual_led_control(color, brightness) + if time_param == -1 or time_param == 0: + turn_off_all_leds() + elif time_param != 999999: + logging.info(f'{color} LED was turned on for {time_param} seconds.') + time.sleep(time_param) + turn_off_all_leds() + else: + logging.info(f'{color} LED was turned on indefinitely.') + #setup logging logging.basicConfig(filename='/home/pi/fula.sh.log', filemode='a', level=logging.INFO, format='%(asctime)s %(message)s') -# Create a parser for command line arguments -parser = argparse.ArgumentParser(description='Control LEDs.') -parser.add_argument('color', type=str, choices=['red', 'green', 'blue', 'light_blue', 'yellow', 'light_green', 'light_purple', 'white'], help='LED color.') -parser.add_argument('time', type=int, default=3, help='Time to flash the LED.') -parser.add_argument('brightness', nargs='?', default=100, type=int, help='Brightness level (0-100). Default is 100.') +def main(): + parser = argparse.ArgumentParser(description='Control LEDs.') + parser.add_argument('color', choices=color_combinations.keys(), help='LED color.') + parser.add_argument('time', type=int, help='Time to keep the LED on.') + parser.add_argument('brightness', nargs='?', default=100, type=int, help='Brightness level (0-100).') + parser.add_argument('--persist', action='store_true', help='Persist LED state across calls.') + parser.add_argument('--background', action='store_true', help='Indicates background execution for persisted state') + args = parser.parse_args() -args = parser.parse_args() -logging.info(f'{args.color} and {args.time} was received.') + logging.info(f"Received command: Color={args.color}, Time={args.time}, Brightness={args.brightness}, Persist={args.persist}") + + if args.background: + # If running in background mode, skip persistence logic to prevent recursion + execute_led_control(args.color, args.time, args.brightness) + else: + # Normal execution flow + if args.persist: + write_persistence_file(args.color, args.time, args.brightness, args.persist) + + execute_led_control(args.color, args.time, args.brightness) -led_pin = {"red": led_r_pin, "green": led_g_pin, "blue": led_b_pin}.get(args.color) + # Check for persisted state and execute in background if needed + persisted_color, persisted_time, persisted_brightness = read_persistence_file() + if persisted_color and persisted_time is not None and persisted_brightness is not None: + command = f'python {__file__} {persisted_color} {persisted_time} {persisted_brightness} --background' + subprocess.Popen(command, shell=True) -try: - if args.time == -1 or args.time == 0: - turn_off_all_leds() - kill_led_processes_except_self() - elif args.time != 999999: # Check if the time is not 999999 - individual_led_control(args.color, args.brightness) - logging.info(f'{args.color} LED was turned on.') - # Only start the timer if the time is not 999999 - timer = threading.Timer(args.time, turn_off_all_leds) - timer.start() - else: - # If the time is 999999, turn on the LED without setting a timer to turn it off - individual_led_control(args.color, args.brightness) - logging.info(f'{args.color} LED was turned on and will stay on indefinitely.') - -except KeyboardInterrupt: - logging.info('Interrupted by user.') - if 'timer' in locals(): - timer.cancel() - +logging.basicConfig(filename='/home/pi/fula.sh.log', filemode='a', level=logging.INFO, format='%(asctime)s %(message)s') + +if __name__ == "__main__": + try: + main() + except KeyboardInterrupt: + logging.info('Script interrupted by user.') \ No newline at end of file diff --git a/docker/fxsupport/linux/fula-readiness-check.service b/docker/fxsupport/linux/fula-readiness-check.service new file mode 100644 index 0000000..cd315e1 --- /dev/null +++ b/docker/fxsupport/linux/fula-readiness-check.service @@ -0,0 +1,13 @@ +[Unit] +Description=Fula Readiness Check Service +After=network.target + +[Service] +Type=simple +User=root +ExecStart=/usr/bin/python /usr/bin/fula/readiness-check.py +Restart=on-failure +RestartSec=5s + +[Install] +WantedBy=multi-user.target diff --git a/docker/fxsupport/linux/fula.sh b/docker/fxsupport/linux/fula.sh index 87d57ba..37be181 100644 --- a/docker/fxsupport/linux/fula.sh +++ b/docker/fxsupport/linux/fula.sh @@ -168,12 +168,6 @@ function install() { all_success=true mkdir -p ${HOME_DIR}/.internal - if [ "$arch" == "RK1" ] || [ "$arch" == "RPI4" ]; then - if [ -f "$INSTALLATION_FULA_DIR/control_led.py" ]; then - python control_led.py blue 100 2>&1 | tee -a $FULA_LOG_PATH & - fi - fi - if test -f /etc/apt/apt.conf.d/proxy.conf; then sudo rm /etc/apt/apt.conf.d/proxy.conf; fi setup_logrotate $FULA_LOG_PATH || { echo "Error setting up logrotate" 2>&1 | sudo tee -a $FULA_LOG_PATH; all_success=false; } || true mkdir -p ${HOME_DIR}/commands/ 2>&1 | sudo tee -a $FULA_LOG_PATH || { echo "Error making directory $HOME_DIR/commands/" 2>&1 | sudo tee -a $FULA_LOG_PATH; all_success=false; } || true @@ -269,6 +263,7 @@ function install() { sudo cp ${INSTALLATION_FULA_DIR}/fula.service $SYSTEMD_PATH/ 2>&1 | sudo tee -a $FULA_LOG_PATH || { echo "Error copying fula.service" | sudo tee -a $FULA_LOG_PATH; } || true sudo cp ${INSTALLATION_FULA_DIR}/commands.service $SYSTEMD_PATH/ 2>&1 | sudo tee -a $FULA_LOG_PATH || { echo "Error copying commands.service" | sudo tee -a $FULA_LOG_PATH; } || true sudo cp ${INSTALLATION_FULA_DIR}/uniondrive.service $SYSTEMD_PATH/ 2>&1 | sudo tee -a $FULA_LOG_PATH || { echo "Error copying uniondrive.service" | sudo tee -a $FULA_LOG_PATH; } || true + sudo cp ${INSTALLATION_FULA_DIR}/fula-readiness-check.service $SYSTEMD_PATH/ 2>&1 | sudo tee -a $FULA_LOG_PATH || { echo "Error copying fula-readiness-check.service" | sudo tee -a $FULA_LOG_PATH; } || true if [ -f "$FULA_PATH/docker.env" ]; then sudo rm ${FULA_PATH}/docker.env 2>&1 | sudo tee -a $FULA_LOG_PATH || { echo "Error removing $FULA_PATH/docker.env" | sudo tee -a $FULA_LOG_PATH; } || true @@ -345,12 +340,19 @@ function install() { if [ "$arch" == "RK1" ] || [ "$arch" == "RPI4" ]; then systemctl daemon-reload 2>&1 | sudo tee -a $FULA_LOG_PATH || { echo "Error daemon reload" | sudo tee -a $FULA_LOG_PATH; all_success=false; } fi + systemctl enable uniondrive.service 2>&1 | sudo tee -a $FULA_LOG_PATH || { echo "Error enableing uniondrive.service" | sudo tee -a $FULA_LOG_PATH; all_success=false; } echo "Installing Uniondrive Finished" | sudo tee -a $FULA_LOG_PATH + systemctl enable fula.service 2>&1 | sudo tee -a $FULA_LOG_PATH || { echo "Error enableing fula.service" | sudo tee -a $FULA_LOG_PATH; all_success=false; } echo "Installing Fula Finished" | sudo tee -a $FULA_LOG_PATH + systemctl enable commands.service 2>&1 | sudo tee -a $FULA_LOG_PATH || { echo "Error enableing commands.service" | sudo tee -a $FULA_LOG_PATH; all_success=false; } echo "Installing Commands Finished" | sudo tee -a $FULA_LOG_PATH + + systemctl enable fula-readiness-check.service 2>&1 | sudo tee -a $FULA_LOG_PATH || { echo "Error enableing fula-readiness-check.service" | sudo tee -a $FULA_LOG_PATH; all_success=false; } + echo "Installing fula-readiness-check Finished" | sudo tee -a $FULA_LOG_PATH + echo "Setting up cron job for manual update" | sudo tee -a $FULA_LOG_PATH create_cron 2>&1 | sudo tee -a $FULA_LOG_PATH || { echo "Could not setup cron job" | sudo tee -a $FULA_LOG_PATH; all_success=false; } || true echo "installation done with all_success=$all_success" | sudo tee -a $FULA_LOG_PATH @@ -359,14 +361,14 @@ function install() { touch ${HOME_DIR}/V6.info 2>&1 | sudo tee -a $FULA_LOG_PATH || { echo "Error creating version file" | sudo tee -a $FULA_LOG_PATH; } if [ "$arch" == "RK1" ] || [ "$arch" == "RPI4" ]; then if [ -f "$FULA_PATH/control_led.py" ]; then - python ${FULA_PATH}/control_led.py green 2 2>&1 | sudo tee -a $FULA_LOG_PATH + python ${FULA_PATH}/control_led.py white 5 2>&1 | sudo tee -a $FULA_LOG_PATH fi fi else echo "Installation finished with errors, version file not created." | sudo tee -a $FULA_LOG_PATH if [ "$arch" == "RK1" ] || [ "$arch" == "RPI4" ]; then if [ -f "$FULA_PATH/control_led.py" ]; then - python ${FULA_PATH}/control_led.py red 3 2>&1 | sudo tee -a $FULA_LOG_PATH + python ${FULA_PATH}/control_led.py red 5 2>&1 | sudo tee -a $FULA_LOG_PATH fi fi fi @@ -621,6 +623,12 @@ function remove() { fi rm -f $SYSTEMD_PATH/commands.service + if service_exists fula-readiness-check.service; then + systemctl stop fula-readiness-check.service -q + systemctl disable fula-readiness-check.service -q + fi + rm -f $SYSTEMD_PATH/fula-readiness-check.service + systemctl daemon-reload dockerPrune echo "Removing Fula Finished" | sudo tee -a $FULA_LOG_PATH @@ -694,11 +702,24 @@ function killPullImage() { # Commands case $1 in "install") - echo "ran install at: $(date)" | sudo tee -a $FULA_LOG_PATH + arch=${2:-RK1} + echo "ran install at: $(date) for $arch" | sudo tee -a $FULA_LOG_PATH + + if [ "$arch" == "RK1" ] || [ "$arch" == "RPI4" ]; then + if [ -f "$FULA_PATH/control_led.py" ]; then + python ${FULA_PATH}/control_led.py light_purple 9000 & + fi + fi install "${2:-RK1}" 2>&1 | sudo tee -a $FULA_LOG_PATH ;; "start" | "restart") - echo "ran start V6 at: $(date)" | sudo tee -a $FULA_LOG_PATH + arch=${2:-RK1} + echo "ran start V6 at: $(date) for $arch" | sudo tee -a $FULA_LOG_PATH + if [ "$arch" == "RK1" ] || [ "$arch" == "RPI4" ]; then + if [ -f "$FULA_PATH/control_led.py" ]; then + python ${FULA_PATH}/control_led.py white 9000 & + fi + fi if ! restart 2>&1 | sudo tee -a $FULA_LOG_PATH; then echo "restart command failed, but continuing..." | sudo tee -a $FULA_LOG_PATH @@ -731,7 +752,8 @@ case $1 in echo "sync status=> $?" | sudo tee -a $FULA_LOG_PATH ;; "stop") - echo "ran stop at: $(date)" | sudo tee -a $FULA_LOG_PATH + arch=${2:-RK1} + echo "ran stop at: $(date) for $arch" | sudo tee -a $FULA_LOG_PATH dockerComposeDown if [ -f $HOME_DIR/update.pid ]; then @@ -739,6 +761,12 @@ case $1 in kill $(cat $HOME_DIR/update.pid) || { echo "Error Killing update Process" | sudo tee -a $FULA_LOG_PATH; } || true sudo rm $HOME_DIR/update.pid | sudo tee -a $FULA_LOG_PATH || { echo "Error removing update.pid" | sudo tee -a $FULA_LOG_PATH; } || true fi + + if [ "$arch" == "RK1" ] || [ "$arch" == "RPI4" ]; then + if [ -f "$FULA_PATH/control_led.py" ]; then + python ${FULA_PATH}/control_led.py red 0 2>&1 | sudo tee -a $FULA_LOG_PATH + fi + fi ;; "rebuild") echo "ran rebuild at: $(date)" | sudo tee -a $FULA_LOG_PATH diff --git a/docker/fxsupport/linux/readiness-check.py b/docker/fxsupport/linux/readiness-check.py new file mode 100644 index 0000000..2b94f35 --- /dev/null +++ b/docker/fxsupport/linux/readiness-check.py @@ -0,0 +1,58 @@ +import os +import subprocess +import time +import logging +import sys + +# Configure logging to write to standard output +logging.basicConfig( + level=logging.INFO, + format='%(asctime)s - %(levelname)s - %(message)s', + stream=sys.stdout, +) + +def check_conditions(): + # Check all required conditions + conditions = [ + os.path.exists("/usr/bin/fula/.partition_flg"), + os.path.exists("/usr/bin/fula/.resize_flg"), + os.path.exists("/home/pi/V6.info"), + "fula_go" in subprocess.getoutput("docker ps --format '{{.Names}}'"), + os.path.exists("/uniondrive"), # Check if /uniondrive directory exists + "active" in subprocess.getoutput("systemctl is-active fula.service"), + "active" in subprocess.getoutput("systemctl is-active uniondrive.service") # Check if uniondrive service is running + ] + return all(conditions) + +def check_wifi_connection(): + # Check the active WiFi connection + output = subprocess.getoutput("nmcli con show --active") + logging.info(f"Active connections: {output}") # Log the output for debugging + if "FxBlox" in output: + return "FxBlox" + elif "wifi" in output: + return "other" + return None + +def main(): + logging.info("readiness check started") + while True: + if check_conditions(): + logging.info("check_conditions passed") + wifi_status = check_wifi_connection() + if wifi_status == "FxBlox": + logging.info("wifi_status FxBlox") + subprocess.run(["python", "/usr/bin/fula/control_led.py", "cyan", "5"]) + elif wifi_status == "other": + logging.info("wifi_status other") + subprocess.run(["python", "/usr/bin/fula/control_led.py", "green", "30"]) + break # Exit the loop as no further check is needed + else: + logging.info("wifi_status not connected") + subprocess.run(["python", "/usr/bin/fula/control_led.py", "yellow", "5"]) + else: + logging.info("check_conditions failed") + time.sleep(5) + +if __name__ == "__main__": + main() diff --git a/docker/fxsupport/linux/resize.sh b/docker/fxsupport/linux/resize.sh index 0dfd434..e27d88f 100644 --- a/docker/fxsupport/linux/resize.sh +++ b/docker/fxsupport/linux/resize.sh @@ -1,6 +1,43 @@ #!/bin/sh - +HOME_DIR=/home/pi force_partition="${1:-0}" +services_stopped=0 +services_started=0 + +if [ -f $HOME_DIR/control_led.per ]; then + sudo rm $HOME_DIR/control_led.per +fi + +# Function to stop services +stop_services() { + if [ "$services_stopped" -eq 0 ]; then + echo "Stopping services..." + python /usr/bin/fula/control_led.py light_purple 999999 --persist & + sudo systemctl stop fula.service + echo "Fula service stopped..." + sudo systemctl stop uniondrive.service + echo "uniondrive service stopped..." + services_stopped=1 + fi +} + +# Function to start services +start_services() { + if [ "$services_started" -eq 0 ]; then + echo "Starting services..." + sudo systemctl start uniondrive.service + echo "uniondrive service started..." + sudo systemctl start fula.service + echo "fula service started..." + if [ -f $HOME_DIR/control_led.per ]; then + sudo rm $HOME_DIR/control_led.per + fi + if [ -f /usr/bin/fula/control_led.py ]; then + python /usr/bin/fula/control_led.py yellow 30 & + fi + services_started=1 + fi +} format_sd_devices() { force="$1" @@ -12,6 +49,7 @@ format_sd_devices() { PARTITIONS=$(sudo fdisk -l "$DEVICE" | grep "^${DEVICE}[0-9]*") if [ -z "$PARTITIONS" ] || [ "$force" -eq 1 ]; then echo "The device $DEVICE is not formatted or force format is requested. Formatting now..." + stop_services # Unmount any mounted partitions on the device before formatting MOUNTED_PARTS=$(lsblk -lnp -o NAME,MOUNTPOINT "$DEVICE" | awk '$2 != "" {print $1}') @@ -65,6 +103,9 @@ format_sd_devices() { sudo mount "${DEVICE}1" "/media/pi/${DEVICE_PATH}" sudo touch "/media/pi/${DEVICE_PATH}/formatted${DEVICE_PATH}.txt" sudo sync + start_services + sleep 1 + sudo reboot else printf "The device %s is already formatted." "$DEVICE" fi @@ -81,6 +122,7 @@ format_nvme() { PARTITIONS=$(sudo fdisk -l $DEVICE | grep "^${DEVICE}p[0-9]*") if [ -z "$PARTITIONS" ] || [ "$force" -eq 1 ]; then echo "The device $DEVICE is not formatted or force format is requested. Formatting now..." + stop_services # Unmount any mounted partitions on the device before formatting MOUNTED_PARTS=$(lsblk -lnp -o NAME,MOUNTPOINT "$DEVICE" | awk '$2 != "" {print $1}') @@ -134,6 +176,9 @@ format_nvme() { sudo mount "${DEVICE}p1" "/media/pi/${DEVICE_PATH}" sudo touch "/media/pi/${DEVICE_PATH}/formatted${DEVICE_PATH}.txt" sudo sync + start_services + sleep 1 + sudo reboot else echo "The device is formatted." fi @@ -146,13 +191,18 @@ partition_flag=/usr/bin/fula/.partition_flg if test -f /etc/apt/apt.conf.d/proxy.conf; then sudo rm /etc/apt/apt.conf.d/proxy.conf; fi resize_rootfs () { + python /usr/bin/fula/control_led.py light_purple 999999 --persist & if [ -d "/sys/module/rockchipdrm" ]; then echo "Running on RockChip." sudo /usr/lib/armbian/armbian-resize-filesystem start echo "Rootfs expanded..." - - python /usr/bin/fula/control_led.py blue 2 + if [ -f $HOME_DIR/control_led.per ]; then + sudo rm $HOME_DIR/control_led.per + fi + if [ -f /usr/bin/fula/control_led.py ]; then + python /usr/bin/fula/control_led.py yellow 20 & + fi sudo touch "${resize_flag}" sudo reboot exit 0 @@ -160,7 +210,12 @@ resize_rootfs () { echo "Not running on RockChip." sudo raspi-config --expand-rootfs echo "Rootfs expanded..." - python /usr/bin/fula/control_led.py blue 2 + if [ -f $HOME_DIR/control_led.per ]; then + sudo rm $HOME_DIR/control_led.per + fi + if [ -f /usr/bin/fula/control_led.py ]; then + python /usr/bin/fula/control_led.py yellow 20 & + fi sudo touch "${resize_flag}" sudo reboot exit 0 @@ -170,28 +225,12 @@ resize_rootfs () { partition_fs () { force_format="$1" if [ -d "/sys/module/rockchipdrm" ]; then - sudo systemctl stop fula.service - echo "Fula service stopped..." - sleep 1 - - sudo systemctl stop uniondrive.service - echo "uniondrive service stopped..." - sleep 1 format_sd_devices "$force_format" || { echo "Failed to format nvme"; } || true format_nvme "$force_format" || { echo "Failed to format nvme"; } || true sudo touch "${partition_flag}" - sudo systemctl start uniondrive.service - echo "uniondrive service started..." - sleep 1 - sudo systemctl start fula.service - echo "fula service started..." - sleep 1 - python /usr/bin/fula/control_led.py blue 2 - sudo reboot exit 0 else sudo touch "${partition_flag}" - python /usr/bin/fula/control_led.py green 3 exit 0 fi } @@ -200,7 +239,6 @@ if [ -f "$resize_flag" ]; then echo "File exists. so no need to expand." if [ -f "$partition_flag" ]; then echo "Partition exists. so no need to parition." - python /usr/bin/fula/control_led.py green 3 else partition_fs "$force_partition" fi diff --git a/docker/fxsupport/linux/update.sh b/docker/fxsupport/linux/update.sh index b747e14..7d28fa2 100644 --- a/docker/fxsupport/linux/update.sh +++ b/docker/fxsupport/linux/update.sh @@ -25,7 +25,7 @@ for device in "${devices[@]}"; do sudo pkill -f "control_led.py" || { echo "Error Killing control_led" >> $FULA_LOG_PATH 2>&1; } fi - python /usr/bin/fula/control_led.py blue 200 >> $FULA_LOG_PATH 2>&1 & + python /usr/bin/fula/control_led.py yellow 200 >> $FULA_LOG_PATH 2>&1 & sudo systemctl stop fula if [ -d "$mountpoint/fula_update/fula" ]; then @@ -53,11 +53,12 @@ for device in "${devices[@]}"; do sudo cp /home/pi/fula.sh.log* "$mountpoint/fula_update/" date | sudo tee -a /home/pi/stop_docker_copy.txt > /dev/null mv "$mountpoint/fula_update/update.inprogress.yaml" "$mountpoint/fula_update/update.completed.yaml" - python /usr/bin/fula/control_led.py blue -1 >> $FULA_LOG_PATH 2>&1 & + python /usr/bin/fula/control_led.py yellow -1 >> $FULA_LOG_PATH 2>&1 & if pgrep -f "control_led.py" > /dev/null; then sudo pkill -f "control_led.py" fi + sync sleep 2 python /usr/bin/fula/control_led.py green 3 >> $FULA_LOG_PATH 2>&1 sudo reboot