89 lines
2.9 KiB
Bash
Executable File
89 lines
2.9 KiB
Bash
Executable File
#!/bin/sh
|
|
# The upgrade shell is forked by the running app and inherits every app socket.
|
|
# Re-exec after closing inherited non-stdio descriptors so the old process can
|
|
# release its ports cleanly. Keep upgrade diagnostics on the debug serial port.
|
|
if [ "$SMOD_FD_CLEAN" != "1" ]; then
|
|
export SMOD_FD_CLEAN=1
|
|
exec /bin/sh -c '
|
|
i=3
|
|
while [ $i -lt 256 ]; do
|
|
eval "exec ${i}>&-" 2>/dev/null
|
|
i=$((i + 1))
|
|
done
|
|
exec /bin/sh "$1" </dev/null >/dev/ttymxc0 2>&1
|
|
' smod_fd_clean "$0"
|
|
fi
|
|
|
|
# Kernel and device-tree updates only take effect after an IMX reboot. Pure
|
|
# userspace packages keep the clock/RF hardware powered and restart only the
|
|
# application so RF can recover without a power cycle.
|
|
need_reboot=0
|
|
reboot_reason=""
|
|
|
|
if [ -f ./src/zImage ]; then
|
|
need_reboot=1
|
|
reboot_reason="kernel"
|
|
echo "kernel image found: reboot required"
|
|
fi
|
|
|
|
if [ -f ./src/imx6ull-S-gpmi-1024x600c7.dtb ]; then
|
|
need_reboot=1
|
|
if [ -n "$reboot_reason" ]; then
|
|
reboot_reason="$reboot_reason+device-tree"
|
|
else
|
|
reboot_reason="device-tree"
|
|
fi
|
|
echo "device-tree image found: reboot required"
|
|
fi
|
|
|
|
killall logrotateStart daemon_system 2>/dev/null
|
|
sh remove.sh
|
|
sh cp.sh
|
|
sync
|
|
sleep 2
|
|
|
|
if [ "$need_reboot" = "1" ]; then
|
|
echo "boot component updated ($reboot_reason), reboot IMX now"
|
|
reboot
|
|
exit 0
|
|
fi
|
|
|
|
# pthread_setname_np changes the app's /proc comm, so identify it by the exact
|
|
# executable path. Also match "(deleted)" after cp.sh replaces the running ELF.
|
|
find_app_pids()
|
|
{
|
|
for exe in /proc/[0-9]*/exe; do
|
|
target=`readlink "$exe" 2>/dev/null` || continue
|
|
case "$target" in
|
|
/aw/anywave/app/imx_atsc_app|/aw/anywave/app/imx_atsc_app\ \(deleted\))
|
|
echo "$exe" | sed 's#/proc/##;s#/exe##'
|
|
;;
|
|
esac
|
|
done
|
|
}
|
|
|
|
old_pids=`find_app_pids`
|
|
[ -n "$old_pids" ] && kill $old_pids 2>/dev/null
|
|
i=0
|
|
while [ -n "`find_app_pids`" ] && [ $i -lt 15 ]; do
|
|
sleep 1
|
|
i=$((i + 1))
|
|
done
|
|
old_pids=`find_app_pids`
|
|
[ -n "$old_pids" ] && kill -9 $old_pids 2>/dev/null
|
|
while [ -n "`find_app_pids`" ]; do sleep 1; done
|
|
|
|
# Remove stale logging pipelines only after the old application has exited.
|
|
killall loglog 2>/dev/null
|
|
|
|
# Start without the legacy argument 1 so the normal no-power-off RF recovery
|
|
# path rebuilds the TALISE handle and FPGA-side JESD link.
|
|
sleep 2
|
|
cd /aw/anywave/app && nohup sh -c './imx_atsc_app 2>&1 | /usr/sbin/loglog /var/module_log/ imx_atsc_app.log 1' </dev/null >/dev/ttymxc0 2>&1 &
|
|
|
|
# Restore the system watchdog/housekeeper and log rotation. BusyBox on this
|
|
# target has no setsid, and /usr/sbin is not in the default PATH.
|
|
sleep 2
|
|
nohup sh -c '/usr/sbin/daemon_system 2>&1 | /usr/sbin/loglog /var/module_log/ daemon_system.log 1' >/dev/null 2>&1 &
|
|
nohup sh -c '/usr/sbin/logrotateStart 2>&1 | /usr/sbin/loglog /var/module_log/ logrotateStart.log 0' >/dev/null 2>&1 &
|