echo -n "Mounting USB drive... "
if [ "$(mount | grep /mnt)" != "" ]
then
echo -e -n "\n/mnt has been already used. umounting... "
umount /mnt
#mount $DEV /mnt
mount -o rw /dev/discs/disc0/part1 /mnt
echo "done."
else
#mount $DEV /mnt
mount -o rw /dev/discs/disc0/part1 /mnt
echo "done."
fi
echo -n "Copying stuff to USB... "
cp -a /etc/ /mnt/
cp -a /bin/ /mnt/
cp -a /dev/ /mnt/
cp -a /lib/ /mnt/
cp -a /usr/ /mnt/
cp -a /tmp/ /mnt/
cp -a /jffs/ /mnt/
echo "done."
echo -n "Mounting USB over running system... "
mount /mnt/etc /etc
mount /mnt/bin /bin
mount /mnt/dev /dev
mount /mnt/lib /lib
mount /mnt/usr /usr
mount /mnt/tmp /tmp
mount /mnt/jffs /jffs
echo "done."
echo -e "nvram show | grep wan_ipaddr= > /tmp/ip_currentquery
IPMATCH=\140cmp /tmp/ip_currentquery /tmp/ip_neweststored\140
if [ \042\044IPMATCH\042 == \042\042 ]; then echo -e \042IP match no action needed\042; else
echo -e \042New WAN IP, therefore restoring iptables settings\042
cat /etc/rc.* | grep iptables > /etc/rcc.iptables
sh /etc/rcc.iptables
nvram show | grep wan_ipaddr= > /tmp/ip_neweststored
fi" > /etc/rcc.iptables.cronjob
chmod +x /etc/rcc.iptables.cronjob
nvram show | grep wan_ipaddr= > /tmp/ip_neweststored
stopservice cron
nvram set cron_jobs="*/2 * * * * root /etc/rcc.iptables.cronjob
* * * * * root date > /etc/rcdate"
nvram set cron_enable=1
nvram commit
startservice cron
echo -n "Creating startup scripts... "
nvram set rc_startup="sleep 5
# mount \`find /dev/scsi/ -name disc\` /mnt
mount -o rw /dev/discs/disc0/part1 /mnt
mount /mnt/etc /etc
mount /mnt/bin /bin
mount /mnt/dev /dev
mount /mnt/lib /lib
mount /mnt/usr /usr
mount /mnt/tmp /tmp
mount /mnt/jffs /jffs
sleep 70
nvram show | grep wan_ipaddr= > /tmp/ip_neweststored
if [ -f /mnt/etc/rc.transmission ]; then /bin/sh /mnt/etc/rc.transmission; fi
if [ -f /mnt/etc/rc.samba ]; then /bin/sh /mnt/etc/rc.samba; fi
if [ -f /mnt/etc/rc.pureftpd ]; then /bin/sh /mnt/etc/rc.pureftpd; fi
if [ -f /mnt/etc/rc.p910nd ]; then /bin/sh /mnt/etc/rc.p910nd; fi
if [ -f /mnt/etc/rc.3g ]; then /bin/sh /mnt/etc/rc.3g; fi"
nvram commit
echo "done."
echo -n "Mounting USB drive... "
#mount $DEV /mnt
mount -o rw /dev/discs/disc0/part1 /mnt
echo "done."
echo -n "Mounting USB over running system... "
mount /mnt/etc /etc
mount /mnt/bin /bin
mount /mnt/dev /dev
mount /mnt/lib /lib
mount /mnt/usr /usr
mount /mnt/tmp /tmp
mount /mnt/jffs /jffs
echo "done."
echo -n "Starting services... "
if [ -f /mnt/etc/rc.transmission ]; then /bin/sh /mnt/etc/rc.transmission; fi
if [ -f /mnt/etc/rc.samba ]; then /bin/sh /mnt/etc/rc.samba; fi
if [ -f /mnt/etc/rc.pureftpd ]; then /bin/sh /mnt/etc/rc.pureftpd; fi
if [ -f /mnt/etc/rc.p910nd ]; then /bin/sh /mnt/etc/rc.p910nd; fi
if [ -f /mnt/etc/rc.3g ]; then /bin/sh /mnt/etc/rc.3g; fi
echo "done."
;;
setup)
echo "#########################################"
echo "# SETTING UP TORRENT CLIENT PREFERENCES #"
echo "#########################################"
echo -n "Do you want authentication for the TRANSMISSION GUI? [Y/N]: "
read AUTH;
if [ "$AUTH" == "Y" -o "$AUTH" == "y" ]
then
echo -n "Enter username: "
read TUSER;
echo -n "Enter password: "
read TPASS;
echo "transmission-daemon -a *.*.*.* -t -u $TUSER -v $TPASS -g /tmp/root/.config/transmission-daemon/ -w /mnt/downloads" > /mnt/etc/rc.transmission
else
echo "transmission-daemon -T -a *.*.*.* -g /tmp/root/.config/transmission-daemon/ -w /mnt/downloads" > /mnt/etc/rc.transmission
fi
# echo "Running transmission daemon... "
echo -n "Do you want to access TRANSMISSION GUI through the internet? [Y/N]: "
read RAT;
if [ "$RAT" == "Y" -o "$RAT" == "y" ]; then echo "iptables -I INPUT -p tcp --dport 9091 -j ACCEPT" >> /mnt/etc/rc.transmission;
iptables -I INPUT -p tcp --dport 9091 -j ACCEPT; else
for i in `iptables --line-number -n -L |grep 9091 |awk '{print $1}' |sort -n -r`; do iptables -D INPUT $i; done
cat /mnt/etc/rc.transmission |grep -v 'iptables' > /mnt/etc/rc.transmission;
fi
# PID=`pidof transmission-daemon`;
if [ "`pidof transmission-daemon`" != "" ]
then
echo -n "Do you want to restart transmission-daemon? [Y/N]: "
read REST;
if [ "$REST" == "Y" -o "$REST" == "y" ]; then kill -2 `pidof transmission-daemon`; /bin/sh /mnt/etc/rc.transmission; fi
else
/bin/sh /mnt/etc/rc.transmission
fi
echo -e "You can access the GUI via http://193.168.0.1:9091\n"
echo -e "Very important to read http://wrt160nl.org FAQ Q114. related to settings and general info how to switch-off the router.\n"
;;
esac
;;
setup)
echo "############################"
echo "# CONFIGURING SAMBA SERVER #"
echo "############################"
if [ ! -f /etc/samba/smbpasswd ]; then touch /etc/samba/smbpasswd; fi
echo -n "Do you want password authentication? [Y/N]: "
read AUTH;
if [ "$AUTH" == "Y" -o "$AUTH" == "y" ]; then smbpasswd -a root; else smbpasswd -a root -n; fi
echo "/usr/sbin/smbd -D" > /mnt/etc/rc.samba
/bin/sh /mnt/etc/rc.samba
echo "Samba is now accessible with user name \"OpenWrt\\root\" at \\\\193.168.0.1\\downloads\\"
echo "Please note that Windows 7 users should enable NTLMv2 authentication"
echo "HOWTO: http://www.builderau.com.au/blogs/viewblogpost.htm?p=339270746"
;;
esac
;;
ftp)
case "$2" in
install)
echo "###############################"
echo "# INSTALLING PURE-FTPD SERVER #"
echo "###############################"
echo -n "Installing PURE-FTPD server... "
ipkg install pure-ftpd >> /dev/null 2>&1
echo "done."
echo -n "Do you want to use different port than 21? [Y/N]: "
read DPF;
if [ "$DPF" == "Y" -o "$DPF" == "y" ]
then
echo -n "Enter port: "
read PORT;
echo "pure-ftpd -E -b -B -S0.0.0.0,$PORT -lpuredb:/etc/pureftpd.pdb" > /mnt/etc/rc.pureftpd
else
echo "pure-ftpd -E -b -B -S0.0.0.0,21 -lpuredb:/etc/pureftpd.pdb" > /mnt/etc/rc.pureftpd
fi
$0 ftp setup
;;
setup)
echo "################################"
echo "# CONFIGURING PURE-FTPD SERVER #"
echo "################################"
if [ -f /etc/pureftpd.passwd ]; then echo -e "Existing accounts:\n`pure-pw list`\n"; fi
while [ "$FTPA" != 6 ];
do
echo "1. List existing accounts"; echo "2. Add new account"; echo "3. Delete account";
echo "4. Enable FTP over internet (INSECURE)"; echo "5. Disable FTP over internet (SECURE)"; echo "6. Exit setup";
read FTPA;
case "$FTPA" in
1)
echo "Listing users: "
LIST=`pure-pw list 2>>/dev/null`
if [ "$LIST" == "" ]; then echo -e "No users found. Please create a new user!\n"; else echo -e "$LIST\n"; fi
;;
2)
echo -n "Enter username: "
read ADDUSER;
pure-pw useradd $ADDUSER -u 1 -g 1 -d /mnt/downloads
pure-pw mkdb
echo -e "'$ADDUSER' has been added.\n"
;;
3)
echo -n "Enter username for deletion: "
read RMUSER;
IFEXIST=`pure-pw list |grep $RMUSER`
if [ "$IFEXIST" == "" ]; then echo -e "User not found. Please enter a valid user for deletion!\n"; else
pure-pw userdel $RMUSER
pure-pw mkdb
echo -e "'$RMUSER' has been deleted.\n"
fi
;;
4)
echo -n "Enabling Pure-FTPD over public iptables... "
PORT=`cat /mnt/etc/rc.pureftpd |grep pure-ftpd |awk '{print $5}' |sed -e "s/.*,//"`
echo "iptables -I INPUT -p tcp --dport $PORT -j ACCEPT" >> /mnt/etc/rc.pureftpd
echo -e "done.\n"
;;
5)
echo -n "Disabling Pure-FTPD over public internet... "
PORT=`cat /mnt/etc/rc.pureftpd |grep pure-ftpd |awk '{print $5}' |sed -e "s/.*,//"`
for i in `iptables --line-number -n -L |grep $PORT |awk '{print $1}' |sort -n -r`; do iptables -D INPUT $i; done
if [ -f /mnt/etc/rc.pureftpd ]; then cat /mnt/etc/rc.pureftpd |grep -v 'iptables' > /mnt/etc/rc.pureftpd; fi
echo -e "done.\n"
;;
esac
done
/bin/sh /mnt/etc/rc.pureftpd
;;
esac
;;
printer)
echo -n "Setting up printer... "
PRINTER=`dmesg |grep usblp0`
if [ "$PRINTER" == "" ]
then
echo "ERROR: No USB printer found!";
echo "Please attach the USB printer, and enable USB support in the web administration page.";
else
mkdir /dev/usb
mknod -m 660 /dev/usb/lp0 c 180 0
ipkg install p910nd >> /dev/null 2>&1
echo "/usr/sbin/p910nd -b -f /dev/usb/lp0 0" > /mnt/etc/rc.p910nd
echo "done."
fi
/bin/sh /mnt/etc/rc.p910nd
;;
3g)
case "$2" in
install)
echo -n "Setting up device... "
mkdir -p /dev/usb
mkdir -p /dev/usb/tts
mknod -m 600 /dev/usb/tts/0 c 188 0
mknod -m 600 /dev/usb/tts/1 c 188 1
echo "done."
echo -n "Setting up scripts... "
echo -e "iptables -A FORWARD -i br0 -o ppp0 -j ACCEPT\niptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE\n" > /mnt/etc/rc.3g
/bin/sh /mnt/etc/rc.3g
echo "
#!/bin/sh
WANGW=`ip route |grep default |grep eth1 |awk '{print $3}'`
3GGW=`ip route |grep default |grep ppp0 |awk '{print $3}'`
if [ \"`ip route |grep 4.2.2.2`\" == \"\" ]; then ip route add 4.2.2.2 via $WANGW dev eth1; fi
if [ \"`pidof pppd`\" == \"\" ]; then pppd file /tmp/ppp/options.pppoe; fi
if [ \"`ping -I eth1 -c 1 4.2.2.2 |grep '64 bytes'`\" == \"\" ];
then
if [ \"`ip route |grep default |awk '{print $5}'`\" == \"ppp0\" ];
then sleep 15;
else
echo \"`date` - Missing hearthbeat... falling back to 3G\" >> /tmp/root/netmon.log
ip route del default via $WANGW dev eth1
ip route add default via $3GGW dev ppp0
fi
else
if [ \"`ip route |grep default |awk '{print $5}'`\" == \"eth1\" ];
then sleep 15;
else
echo \"`date` - Found new hearthbeat... falling back to DHCP\" >> /tmp/root/netmon.log
ip route del default via $3GGW dev ppp0
ip route add default via $WANGW dev eth1
fi
fi
/bin/sh /tmp/root/netmon.sh
" > /tmp/root/netmon.sh
chmod +x /tmp/root/netmon.sh
echo "done."
echo "Please attach the 3G modem to the router and perform setup via GUI"
echo "When finished, please run /tmp/root/netmon.sh"
;;
esac
;;
*)
echo "wrt160nlmod VERSION v1.0561"
echo "Usage: $0 option"
echo "Available options:"
echo " initiate - INITIAL SETUP - THIS SHOULD BE RUN FIRST!"
echo " disable - Clearing auto-startup and restore to defaults"
echo " update - Update wrt160nlmod script to the latest version"
# echo " start - Needed after router reboots. Don't run this after initiation."
echo " torrent install - Installing transmission torrent client"
echo " torrent setup - Setting up transmission torrent client"
echo " samba install - Installing Samba server"
echo " samba setup - Setting up Samba server"
echo " ftp install - Installing pure-ftpd server"
echo " ftp setup - Setting up pure-ftpd server"
echo " printer - Setting up the USB printer and sharing"
# echo " 3g install - Installing WAN monitor for 3G/DSL/LAN"
# echo " 3g setup - Setting up WAN monitor script"
echo " "
;;
esac
$# INSTALLING SAMBA SERVER #
echo Setting up scripts... [/img]
$0 samba setup
;;
setup)
echo ]
then
echo
Last edited by forum1 on Sat Mar 16, 2013 10:11; edited 5 times in total
Posted: Sat Oct 01, 2011 12:37 Post subject: (SVN revision 17201) have the same bug
I test lates version:
DD-WRT v24-sp2 (06/14/11) std
(SVN revision 17201)
and have the same bug
Only first time work samba, after some management restarts and some settings changes on samba dd-wrt web configuration. Samba not working on usb /mnt device any more.
So many bugs
Linux is full of fatals hidden bugs not like Windows.