#!/bin/sh status_file=/run/update_camera.status status_file_tmp="${status_file}.$$" if sh /opt/update_camera.sh 2>&1 | tee /proc/1/fd/1 | grep -i error >/dev/null; then printf 'error\n' > "$status_file_tmp" else printf 'ok\n' > "$status_file_tmp" fi mv "$status_file_tmp" "$status_file"