Router Model Linksys WRT160NL fix usb mount error script

Post new topic   Reply to topic    DD-WRT Forum Index -> Atheros WiSOC based Hardware

Please test and tell me is everething is ok
Yes it is Ok
50%
 50%  [ 1 ]
No it is not Ok
50%
 50%  [ 1 ]
I do not have this model router
0%
 0%  [ 0 ]
Total Votes : 2

Author Message
forum1
DD-WRT Novice


Joined: 05 Aug 2011
Posts: 25

PostPosted: Tue Sep 06, 2011 20:51    Post subject: Router Model Linksys WRT160NL fix usb mount error script Reply with quote
This is all code script with fixed source code in mount part.

Here is code to make your ddwrt torrent / samba / ftp

wrt160nlmod3_mnt.sh

Comment original line and replace with hardcoded

[img]
http://i.imgur.com/2pFnXw5.png[/img]

Code:



case "$1" in
initiate)
   echo "##################################"
   echo "# wrt160nlmod INITIAL SETUP ($VERSION) #"
   echo "##################################"
   echo -n "Finding USB drives... "

       # DEV=`find /dev/scsi/ -name disc`;
        DEV=`find /dev/discs/disc0/ -name part1`;
       
   echo "done."

   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 -n "Setting up ipkg... "
   mv /etc/ipkg.conf /etc/ipkg.conf.orig
   echo -e "src backfire http://downloads.openwrt.org/backfire/10.03-rc2/atheros/packages/\ndest root /\ndest ram /tmp" > /etc/ipkg.conf
   cp /bin/ipkg /bin/ipkg.orig
   cat /bin/ipkg.orig |sed -e "s/--passive-ftp //" > /bin/ipkg
   ipkg update >> /dev/null 2>&1
   ipkg install libc >> /dev/null 2>&1
   ipkg install coreutils-sort >> /dev/null 2>&1
   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."

   mkdir -p /mnt/downloads
   mkdir -p /mnt/downloads/.incomplete
   chmod -R 777 /mnt/downloads
;;

disable)
   echo "##########################"
   echo "# DISABLING AUTO STARTUP #"
   echo "##########################"
   echo -n "Are you really want to disable wrt160nlmod tools? [Y/N]: "
   read SURE;
   if [ "$SURE" == "Y" -o "$SURE" == "y" ]
   then
       echo -n "Clearing rc_startup... "
       nvram set rc_startup=""
       nvram commit
       echo "done."
       echo -n "Do you want to reboot the router now? [Y/N]: "
       read REB;
       if [ "$REB" == "Y" -o "$REB" == "y" ]
       then
       reboot
       else
       echo "Please reboot your router manually."
       fi
   fi
;;

update)
    echo -n "Updating wrt160nlmod script... "
    wget http://wrt160nl.org/files/wrt160nlmod.sh -O wrt160nlmod.sh.new -q
    mv wrt160nlmod.sh wrt160nlmod.sh.old
    mv wrt160nlmod.sh.new wrt160nlmod.sh
    chmod +x wrt160nlmod.sh
    echo "done."
;;

start)
   echo -n "Finding USB drives... "
   #DEV=`find /dev/scsi/ -name disc`;
   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."
;;

torrent)
    case "$2" in
    install)
   echo "#########################################"
   echo "# INSTALLING TRANSMISION TORRENT CLIENT #"
   echo "#########################################"
   echo -n "Setting up client... "
   ipkg install libevent >> /dev/null 2>&1
   ipkg install libcurl >> /dev/null 2>&1
   ipkg install zlib >> /dev/null 2>&1
   ipkg install transmission-daemon >> /dev/null 2>&1
   ipkg install transmission-web >> /dev/null 2>&1
   transmission-daemon
   sleep 5
   killall transmission-daemon
   sleep 8
   cp /tmp/root/.config/transmission-daemon/settings.json /tmp/root/.config/transmission-daemon/settings.json.orig
   cat /tmp/root/.config/transmission-daemon/settings.json.orig |sed -e "s/127\.0\.0\.1/127\.0\.0\.1,\*\.\*\.\*\.\*/;s/\\\\\/tmp\\\\\/root\\\\\/Downloads/\/mnt\/downloads/;s/\\\\\/tmp\\\\\/root\\\\\/.config\\\\\/transmission-daemon\\\\\/Incomplete/\/mnt\/downloads\/incomplete/;s/incomplete-dir-enabled\": false/incomplete-dir-enabled\": true/" > /tmp/root/.config/transmission-daemon/settings.json
   rm /tmp/root/.config/transmission-daemon/settings.json.orig
   ln -s /mnt/downloads/ /tmp/root/Downloads
   echo -e "done.\n\n"
   $0 torrent setup
    ;;
   
    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
