if [ -z "${LANFACE}" ] ; then
optlog "${scriptname}" "I could not determine the Lan-interface"
exit 1
fi
# You need to fill in a free IP within your subnet
secFACE=${LANFACE}:15
secIP=
# You can (optionally) run lighttpd with physical hosting on a 3rd IP
# If you don't specify a seperate IP, it will move to port 888
terFACE=${LANFACE}:16
terIP=
virtualHostPort=80
if [ -z "${terIP}" ] || [ "${terIP}" == "${secIP}" ] ; then
terIP=${secIP}
physicalHostPort=888
else
physicalHostPort=80
fi
# secIP=192.168.1.2
if [ -z "${secIP}" ] ; then
optlog "${scriptname}" "is disabled for your protection, \"secIP\" is not defined"
exit 1
fi
secIP=`echo "${secIP}" | tr -cd '0-9.' | egrep -o "^[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*$"`
if [ -z "${secIP}" ] ; then
optlog "${scriptname}" "\"\$secIP\" is not valid!"
exit 1
fi
terIP=`echo "${terIP}" | tr -cd '0-9.' | egrep -o "^[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*$"`
if [ -z "${terIP}" ] ; then
optlog "${scriptname}" "\"\$terIP\" is not valid!"
exit 1
fi
if [ -z "`which ipcalc`" ] ; then
optlog "${scriptname}" "\"ipcalc\" is not installed!"
ipkg-opt update
ipkg-opt install ipcalc
if [ -z "which ipcalc" ] ; then
optlog "${scriptname}" "install of \"ipcalc\" was not successful"
exit 1
fi
fi
if [ physicalHostPort -eq 80 ] || [ virtualHostPort -eq 80 ] ; then
if [ ! -z "`netstat -tanp | grep LISTEN | awk '{print $4}' | grep "0\.0\.0\.0:80$"`" ] ; then
optlog "${scriptname}" "A webserver on port 80 which binds to all interfaces is running"
optlog "${scriptname}" "You need to remove this service from port 80 or change it to use seperate interfaces"
exit 1
fi
fi
if [ -z "`echo $NETWORK_WRT | grep -o "[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*/[0-9]*"`" ] ; then
optlog "${scriptname}" "ipcalc gave an unexpected result (${NETWORK_WRT}). I can not continue!"
exit 1
fi
if [ "${secIP}" == "${LANIP}" ] ; then
optlog "${scriptname}" "The requested IP (${secIP}) can NOT be the same as my DD-WRT's IP (${LANIP})"
exit 1
fi
if [ ! "${NETWORK_SECIP}" == "${NETWORK_ADDR}" ] ; then
optlog "${scriptname}" "The requested IP (${secIP}) is not within the same network as DD-WRT (${NETWORK_WRT})"
exit 1
fi
# Add an extra IP if necessary
# Write all IP's to file
ifconfig | grep "inet addr:" | awk -F: '{print $2}' | awk '{print $1}' >/tmp/wrt_ips
# add an IP for virtual hosting if this hasn't been done already
if ! grep -q "${secIP}" /tmp/wrt_ips ; then
if ping -c1 ${secIP} | grep from | grep -q time= ; then
optlog "${scriptname}" "I was able to see ${secIP} on another device..., I will not create an IP"
else
# Create new IP on new interface
ifconfig ${secFACE} ${secIP} netmask ${LANNETMASK} up
optlog "${scriptname}" "add IP:${secIP} to ${LANFACE}"
fi
fi
# add an IP for physical hosting if this hasn't been done already
if [ ! "${terIP}" = "${secIP}" ] ; then
if ! grep -q "${terIP}" /tmp/wrt_ips ; then
if ping -c1 ${terIP} | grep from | grep -q time= ; then
optlog "${scriptname}" "I was able to see ${terIP} on another device..., I will not create an IP"
else
# Create new IP on new interface
ifconfig ${terFACE} ${terIP} netmask ${LANNETMASK} up
optlog "${scriptname}" "add IP:${terIP} to ${LANFACE}"
fi
fi
fi
if [ -z "$1" ] ; then
case `echo "$0" | sed 's:^.*/\(.*\):\1:g'` in
S??*) rc="start" ;;
K??*) rc="stop" ;;
*) rc="usage" ;;
esac
else
rc="$1"
fi
correctAddressPhyshosting () {
confIP=`grep "^server.bind.*=.*\"[1-9]*" $CONF | grep -o ${terIP}`
if [ -z "$confIP" ] ; then
# Address is not yet configured in lighttpd.conf
if grep -q "^server\.bind" $CONF ; then
sed -i -e "s/^server.bind.*/server.bind\t\t= \"$terIP\"/" $CONF
else
if grep -q "server\.bind" $CONF ; then
# Replace the first occurence of server.bind
sed -i -e "0,/.*server\.bind.*/s//&\nserver.bind\t\t= \"$terIP\"/" $CONF
else
optlog "${scriptname}" "$CONF does NOT contain a \"server.bind\" entry"
exit 1
fi
fi
fi
}
enablemodules () {
if grep "\"mod_cgi\"" $CONF | grep -q "^#" ; then
optlog "$scriptname" "cgi-modules are disabled in $CONF, I will enable them"
sed -i -e "s/#[$ht ]*.*\"mod_alias.*/$ht$ht$ht$ht\"mod_alias\",/" $CONF
sed -i -e "s/#[$ht ]*.*\"mod_auth.*/$ht$ht$ht$ht\"mod_auth\",/" $CONF
sed -i -e "s/#[$ht ]*.*\"mod_fastcgi.*/$ht$ht$ht$ht\"mod_fastcgi\",/" $CONF
sed -i -e "s/#[$ht ]*.*\"mod_cgi.*/$ht$ht$ht$ht\"mod_cgi\",/" $CONF
sed -i -e "s/#[$ht ]*.*\"mod_rewrite.*/$ht$ht$ht$ht\"mod_rewrite\",/" $CONF
grep -q mod_webdav $CONF || sed -i -e "s/.*\"mod_rrdtool.*/&\n$ht$ht$ht$ht\"mod_webdav\",/" $CONF
grep -q "index\.cgi" $CONF || sed -i -e "s/.*\"index.htm\", \"def.*/&\n$ht$ht$ht$ht\"index.cgi\",/" $CONF
sed -i -e "s/^# *cgi.assign/cgi.assign/" $CONF
sed -i -e "s/^#[$ht ]*\"\.cgi/$ht$ht$ht$ht\".cgi/" $CONF
fi
}
correctdocrootPhyshosting () {
confDOC=`grep "^server.document-root.*=.*" $CONF | grep -o ${PHOSTDIR}`
if [ -z "${confDOC}" ] ; then
# Address is not yet configured in lighttpd.conf
if grep -q "^server.document-root" $CONF ; then
optlog "${scriptname}" "replacing server.document-root in $CONF"
sed -i -e "s/^server.document.*/server.document-root\t\t= \"${PHOSTsed}\"/" $CONF
else
optlog "${scriptname}" "$CONF does NOT contain a \"server.document-root\" entry"
exit 1
fi
fi
if ! grep -q ^server.username $CONF ; then
sed -i -e "s/#.*server.username.*/&\nserver.username\t\t= \"${AS_USER}\"/" $CONF
fi
grep ^server.username $CONF | grep -q ${AS_USER} || sed -i -e "s/^server.username.*/server.username\t\t= \"${AS_USER}\"/" $CONF
if ! grep -q ^server.groupname $CONF ; then
sed -i -e "s/#.*server.groupname.*/&\nserver.groupname\t\t= \"${AS_USER}\"/" $CONF
fi
grep ^server.groupname $CONF | grep -q ${AS_USER} || sed -i -e "s/^server.groupname.*/server.groupname\t\t= \"${AS_USER}\"/" $CONF
chown -R ${AS_USER}:${AS_USER} /opt/var/log/lighttpd
}
correctPortPhyshosting () {
confPORT=`grep "^server.port.*=.*\"[1-9]*" $CONF | grep -o ${physicalHostPort}`
if [ -z "${confPORT}" ] ; then
# Address is not yet configured in lighttpd.conf
if grep -q "^server\.port" $CONF ; then
optlog "${scriptname}" "replacing server.port in $CONF"
sed -i -e "s/^server.port.*/server.port\t\t= \"${physicalHostPort}\"/" $CONF
else
optlog "${scriptname}" "$CONF does NOT contain a \"server.port\" entry"
exit 1
fi
fi
}
correctVhosting () {
if [ -f ${CONFDIR}/conf.d/evhost.conf ] ; then
# if secIP is not in evhost.conf
if ! grep -q ${secIP} ${CONFDIR}/conf.d/evhost.conf ; then
optlog "${scriptname}" "evhost.conf needs to be corrected"
sed -i -e "s/\$SERVER\[\"socket\".*/\$SERVER[\"socket\"] == \"${secIP}:${virtualHostPort}\" {/" ${CONFDIR}/conf.d/evhost.conf
fi
else
optlog "${scriptname}" "evhost.conf does NOT exist... I will create it"
fi
mkdir -p ${VHOSTDIR}/oops 2>/dev/null
if [ ! -e ${VHOSTDIR}/oops/index.html ] ; then
optlog "${scriptname}" "Creating ${VHOSTDIR}/oops/index.html because it was missing"
echo -e "<html>\n <head>\n <title>Ooops....</title>\n </head>" >${VHOSTDIR}/oops/index.html
echo -e " <body>\n <h2>Oooops......</h2>\n </body>\n</html>" >>${VHOSTDIR}/oops/index.html
fi
mkdir -p ${VHOSTDIR}/com/yourdomain/www 2>/dev/null
mkdir -p ${VHOSTDIR}/org/yourdomain/www 2>/dev/null
mkdir -p ${VHOSTDIR}/org/dyndns 2>/dev/null
mkdir -p ${VHOSTDIR}`nvram get lan_domain | awk -F\. '{print $6"/"$5"/"$4"/"$3"/"$2"/"$1}' | tr -s '/'`
IPDIR=${VHOSTDIR}/`echo "${secIP}" | awk -F\. '{print $4"/"$3"/"$2"/"$1}'`
[ -d $IPDIR ] || mkdir -p $IPDIR 2>/dev/null
if [ ! -e $IPDIR/index.html ] ; then
optlog "${scriptname}" "Creating $IPDIR/index.html because it was missing"
echo -e "<html>\n <head>\n <title>lighttpd default page</title>\n </head>" >$IPDIR/index.html
echo -e " <body>\n <h2>lighttpd server is running (virtual hosting).</h2>\n </body>\n</html>" >>$IPDIR/index.html
fi
[ -d ${PHOSTDIR} ] || mkdir -p ${PHOSTDIR} 2>/dev/null
if [ ! -e ${PHOSTDIR}/index.html ] ; then
optlog "${scriptname}" "Creating ${PHOSTDIR}/index.html because it was missing"
echo -e "<html>\n <head>\n <title>lighttpd default page</title>\n </head>" >${PHOSTDIR}/index.html
echo -e " <body>\n <h2>lighttpd server is running (physical hosting).</h2>\n </body>\n</html>" >>${PHOSTDIR}/index.html
fi
# Correction if event handler is missing
if ! grep -q "^server.event" ${CONF} ; then
sed -i -e "s/#.*server.event.*/&\nserver.event-handler = \"poll\" # needed on OS X server/" ${CONF}
fi
}
case "$rc" in
status)
if [ -n "`pidof $DNAME`" ]; then
# http_port=`nvram get http_lanport`
# [ -z "${http_port}" ] && http_port=80
echo "web server: $DNAME is running"
netstat -lnp --inet | grep lighttpd | sed 's/ *0 0//' | sed 's/ *LISTEN //' | sed 's/^t/\tt/'
netstat -lnp --inet | grep -e ":80 " -e ":443 " -e "httpd" | grep -v lighttpd | sed 's/ *0 0//' | sed 's/ *LISTEN //' | sed 's/^t/\tt/' >/tmp/nstat
if [ -s /tmp/nstat ] ; then
echo "Other webservices"
cat /tmp/nstat
rm /tmp/nstat
fi
else
echo "web server: $DNAME is not running"
fi
;;
start)
if ! netstat -tanp | grep LISTEN | awk '{print $4}' | grep -q "${secIP}:${virtualHostPort}$" ; then
if netstat -tanp | grep LISTEN | awk '{print $4}' | grep -q "0\.0\.0\.0:${virtualHostPort}$" ; then
echo "Error: Another server is listening to all interfaces on port: ${virtualHostPort}"
exit 1
fi
echo "Starting web server: $NAME"
$DAEMON $DAEMON_OPTS
else
echo "web server: $DNAME is already running"
fi
;;
stop)
if [ -n "`pidof $DNAME`" ]; then
PID=`netstat -tanp | grep LISTEN | grep lighttpd | grep ":${virtualHostPort} " | awk '{print $7}' | awk -F/ '{print $1}'`
echo "Stopping web server: $NAME"
kill $PID 2> /dev/null
else
echo "web server: $DNAME is not running"
fi
;;
restart)
"$0" stop
sleep 1
"$0" start
;;
*)
echo "Usage: $0 (start|stop|restart|usage)"
;;
esac
exit 0 _________________ Please state what make and model router plus the build number and type of DD-WRT you are using. Screen prints and a network diagram can are also helpful. Before you create a new post, use the search function. Chances are your issue has happened to someone else.
i think that error might have had something to do with server event handler _________________ Please state what make and model router plus the build number and type of DD-WRT you are using. Screen prints and a network diagram can are also helpful. Before you create a new post, use the search function. Chances are your issue has happened to someone else.
i think that error might have had something to do with server event handler
Thanks for posting that.
I believe the issue is this. For OTRW v1 Frater wrote the vlighttpd service which basically sets up lighttpd for the dd-wrt Optware environment.
But as far as I can see from your configuration file that does not show any of the hallmarks of having been configured via Frater's vlighttpd script, which amongst other things provided enhanced hosting possibilities (virtual and physical).
Therefore it may be that Take 2 doesn't support the vlighttpd configuration, in which case it should really be removed from the available services.
were you able to get past that error and is your lighttpd working now? _________________ Please state what make and model router plus the build number and type of DD-WRT you are using. Screen prints and a network diagram can are also helpful. Before you create a new post, use the search function. Chances are your issue has happened to someone else.
were you able to get past that error and is your lighttpd working now?
I'm afraid not.
What I have done is found a post by Kong that references the error message:
Code:
. . .because your optware svn was compiled with different libs, if you now call the executable it will load the wrong libs, therefore you have to use LD_PRELOAD or LD_LIBRARY_PATH in order to point to the optware libs that were installed as a dependency.
Logon to the router and run this command before you use svn command:
That sounds like the issue at hand, but unfortunately I don't know enough scripting to craft a fix for the vlighttpd script.
I'll give it another few days and hope that somebody can chime in, otherwise I'm afraid it looks like a firmware downgrade and reinstallation of Take 1, since I use the vlighttpd implementation fairly extensively.
Well in the absence of any feedback on this and also due to the fact that I didn't seem able to get Samba working properly, I am afraid I have downgraded to Kong's 18730 build.
Vlighttpd and Samba are now working properly, but I am obviously disappointed that Open VPN, Transmission, etc are off limits.
Posted: Tue Jul 01, 2014 19:18 Post subject: chan_motif.so
Does installing OTRW2 also installs chan_motif module or do I have to install it seperately. If yes, how can I install it any help would be much appreciated.
Posted: Sat Jul 05, 2014 21:32 Post subject: /opt/usr/sbin/service: line 31: can't create /tmp/services
Error following OTRW2 install [when inputting "service"]:
/opt/usr/sbin/service: line 31: can't create /tmp/services: Is a directory
Error output immediately prior to OTRW2 install completion:
grep: /opt/etc/init.d/s56unfsd: no such file or directory
grep: /opt/etc/init.d/s55portmap: no such file or directory
I received the above error upon rebooting after OTRW2 install and giving the service command. I was hoping to be able to search this thread as its 60 pages long, however I'm either not looking in the right place, or the forum doesn't have thread search abilities.
I am running a Kong AC firmware for my R6300 (24200M) and wasn't aware Kong AC firmwares were not supported before installing OTRW2. So first, is the fact I'm running an AC firmware the reason for the above error? If it isn't, could someone please provide insight into what I did wrong or did not do. I followed all directions provided within the OTRW2 tutorial page and after I got this error the first time, I thought maybe I didn't do something correctly and I reformatted my thumb drive and reinstalled the 24200M firmware... only to get the error again.
I did read on the tutorial page kernel 3.x aren't supported fully, but did list around 10 or so that do work on kernel 3.x, which makes me wonder if it is the fact I'm running AC firmware. Any insight would be greatly appreciated =]
EDIT: After realizing I shouldn't have created a partition for jffs, I reformatted my thumb drive and reinstalled OTRW2 (left router off during the reformat, as I don't know how to unmount the thumb drive from the router). However, I still receive the same error when inputting services, as well as a grep error immediately before the OTRW2 install finishes. I know next to nothing about Linux, minus some very basic stuff I know from rooting and unlocking the bootloader on my Razr Maxx HD, and I figured now is as good of a time as any to learn the basics of Linux. From Googling the error, it seems [I could be way off here] like this is a permission issue, and not knowing the Linux filesystem, I don't want to go poking around with chmod without guidance if it is a permissions issue. When I attempt to navigate to the /opt/usr/sbin/service folder using ls, it returns an error that no such directory exists. Also, the UUID for /opt [sda1] has been entered into the "Mount this Partition to /opt" text box [Additional screenshot added]
OTRW2 install grep error.png
Description:
Filesize:
439.62 KB
Viewed:
21414 Time(s)
updated telnet errors.png
Description:
Filesize:
332.96 KB
Viewed:
21429 Time(s)
Last edited by JW0914 on Tue Jul 08, 2014 8:12; edited 1 time in total
It's not just the firmware, the regular Optware works only on Broadcom Mipsel processors. Maybe if somebody else compiled it for the processor of your router, it would work. _________________ 2 times APU2 Opnsense 21.1 with Sensei
2 times RT-AC56U running DD-WRT 45493 (one as Gateway, the other as AP, both bridged with LAN cable)
3 times Asus RT-N16 shelved
E4200 V1 running freshtomato 2020.8 (bridged with LAN cable)
3 times Linksys WRT610N V2 converted to E3000 and 1 original E3000 running freshtomato 2020.8 (bridged with LAN cable)
It's not just the firmware, the regular Optware works only on Broadcom Mipsel processors. Maybe if somebody else compiled it for the processor of your router, it would work.
.
EDIT (20140708): All that was needed was to remove the services directory in /tmp, which makes the reply to my most by slobodan even more baffling...
OTRW2 does work on the R6300, as it works on the R6300 and previous models.
I'm also failing to see the link between what you just said and what I posted about... the processor has nothing to do with being able to access directories. OTRW2 installed fine on the router, but certain directories were not able to be accessed or written to, as I detailed in my post above.
Regardless of whether a processor supports a package or not, that has nothing to do with the file system... so I'm a bit confused why you would post such a response, even more so when you appear to be fully competent with Linux...
I came here looking for help, and while I may not have a clue about most things Linux, I do know with 100% certainty that whether you're running Linux or NT, the processor doesn't come into the equation in regards to the file system... and even if it did, the /opt partition isn't on the router, it's on a thumb drive and mounted within the firmware.
EDIT: According to the OTRW2 wiki tutorial, as well as other threads on DD-WRT, the Netgear R6300 is fully compatible with OTRW2:
Optware runs on Broadcom routers only(which the Netgear R6300 is).
The following builds are supported:
BrainSlayer builds up to 19519
Fractal builds up to 20006
All Kong builds based on Kernel 2.6
Kernel 3.x (Very early development preview)(while all packages and features may not work with the current 3.x kernel, some should... and the problem I'm inquiring about is certain very specific directories (just three) were not created)
Last edited by JW0914 on Wed Jul 23, 2014 18:24; edited 7 times in total
Posted: Tue Jul 08, 2014 11:04 Post subject: This is definitively a permissions issue...
slobodan wrote:
It's not just the firmware, the regular Optware works only on Broadcom Mipsel processors. Maybe if somebody else compiled it for the processor of your router, it would work.
The issue here is permissions and nothing else (specifically permissions for symbolic link directories)... unfortunately, I'm not sure how to edit permissions for the command "service".
Giving myself rwx permissions, I am able to access the /tmp/services directory, as well as the /opt/usr/sbin/service directory, however, the command "service" is unable to write to /tmp/services as it doesn't have write permissions to that folder, returning the error:
/opt/usr/sbin/service: line 31: can't create /tmp/services: Is a directory
If I delete the /tmp/services folder, I can give the "service" command and turn on services... until I reboot the router, at which point "service" is again unable to write the existing folder /tmp/services.
If someone could provide insight into how to assign the "service" command the proper permissions to access and edit directories, I would be appreciative.
However, I would appreciate any user wishing to tell me this is due to processors and other inaccurate information due to their own ignorance to please not share time wasting answers that do not apply to the issue at hand.
Posted: Sun Jul 20, 2014 4:08 Post subject: PixelServ / DnsMasq causing huge DNS resolve delays
First, want to say thank you for reading this post.
Second, I have been a long time user of DD-WRT and OTRW1&2 but I have been out of the loop for a year or so due to lots of reasons.
Been running PixelServ for 2 years and it has been working great.... up until about 2 weeks ago. Symptoms are that DNS resolves take 30+ seconds to complete (if they dont time out compeltely) on all workstations attached to router (E3000) w/ 8GB pen drive. Checking processes on the router, dnsmasq is sitting at 30% CPU and System taking up the rest (Load average 4.00+). Long story short, I found that if PixelServ is killed, problem disapears. Start PixelServ back up, wait 6-8 hours of internet usage and issue returns.
Deleted the black lists from /opt and reloaded; no change.
Upgraded to latest OTRW2 using script located here:
http://ddwrt.basmaf.com/prep_optware - Upgrades successful - No Change
Upgraded from build 16785 (old but no problems up until now) to Kong 22000++ - No Change
Am I using the wrong script/service?
Other Running Services in OTRW:
xinetd
rotate_log
fixtables
stophammer
asiablock
birmablock
worldblock
stophack
backupessentials
System:
E3000
Kong 22000++ (updated today from 16785)
8GB USB Pen - Mounted /opt - 64MB SWAP
I have been out of the loop for a while so if there is an obvious issue, please enlighten me.
Posted: Wed Jul 23, 2014 17:49 Post subject: Re: PixelServ / DnsMasq causing huge DNS resolve delays
The blacks and blacks6 files form pixelserv have become huge, so unless you have a 256 MB RAM router, use the attached pixelserv. Put in hosts4a and hosts6a extra blocked domains (one is for IPv4 and the other for IPv6).