Skip to content

Commit

Permalink
fix creation of olsrd_setup.sh script
Browse files Browse the repository at this point in the history
removed shell-comments to reduce needed buffer size
  • Loading branch information
pocki80 authored Jun 13, 2018
1 parent 88c48a7 commit 3ef5fc3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 20 deletions.
19 changes: 1 addition & 18 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 [0903k/201803220]
# Version [0903k/201806130]
# ^-- previous line is used from bmk-webstatus-package as version identification, dont remove "Version "
#
# Github repository: https://github.com/vchrizz/ER-wizard-OLSRd_V1/
Expand Down Expand Up @@ -98,33 +98,26 @@ if [ ! $olsrdv1wizard ]; then
exit
fi
cfgusrdir="/config/user-data/"
# olsrd installation logfile
log="/var/log/0xffolsrd.log"
# default olsrd configuration files
olsrdconfig='/etc/olsrd/olsrd.conf'
olsrd4init='/etc/init.d/olsrd'
olsrd4default='/etc/default/olsrd'
olsrd4bin='/usr/sbin/olsrd'
olsrd6init='/etc/init.d/olsrd6'
olsrd6default='/etc/default/olsrd6'
olsrd6bin='/usr/sbin/olsrd6'
# user-defined olsrd configuration files
olsrd4config="${cfgusrdir}olsrd4.conf"
olsrd6config="${cfgusrdir}olsrd6.conf"
# hosts to check for online status
v4iphost='8.8.8.8'
v4dnshost='www.google.com'
v6iphost='2001:4860:4860::8888'
v6dnshost='www.google.com'
# check what architecture we are working on. ER big endian (mips) or ER-X little endian (mipsel)
if [ $(echo -n I | od -to2 | awk '{ print substr($2,6,1); exit}') == 0 ]; then
arch='mips'
else
arch='mipsel'
fi
echo "Running olsrdsetupscriptfile script... $(date +%Y-%m-%d/%H:%M:%S.%N)" >>$log
# both packages, olsrd *and* olsrd-plugins are required and must be specified!
# german debian mirror
olsrdmirror="http://ftp.de.debian.org/debian/pool/main/o/olsrd/olsrd_0.6.6.2-1_$arch.deb"
olsrdplgmirror="http://ftp.de.debian.org/debian/pool/main/o/olsrd/olsrd-plugins_0.6.6.2-1_$arch.deb"
olsrdwatchdogscriptfile="/etc/olsrdwatchdog"
Expand All @@ -138,22 +131,17 @@ sed -n "/^load ()/,/^}/p" $olsrdv1wizard >> func.sh
source func.sh
load
rm -f func.sh
# if one of enabled interfaces is a bridge, drop forwarded ethernet frames, else accept
if [[ $(grep ^MESH_IF $olsrd4default) == *"br"* ]] || [[ $(grep ^MESH_IF $olsrd6default) == *"br"* ]]; then
if [[ $(grep -E "^ebtables\ \-P\ FORWARD\ DROP" /config/scripts/pre-config.d/ebtables.sh 2>/dev/null | wc -l) == 0 ]]; then

if [ ! -d /config/scripts/pre-config.d ]; then
# create missing directory
mkdir /config/scripts/pre-config.d >>$log 2>>$log
chmod --reference=/config/scripts/post-config.d /config/scripts/pre-config.d >>$log 2>>$log
chown --reference=/config/scripts/post-config.d /config/scripts/pre-config.d >>$log 2>>$log
fi
if [ ! -f /config/scripts/pre-config.d/ebtables.sh ]; then
#create file
echo -e '#!/bin/sh\n#olsrdwizard: dont forward ethernet frames between bridge ports\nebtables -P FORWARD DROP\nexit 0' > /config/scripts/pre-config.d/ebtables.sh
chmod 755 /config/scripts/pre-config.d/ebtables.sh
else
#add lines to file on top
linenumber=2
sed -i $linenumber'i\
#olsrdwizard: dont forward ethernet frames between bridge ports\
Expand All @@ -163,14 +151,11 @@ ebtables -P FORWARD DROP' /config/scripts/pre-config.d/ebtables.sh >>$log 2>>$lo
fi
else
if [[ $(grep -E "^#olsrdwizard:|^ebtables\ \-P\ FORWARD\ DROP" /config/scripts/pre-config.d/ebtables.sh 2>/dev/null | wc -l) == 2 ]]; then


sed -i '/^#olsrdwizard:.*/d' /config/scripts/pre-config.d/ebtables.sh
sed -i '/^ebtables\ \-P\ FORWARD\ DROP/d' /config/scripts/pre-config.d/ebtables.sh
ebtables -P FORWARD ACCEPT
fi
fi
#add cronjob? if missing, olsrd-autostart=on, executeable watchdogscript
if [ ! -f /etc/cron.d/olsrdwatchdog ] &&
[ -f $olsrd4default ] && [ $(cat $olsrd4default | cut -d "#" -f 1 | grep -c START_OLSRD=\"YES\") \> 0 ] &&
[ $(cat $olsrd4config | cut -d "#" -f 1 | grep -c LoadPlugin.*olsrd_watchdog) \> 0 ] &&
Expand All @@ -179,7 +164,6 @@ if [ ! -f /etc/cron.d/olsrdwatchdog ] &&
echo "* * * * * root /etc/olsrdwatchdog >/dev/null 2>/dev/null" >/etc/cron.d/olsrdwatchdog
chmod 744 /etc/cron.d/olsrdwatchdog
fi
#need to remove cronjob?
if [ ! -f $olsrd4default ] ||
[ $(cat $olsrd4default | cut -d "#" -f 1 | grep -c START_OLSRD=\"YES\") -eq 0 ] ||
[ $(cat $olsrd4config | cut -d "#" -f 1 | grep -c LoadPlugin.*olsrd_watchdog) -eq 0 ] ||
Expand All @@ -189,7 +173,6 @@ if [ ! -f $olsrd4default ] ||
rm /etc/cron.d/olsrdwatchdog
fi
fi
# restart daemon(s)
$olsrd4init restart >>$log
$olsrd6init restart >>$log
echo "Finished olsrdsetupscriptfile script... $(date +%Y-%m-%d/%H:%M:%S.%N)" >>$log
Expand Down
4 changes: 2 additions & 2 deletions wizard.html
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
Works on EdgeRouter and EdgeRouter X / X-SFP (system version 1.7.0+)
versioninfo=201803220
versioninfo=201806130
^-- use version identifier as number: YYYYMMDDX whereas X can be intraday-version
autoupdate=201801260
^-- set autoupdate the same version identifier to allow autoupdates
Expand All @@ -15,7 +15,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 [0903k/20180322]</center>
<br>Version [0903k/20180613]</center>
</legend>
<div style="padding:15px;border: 1px solid lightgray;width:648px">
<table border="0">
Expand Down

0 comments on commit 3ef5fc3

Please sign in to comment.