;;

samba)
    case "$2" in
    install)
   echo "###########################"
   echo "# INSTALLING SAMBA SERVER #"
   echo "###########################"
   echo -n "Installing SAMBA server... "
   ipkg install samba-common >> /dev/null 2>&1
   ipkg install samba-server >> /dev/null 2>&1
   cp /etc/samba/smb.conf /etc/samba/smb.conf.orig
   cat /etc/samba/smb.conf.orig |sed "s/tmp/mnt\/downloads/;s/writeable = no/writeable = yes/;s/\[mnt\/downloads\]/\[downloads\]/" > /etc/samba/smb.conf
   echo "done."
   $0 samba setup
    ;;

    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
Sponsor
forum1
DD-WRT Novice


Joined: 05 Aug 2011
Posts: 25

PostPosted: Tue Sep 06, 2011 20:53    Post subject: I have this router and Reply with quote
I have this router and
Code:
DEV=`find /dev/scsi/ -name disc`;


not working correctly. I make hard-coder code and everything now is ok Wink Use if you have this model router. It work like a charm Wink
forum1
DD-WRT Novice


Joined: 05 Aug 2011
Posts: 25

PostPosted: Sat Oct 01, 2011 12:37    Post subject: (SVN revision 17201) have the same bug Reply with quote
I test lates version:

DD-WRT v24-sp2 (06/14/11) std
(SVN revision 17201)


and have the same bug Wink
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 Wink

Linux is full of fatals hidden bugs not like Windows.
maciejb84
DD-WRT Novice


Joined: 18 Nov 2011
Posts: 19

PostPosted: Fri Nov 18, 2011 2:24    Post subject: Re: I have this router and Reply with quote
forum1 wrote:
I have this router and
Code:
DEV=`find /dev/scsi/ -name disc`;


not working correctly. I make hard-coder code and everything now is ok Wink Use if you have this model router. It work like a charm Wink


what is hard-coder code?

can you show it here?
forum1
DD-WRT Novice


Joined: 05 Aug 2011
Posts: 25

PostPosted: Sun Jun 03, 2012 13:41    Post subject: Re: I have this router and Reply with quote
maciejb84 wrote:
forum1 wrote:
I have this router and
Code:
DEV=`find /dev/scsi/ -name disc`;


not working correctly. I make hard-coder code and everything now is ok Wink Use if you have this model router. It work like a charm Wink


what is hard-coder code?

can you show it here?


http://en.wikipedia.org/wiki/Hard_coding
forum1
DD-WRT Novice


Joined: 05 Aug 2011
Posts: 25

PostPosted: Sun Jun 03, 2012 13:42    Post subject: new version is available here Reply with quote
new version is available here

Code:

# wget http://dl.dropbox.com/u/35489915/wrt160nlmod_v2.sh -O wrt160nlmod.sh.new -q

sh wrt160nlmod.sh.new

forum1
DD-WRT Novice


Joined: 05 Aug 2011
Posts: 25

PostPosted: Sat Mar 16, 2013 10:14    Post subject: new problem Reply with quote
in new version in ddwrt have problem with this script becouse systems mount is read only Wink

at this point ddwrt is not very open source Wink
I do not know why ddwrt gurus not want to insert torrent in official firmware Wink

Have ftp,samba integrated and missing torrent, why?

Because only Buffalo pay to ddwrt. Cisco must pay some money to this people. I will never buy cisco product.
forum1
DD-WRT Novice


Joined: 05 Aug 2011
Posts: 25

PostPosted: Sat Mar 16, 2013 10:22    Post subject: other problem with router Reply with quote
Description When Wireless Network Mode is N-Only(2.4GHz) can not connect to wifi.

This is because CPU Model is wrong. Atheros AR9130 rev 2 (0xb8) is wrong hardware driver.

Official firmware work fine with Wireless Network Mode - N-Only(2.4GHz).
Additional Information current firmaware information

System

Router Name
DD-WRT

Router Model
Linksys WRT160NL

Firmware Version
DD-WRT v24-sp2 (02/11/13) - build 20675

Kernel Version
Linux 3.5.7-svn20625 4940 Mon Feb 11 05:17:37 CET 2013 mips

show wrong CPU Model: Atheros AR9130 rev 2 (0xb8)
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Atheros WiSOC based Hardware All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum