Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # Script for installing optware on DD-WRT
- # Written by frater
- #
- # Modified for Minimized install
- export PATH=/opt/bin:/opt/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin
- SCRIPTVER="Mon Feb 21 13:43:19 CET 2011 (rev 22nd Feb 2011)"
- export SITES='http://ipkg.nslu2-linux.org http://ftp-osl.osuosl.org/pub/nslu2'
- export dom=wd.mirmana.com
- os_date="`nvram get os_date`"
- os_year=`date -r /bin/busybox +%Y`
- os_month=`date -r /bin/busybox +%m`
- os_day=$(( `date -r /bin/busybox +%e` + 0 ))
- # HASBINBASH=0
- # [ `nvram get os_date | awk '{print $3}'` -gt 2010 ] && HASBINBASH=1
- # If the time is not set then get it at least a bit up to date
- if [ `date +%s` -lt 99999 ] ; then
- ntpclient pool.ntp.org
- if [ `date +%s` -lt 99999 ] ; then
- date -s "${SCRIPTVER}"
- fi
- fi
- KERNEL=`/bin/uname -r`
- k26=0
- /bin/uname -r | grep -q "^2\.6\." && k26=1
- Atheros=0
- OLD_RC=1
- NEW_RC=0
- if [ $os_year -gt 2009 ] ; then
- if [ $os_year -eq 2010 ] ; then
- [ $os_month -gt 4 ] && NEW_RC=1
- else
- NEW_RC=1
- fi
- fi
- [ $os_year -gt 2009 ] && OLD_RC=0
- [ $os_year -eq 2009 ] && [ $os_month == 12 ] && OLD_RC=0
- REBOOT_CORRECT=0
- [ $os_year -gt 2009 ] && REBOOT_CORRECT=1
- echo -e "$0\nWritten on: ${SCRIPTVER}"
- date -u
- echo -e "If you're giving feedback, please post the version as well\n\n"
- if grep -iq 'Atheros' /proc/cpuinfo ; then
- Atheros=1
- echo "Atheros is not supported, sorry"
- exit 1
- fi
- if ! grep -i -q "MIPS" /proc/cpuinfo ; then
- echo "This device has no MIPS processor"
- exit 1
- fi
- if [ ! "$USER" = root ]; then
- echo -e "You're not root, you're ${USER}..\nI will not have enough permissions to do the things I want to do.\nExiting..."
- exit 1
- fi
- cd /tmp
- if ! /bin/mount 2>/dev/null | grep -q " on /opt " ; then
- echo -e "You need to mount /opt\nExiting..."
- exit 1
- fi
- echo -e "\n\nThis will take a while!\nIf you need to do some shopping.... do it now! ;-)\n"
- sleep 1
- mkdir -p /opt/etc/init.d 2>/dev/null
- if [ ! -d /opt/etc/init.d ] ; then
- echo -e "I'm unable to create the directory /opt/etc/init.d Check your config"
- exit 1
- fi
- ipkg=ipkg-opt
- if [ ${Atheros} -ne 0 ] ; then
- REPOSITORY=http://ipkg.nslu2-linux.org/feeds/optware/openwrt-atheros/cross/unstable
- ipkg=ipkg
- else
- flavour=feeds/optware/ddwrt/cross/stable
- ipkgopt=ipkg-opt_0.99.163-10_mipsel.ipk
- ERROR_STATE=1
- rm -f /tmp/ipk
- for cURL in ${SITES} ; do
- REPOSITORY=${cURL}/$flavour
- /usr/bin/wget -O /tmp/ipk ${REPOSITORY}/$ipkgopt >/dev/null
- if [ -f /tmp/ipk ] ; then
- ERROR_STATE=0
- break
- fi
- done
- rm -f /tmp/ipk
- DOMAIN=`echo ${cURL} | cut -b8- | awk -F/ '{print $1}'`
- fi
- echo "src/gz optware $REPOSITORY" > /tmp/ipkg.conf
- echo "dest /opt/ /" >> /tmp/ipkg.conf
- $ipkg print_installation_architecture >/dev/null 2>&1
- if [ ${?} -eq 0 ] ; then
- echo -e "You already installed optware, good show!\nI will execute an update"
- $ipkg update -f /tmp/ipkg.conf
- else
- echo -e "Optware is not installed... Let's install it\n"
- if [ $Atheros -ne 0 ] ; then
- $ipkg -verbose_wget update -f /tmp/ipkg.conf
- $ipkg -force-reinstall -verbose_wget install uclibc-opt -f /tmp/ipkg.conf
- else
- # wget http://www.3iii.dk/linux/optware/optware-install-ddwrt.sh -O - | tr -d '\r' > /tmp/optware-install.sh
- # wget http://www.wlan-sat.com/boleo/optware/optware-install-ddwrt.sh -O - | tr -d '\r' > /tmp/optware-install.sh
- wget http://${dom}/optware-install-ddwrt2.sh -O - | tr -d '\r' > /tmp/optware-install.sh
- sh /tmp/optware-install.sh
- fi
- $ipkg update -f /tmp/ipkg.conf 2>/dev/null
- if [ $? -ne 0 ] ; then
- echo -e "\n######\n\nOptware installation was NOT successfull...\nYour hardware is probably not compatible"
- cat /proc/cpuinfo
- exit 1
- fi
- fi
- nvram get rc_startup >/dev/null
- if [ ! $? -eq 0 ] ; then
- echo "Error getting startup value... is this really DD-WRT?"
- exit 1
- fi
- rc_startup=`nvram get rc_startup`
- if [ $OLD_RC -ne 0 ] ; then
- echo -en "nvram set rc_startup=\"" >/tmp/chng_startup
- echo -n "${rc_startup}" | sed -e 's/[$`"\]/\\&/g' >> /tmp/chng_startup
- if ! grep -q "/init.d/optS" /tmp/chng_startup ; then
- echo -e "\nn=1\nwhile [ ! -d /opt/etc/init.d ] ; do\n sleep 3\n [ \\\$n -gt 30 ] && break\n let n+=1\ndone\n/opt/etc/init.d/optS\n\"" >>/tmp/chng_startup
- chmod +x /tmp/chng_startup
- /tmp/chng_startup
- nvram commit
- fi
- rm /tmp/chng_startup
- rc_shutdown=`nvram get rc_shutdown`
- if ! nvram get rc_shutdown | grep -q "/init.d/optK" ; then
- echo -en "nvram set rc_shutdown=\"" >/tmp/chng_shutdown
- echo -e "/opt/etc/init.d/optK\n" >>/tmp/chng_shutdown
- echo -n "${rc_shutdown}" | sed -e 's/[$`"\]/\\&/g' >>/tmp/chng_shutdown
- echo -en "\"" >>/tmp/chng_shutdown
- chmod +x /tmp/chng_shutdown
- /tmp/chng_shutdown
- rm /tmp/chng_shutdown
- nvram commit
- fi
- fi
- mkdir -p /opt/etc/init.d 2>/dev/null
- mkdir -p /opt/usr/sbin 2>/dev/null
- if [ ! -d /opt/etc/init.d ] ; then
- echo "I was unable to create the directory /opt/etc/init.d, check if it is writable"
- exit 1
- fi
- mkdir -p /opt/var/backups
- mkdir -p /opt/tmp
- cd /opt/etc/init.d
- isVIRGIN=1
- [ -f /opt/etc/init.d/S35automount ] && isVIRGIN=0
- ##
- ## Stuff removed including and after the line: S45DISABLED=1
- ##
- echo -e "Script finished!!\nYou can now fully use optware if you login again...\nI advice a reboot!\n"
- echo -e "Do check if /opt will be mounted otherwise optware will not loaded!"
- echo -e "\n\nhttps://mail.mirmana.com/OTRW\n\n"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement