Skip to content

Commit a7d6987

Browse files
authored
fix watchdog cron.d-entry creation from within init.d script
1 parent 377dc02 commit a7d6987

File tree

2 files changed

+26
-9
lines changed

2 files changed

+26
-9
lines changed

wizard-run

+24-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#
44
# EdgeMAX Wizard "OLSRd_V1" created 03/2016 by Onetrix.net for FunkFeuer.at
5-
# Version [0903k/201810090]
5+
# Version [0903k/201810150]
66
# ^-- previous line is used from bmk-webstatus-package as version identification, dont remove "Version "
77
#
88
# Github repository: https://github.com/vchrizz/ER-wizard-OLSRd_V1/
@@ -158,15 +158,15 @@ else
158158
fi
159159
fi
160160
if [ ! -f /etc/cron.d/olsrdwatchdog ] &&
161-
[ -f $olsrd4default ] && [ $(cat $olsrd4default | cut -d "#" -f 1 | grep -c START_OLSRD=\"YES\") \> 0 ] &&
161+
[ -f $olsrd4default ] && [ $(cat $olsrd4default | cut -d "#" -f 1 | grep -c 'START_OLSRD=\"YES\"') \> 0 ] &&
162162
[ $(cat $olsrd4config | cut -d "#" -f 1 | grep -c LoadPlugin.*olsrd_watchdog) \> 0 ] &&
163163
[ -x /etc/olsrdwatchdog ] ; then
164164
echo add watchdog to crontab
165165
echo "* * * * * root /etc/olsrdwatchdog >/dev/null 2>/dev/null" >/etc/cron.d/olsrdwatchdog
166166
chmod 744 /etc/cron.d/olsrdwatchdog
167167
fi
168168
if [ ! -f $olsrd4default ] ||
169-
[ $(cat $olsrd4default | cut -d "#" -f 1 | grep -c START_OLSRD=\"YES\") -eq 0 ] ||
169+
[ $(cat $olsrd4default | cut -d "#" -f 1 | grep -c 'START_OLSRD=\"YES\"') -eq 0 ] ||
170170
[ $(cat $olsrd4config | cut -d "#" -f 1 | grep -c LoadPlugin.*olsrd_watchdog) -eq 0 ] ||
171171
[ ! -x /etc/olsrdwatchdog ]; then
172172
if [ -f /etc/cron.d/olsrdwatchdog ]; then
@@ -400,7 +400,7 @@ if [ -f $olsrd4init ] && [ $(grep -c "rm /etc/cron.d/olsrdwatchdog" $olsrd4init)
400400
linenumber=$(($(grep -n 'start-stop-daemon --start --quiet' $olsrd4init | tail -n1 | cut -d":" -f1)+5))
401401
sed -i $linenumber'i\
402402
if [ ! -f /etc/cron.d/olsrdwatchdog ] &&\
403-
[ -f /etc/default/olsrd ] && [ $(cat /etc/default/olsrd | cut -d "#" -f 1 | grep -c START_OLSRD=\"YES\") \\> 0 ] &&\
403+
[ -f /etc/default/olsrd ] && [ $(cat /etc/default/olsrd | cut -d "#" -f 1 | grep -c ''START_OLSRD=\"YES\"'') \\> 0 ] &&\
404404
[ $(cat /config/user-data/olsrd4.conf | cut -d "#" -f 1 | grep -c LoadPlugin.*olsrd_watchdog) \\> 0 ] &&\
405405
[ -x /etc/olsrdwatchdog ] ; then\
406406
echo "* * * * * root /etc/olsrdwatchdog >/dev/null 2>/dev/null" >/etc/cron.d/olsrdwatchdog\
@@ -410,9 +410,26 @@ fi
410410
#fix init.d/olsrd generating a "0" file
411411
[ -f $olsrd4init ] && (grep -q ' > 0 ]' $olsrd4init) && sed -i 's/> 0 ]/\\> 0 ]/g' $olsrd4init
412412

413+
## olsrdwatchgdog patch BEGIN
414+
#patch syntax error in init file related to creation of watchdog cron.d entry
415+
if (grep -q ' START_OLSRD="YES")' /etc/init.d/olsrd); then
416+
sed -i "s/ START_OLSRD=\"YES\")/ 'START_OLSRD=\"YES\"')/g" /etc/init.d/olsrd | grep "START_OLSRD="
417+
fi
418+
#add cron entry if missing but expected to be there
419+
if [ ! -f /etc/cron.d/olsrdwatchdog ] &&
420+
[ -f $olsrd4default ] && [ $(cat $olsrd4default | cut -d "#" -f 1 | grep -c 'START_OLSRD=\"YES\"') \> 0 ] &&
421+
[ $(cat $olsrd4config | cut -d "#" -f 1 | grep -c LoadPlugin.*olsrd_watchdog) \> 0 ] &&
422+
[ -x /etc/olsrdwatchdog ] ; then
423+
echo add watchdog to crontab >>$log
424+
echo "* * * * * root /etc/olsrdwatchdog >/dev/null 2>/dev/null" >/etc/cron.d/olsrdwatchdog
425+
chmod 644 /etc/cron.d/olsrdwatchdog
426+
fi
427+
## olsrdwatchgdog patch END
428+
413429
## END patch for installing this wizard onto a existing 0.9.0.3 wizard END ##
414430
#############################################################################
415431

432+
416433
###update default intervals to reduce olsr management traffic
417434
#define new settings
418435
Pollrate="0.1"
@@ -19569,7 +19586,7 @@ UG=$(echo $(id -un):$(id -u) "("$(id -gn):$(id -g)")")' $olsrd4init
1956919586
linenumber=$(($(grep -n 'start-stop-daemon --start --quiet' $olsrd4init | tail -n1 | cut -d":" -f1)+5))
1957019587
sed -i $linenumber'i\
1957119588
if [ ! -f /etc/cron.d/olsrdwatchdog ] &&\
19572-
[ -f /etc/default/olsrd ] && [ $(cat /etc/default/olsrd | cut -d "#" -f 1 | grep -c START_OLSRD=\"YES\") \\> 0 ] &&\
19589+
[ -f /etc/default/olsrd ] && [ $(cat /etc/default/olsrd | cut -d "#" -f 1 | grep -c ''START_OLSRD=\"YES\"'') \\> 0 ] &&\
1957319590
[ $(cat /config/user-data/olsrd4.conf | cut -d "#" -f 1 | grep -c LoadPlugin.*olsrd_watchdog) \\> 0 ] &&\
1957419591
[ -x /etc/olsrdwatchdog ] ; then\
1957519592
echo "* * * * * root /etc/olsrdwatchdog >/dev/null 2>/dev/null" >/etc/cron.d/olsrdwatchdog\
@@ -20111,7 +20128,7 @@ Interface "br9" {\
2011120128
fi
2011220129
#add cronjob? if missing, olsrd-autostart=on, executeable watchdogscript
2011320130
if [ ! -f /etc/cron.d/olsrdwatchdog ] &&
20114-
[ -f $olsrd4default ] && [ $(cat $olsrd4default | cut -d "#" -f 1 | grep -c START_OLSRD=\"YES\") \> 0 ] &&
20131+
[ -f $olsrd4default ] && [ $(cat $olsrd4default | cut -d "#" -f 1 | grep -c 'START_OLSRD=\"YES\"') \> 0 ] &&
2011520132
[ $(cat $olsrd4config | cut -d "#" -f 1 | grep -c LoadPlugin.*olsrd_watchdog) \> 0 ] &&
2011620133
[ -x /etc/olsrdwatchdog ] ; then
2011720134
echo add watchdog to crontab >>$log
@@ -20120,7 +20137,7 @@ Interface "br9" {\
2012020137
fi
2012120138
#need to remove cronjob?
2012220139
if [ ! -f $olsrd4default ] ||
20123-
[ $(cat $olsrd4default | cut -d "#" -f 1 | grep -c START_OLSRD=\"YES\") -eq 0 ] ||
20140+
[ $(cat $olsrd4default | cut -d "#" -f 1 | grep -c 'START_OLSRD=\"YES\"') -eq 0 ] ||
2012420141
[ $(cat $olsrd4config | cut -d "#" -f 1 | grep -c LoadPlugin.*olsrd_watchdog) -eq 0 ] ||
2012520142
[ ! -x /etc/olsrdwatchdog ]; then
2012620143
if [ -f /etc/cron.d/olsrdwatchdog ]; then

wizard.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
EdgeMAX Wizard "OLSRd_V1" created 03/2016 by Onetrix.net for FunkFeuer.at
44
Works on EdgeRouter and EdgeRouter X / X-SFP (system version 1.7.0+)
5-
versioninfo=201810090
5+
versioninfo=201810150
66
^-- use version identifier as number: YYYYMMDDX whereas X can be intraday-version
77
autoupdate=201810090
88
^-- set autoupdate the same version identifier to allow autoupdates
@@ -15,7 +15,7 @@ <h3>Optimized Link State Routing Protocol</h3>
1515
</div>
1616
<legend style="position:absolute;right:0px;padding:5px;">
1717
<center>EdgeMAX Wizard "OLSRd_V1" created 2016<br>by <a href="http://onetrix.net" target="_blank">Onetrix.net</a> for <a href="http://funkfeuer.at" target="_blank">FunkFeuer.at</a>
18-
<br>Version [0903k/20181009]</center>
18+
<br>Version [0903k/20181015]</center>
1919
</legend>
2020
<div style="padding:15px;border: 1px solid lightgray;width:648px">
2121
<table border="0">

0 commit comments

Comments
 (0)