From 29c6787f17273851686ef134de3500ededdad396 Mon Sep 17 00:00:00 2001 From: Kris Knigga Date: Tue, 21 Jun 2016 19:30:29 -0500 Subject: [PATCH] convert from sysv init to systemd for the crash recovery benefits --- __lib__systemd__system__stratux.service | 16 ++++++++++++++++ __root__stratux-pre-start.sh | 17 +++++++++++++++++ selfupdate/makeupdate.sh | 3 ++- selfupdate/update_footer.sh | 13 +++++++++---- 4 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 __lib__systemd__system__stratux.service create mode 100755 __root__stratux-pre-start.sh diff --git a/__lib__systemd__system__stratux.service b/__lib__systemd__system__stratux.service new file mode 100644 index 000000000..7353a517e --- /dev/null +++ b/__lib__systemd__system__stratux.service @@ -0,0 +1,16 @@ +[Unit] +Description=Stratux +After=network.target + +[Service] +ExecStartPre=/root/stratux-pre-start.sh +ExecStart=/usr/bin/gen_gdl90 +ExecStop=pkill dump1090 +KillMode=process +Restart=always +RestartSec=5 +LimitCORE=1073741824 + +[Install] +WantedBy=multi-user.target + diff --git a/__root__stratux-pre-start.sh b/__root__stratux-pre-start.sh new file mode 100755 index 000000000..959a76c45 --- /dev/null +++ b/__root__stratux-pre-start.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +echo powersave >/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + +# Check if we need to run an update. +if [ -e /root/update*stratux*v*.sh ] ; then + UPDATE_SCRIPT=`ls -1t /root/update*stratux*v*.sh | head -1` + if [ -n "$UPDATE_SCRIPT" ] ; then + # Execute the script, remove it, then reboot. + echo + echo "Running update script ${UPDATE_SCRIPT}..." + sh ${UPDATE_SCRIPT} + rm -f $UPDATE_SCRIPT + reboot + fi +fi + diff --git a/selfupdate/makeupdate.sh b/selfupdate/makeupdate.sh index 004b931fe..51ec508a2 100755 --- a/selfupdate/makeupdate.sh +++ b/selfupdate/makeupdate.sh @@ -18,7 +18,8 @@ mkdir -p work/bin cp gen_gdl90 work/bin/ cp libdump978.so work/bin/ cp linux-mpu9150/libimu.so work/bin/ -cp init.d-stratux work/bin/ +cp __lib__systemd__system__stratux.service work/bin/ +cp __root__stratux-pre-start.sh work/bin/ cp dump1090/dump1090 work/bin/ cp -r web work/bin/ cp image/hostapd.conf work/bin/ diff --git a/selfupdate/update_footer.sh b/selfupdate/update_footer.sh index 655c707da..84fb8a0ea 100755 --- a/selfupdate/update_footer.sh +++ b/selfupdate/update_footer.sh @@ -4,10 +4,15 @@ cp -f libimu.so /usr/lib/libimu.so # Startup script. -cp -f init.d-stratux /etc/init.d/stratux -chmod 755 /etc/init.d/stratux -ln -fs /etc/init.d/stratux /etc/rc2.d/S01stratux -ln -fs /etc/init.d/stratux /etc/rc6.d/K01stratux +rm -f /etc/init.d/stratux +rm -f /etc/rc2.d/S01stratux +rm -f /etc/rc6.d/K01stratux + +cp -f __lib__systemd__system__stratux.service /lib/systemd/system/stratux.service +cp -f __root__stratux-pre-start.sh /root/stratux-pre-start.sh +chmod 644 /lib/systemd/system/stratux.service +chmod 744 /root/stratux-pre-start.sh +ln -fs /lib/systemd/system/stratux.service /etc/systemd/system/multi-user.target.wants/stratux.service #wifi config cp -f hostapd.conf /etc/hostapd/hostapd.conf