Skip to content

Commit

Permalink
fix issue with setup-script not able to find OLSRd_V1 wizard after fi…
Browse files Browse the repository at this point in the history
…remware update

in case there are other feature wizards installed with name containing "olsr", the setup script might exit before finishing
  • Loading branch information
pocki80 authored Mar 17, 2017
1 parent 181bae0 commit d9e9cb2
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 6 deletions.
50 changes: 45 additions & 5 deletions wizard-run
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#
# EdgeMAX Wizard "OLSRd_V1" created 03/2016 by Onetrix.net for FunkFeuer.at
# Version [cpo0903d/20170217]
# Version [cpo0903e/20170317]
#
# Github repository: https://github.com/vchrizz/ER-wizard-OLSRd_V1/
#
Expand All @@ -25,6 +25,7 @@
# *) 02/2017 CPO: fix migration from very-old to new version related configfiles in /etc/olsrd instead of /config/user-data)
# *) 02/2017 CPO: fix olsrd6.conf for using LinkQualityMult - param IpVersion is needed before LQ factors to parse IPv6 entries
# *) 02/2017 CPO: feature - restart olsrd for IPv4 and IPv6 individually
# *) 02/2017 CPO: fix setup-script to correctly find OLSRd_V1 wizard after FW update, if other wizards are installed !
#

ACTION=$1
Expand Down Expand Up @@ -159,6 +160,43 @@ if [ -w "/etc/olsrd/olsrdv6.conf" ]; then
rm /etc/olsrd/olsrdv6.conf >> $cfgusrdir$log
fi

# CPO patch previous version with activated setup script - need to implove wizard detection
#
# was:
#for i in $(find /config/wizard/feature/ -name wizard-run | grep -i olsr); do
# if [[ $(grep 'OLSRd_V1' $i) ]]; then
# olsrdv1wizard=$i
# else
# echo "error: OLSRd_V1 wizard not found!"
# exit
# fi
#done

if [ -w $olsrdsetupscriptfile ] &&
[ $(head -n 10 $olsrdsetupscriptfile | grep -n "if \[\[ \$(grep 'OLSRd_V1' \$i) \]\]; then" | wc -l) == "1" ] ; then
echo "Patching existing olsrd_setup.sh in post-config.d to support multiple wizards" >> $cfgusrdir$log
startatline=$(head -n 10 $olsrdsetupscriptfile | grep -n "if \[\[ \$(grep 'OLSRd_V1' \$i) \]\]; then" | awk -F":" {'print $1'})
finishatline=$(head -n 20 $olsrdsetupscriptfile | grep -ne '^done' | awk -F":" {'print $1'})
totallines=$(cat $olsrdsetupscriptfile | wc -l)
head $olsrdsetupscriptfile -n $(($startatline -2)) >/tmp/olsrd_setup_fixed
cat >>/tmp/olsrd_setup_fixed <<'ENDSCRIPTCONTENT'
for i in $(find /config/wizard/feature/ -name wizard-run | grep -i olsr); do
if [[ $(head $i -n 10 | grep 'OLSRd_V1') ]]; then
olsrdv1wizard=$i
break
fi
done
if [ ! $olsrdv1wizard ]; then
echo "error: OLSRd_V1 wizard not found!"
exit
fi
ENDSCRIPTCONTENT
tail $olsrdsetupscriptfile -n $(($totallines - $finishatline)) >>/tmp/olsrd_setup_fixed
cp /tmp/olsrd_setup_fixed $olsrdsetupscriptfile >> $cfgusrdir$log
rm /tmp/olsrd_setup_fixed >> $cfgusrdir$log
chmod 755 $olsrdsetupscriptfile
fi

echo "detected $arch architecture, extracting packages olsrd and olsrd-plugins ..." >> $cfgusrdir$log
if [ $arch == 'mips' ]; then
# base64: olsrd_0.9.0.3-1_mips.deb
Expand Down Expand Up @@ -19440,13 +19478,15 @@ apply () {
#!/bin/bash
olsrdv1wizard=""
for i in $(find /config/wizard/feature/ -name wizard-run | grep -i olsr); do
if [[ $(grep 'OLSRd_V1' $i) ]]; then
if [[ $(head $i -n 10 | grep 'OLSRd_V1') ]]; then
olsrdv1wizard=$i
else
echo "error: OLSRd_V1 wizard not found!"
exit
break
fi
done
if [ ! $olsrdv1wizard ]; then
echo "error: OLSRd_V1 wizard not found!"
exit
fi
cfgusrdir="/config/user-data/"
# olsrd installation logfile
log="olsrd-install.log"
Expand Down
2 changes: 1 addition & 1 deletion wizard.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ <h3>Optimized Link State Routing Protocol</h3>
</div>
<legend style="position:absolute;right:0px;padding:5px;">
<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>
<br>Version [cpo0903d/20170217]</center>
<br>Version [cpo0903e/20170317]</center>
</legend>
<div style="padding:15px;border: 1px solid lightgray;width:648px">
<table border="0">
Expand Down

0 comments on commit d9e9cb2

Please sign in to comment.