#!/bin/sh
# Author: redhat27
# snbforums thread: https://www.snbforums.com/threads/fun-with-www-user.38546/
[ -z "$1" ] && echo "$0: Specify a directory on the router you want to expose!" && exit 1
[ ! -d "$1" ] && echo "$0: Cannot find the directory $1 on this router!" && exit 2
ps_line=$(ps | sed -n '/[l]ighttpd /s/-[D,f]//p')
if [ -n "$ps_line" ]; then
root=$(sed -n 's/"//g;/document-root/s/^.*= //p' ${ps_line##* })
port=$(sed -n 's/"//g;/port/s/^.*= //p' ${ps_line##* })
base=${1#/} base=${base%%/*}
[ -L "$root/$base" ] || ln -s /$base $root/$base
echo -e "Created symlink $root/$base and $root/$(basename $1).html\nPlease remove [rm -f $root/$base $root/$(basename $1).html] to undo the changes!"
append=":$port"
else
Complain="
This page would work so much better if you had lighttpd installed and running. If you have entware, you can install it with opkg install lighttpd
Right now, you can only see the file listings inside of $1, but will not be able to see the contents or download any of the files. Sad :(
"
root="/www/user"
httpd_ps=$(ps | grep "[h]ttpd ")
if [ -n "$httpd_ps" ]; then
httpd_port=$(ps | grep "[h]ttpd " | sed -n "s/^.*-p //p" | awk '{print $1}')
[ -z "$httpd_port" -o "$httpd_port" = "80" ] || append=":$httpd_port"
else
httpds_port=$(ps | grep "[h]ttpds " | sed -n "s/^.*-p //p" | awk '{print $1}')
[ -z "$httpds_port" -o "$httpds_port" = "443" ] || append=":$httpds_port"
s=s
fi
append="$append/user"
fi
OUT="$root/$(basename $1).html"
echo -e "\n