Buscando y buscando, con Manuel Alaba  después de luchar con problemas de escritura y cuanta cosa , encontramos un scrip que realiza todo el proceso para instalar los paquetes IPKG en el router DD WRT.

Acá se los dejo, el scipt es awesom ;

#!/bin/sh
################################################
# Modding script for Linksys WRT160NL & WRT500NL
# Features:
#    -graphical torrent client
#    -pure-ftpd virtual user system
#    -samba
#    -printer sharing
#
# Author: tsoky, tema (2010)
################################################
#VERSION v1.056291

case "$1" in
initiate)
	echo "##################################"
	echo "# wrt160nlmod INITIAL SETUP ($VERSION) #"
	echo "##################################"
	echo -n "Finding USB drives... "
	DEV=`find /dev/scsi/ -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
	echo "done."
	else
	mount $DEV /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 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]: "

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 part1`;
	echo "done."

	echo -n "Mounting USB drive... "
	mount $DEV /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://192.168.1.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 \\\\192.168.1.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

 

Fuente:  http://wrt160nl.org/tutoeng.html

Saludos