Skip to content

Instantly share code, notes, and snippets.

@Danw33
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Danw33/53da47503ee861116585 to your computer and use it in GitHub Desktop.
Save Danw33/53da47503ee861116585 to your computer and use it in GitHub Desktop.
Mirror of Optware pre-installation script (optware-install-ddwrt.sh)

A Mirror

This Gist is a mirror of the original Optware pre-installation script as it appeared here on 16/07/2014. The only changes made are to the comment block at the top of the script (adding lines 4, 5 and 6).

The script, optware-install-ddwrt.sh is copyright it's respective creators and is only mirrored here for future reference and archival purposes.

Usage

Usage of this mirror (as above, with the URL of this Gist):

wget https://gist.githubusercontent.com/Danw33/53da47503ee861116585/raw/optware-install-ddwrt.sh -O - | tr -d '\r' > /tmp/optware-install.sh
sh /tmp/optware-install.sh

Usage (as given on the DD-WRT Wiki):

wget http://www.3iii.dk/linux/optware/optware-install-ddwrt.sh -O - | tr -d '\r' > /tmp/optware-install.sh
sh /tmp/optware-install.sh

References

For reference, the following links point to pages that are related to this script, including a link to the page as it appeared at the time of this mirror being created.

#!/bin/sh
# Optware pre-installation script, Leon Kos 2006, 2008
# added -verbose_wget to some lines, MrAlvin 2009
#
# Mirrored from http://www.3iii.dk/linux/optware/optware-install-ddwrt.sh
# Gist created: 16-07-2014 (following source unmodified)
REPOSITORY=http://ipkg.nslu2-linux.org/feeds/optware/ddwrt/cross/stable
TMP=/tmp
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/opt/bin:/opt/sbin
unset LD_PRELOAD
unset LD_LIBRARY_PATH
_check_config()
{
echo "Checking system config ..."
GATEWAY=$(netstat -rn |
sed -n 's/^0.0.0.0[ \t]\{1,\}\([0-9.]\{8,\}\).*/\1/p' )
if [ -n "${GATEWAY}" ]; then
echo "Using ${GATEWAY} as default gateway."
else
echo "Error: No default gateway set!"
exit 2
fi
if [ -s /etc/resolv.conf ]; then
echo "Using the following nameserver(s):"
if grep nameserver /etc/resolv.conf ; then
GATEWAY_SUBNET=$(echo "${GATEWAY}" |
sed 's/\.[0-9]\{1,3\}\.[0-9]\{1,3\}$//')
if [ "${GATEWAY_SUBNET}" = "192.168" ]; then
if grep -q ${GATEWAY} /etc/resolv.conf ; then
echo "Gateway ${GATEWAY} is also nameserver."
else
echo "Warning: local nameserver is different than gateway!"
echo "Check config or enter:"
if test -L /etc/resolv.conf ; then
echo " sed -i s/192.168.*/${GATEWAY}/ /tmp/resolv.conf"
else
echo " sed -i s/192.168.*/${GATEWAY}/ /etc/resolv.conf"
fi
echo "and try again - or wait to see if your download continues anyway."
fi
fi
else
echo "Error: No nameserver specified in /etc/resolv.conf"
exit 5
fi
else
echo "Error: Empty or nonexistent /etc/resolv.conf"
exit 3
fi
if mount | grep -q /opt ; then
[ -d /opt/etc ] && echo "Warning: /opt partition not empty!"
else
echo "Error: /opt partition not mounted."
echo "for running Optware on JFFS (not recommended), Enter"
echo " mkdir /jffs/opt"
echo " mount -o bind /jffs/opt /opt"
echo "to correct this."
exit 4
fi
}
_install_package()
{
PACKAGE=$1
echo "Installing package ${PACKAGE} ..."
echo " Some newer versions of DD-WRT does not show download progress bar,"
echo " so just be patient - or check STATUS -> BANDWIDTH tab for download"
echo " activity in your routers Web-GUI, and then still wait a minute or two."
wget -O ${TMP}/${PACKAGE} ${REPOSITORY}/${PACKAGE}
cd ${TMP}
tar xzf ${TMP}/${PACKAGE}
tar xzf ${TMP}/control.tar.gz
cd /
if [ -f ${TMP}/preinst ] ; then
sh ${TMP}/preinst
rm -f ${TMP}/preints
fi
tar xzf ${TMP}/data.tar.gz
if [ -f ${TMP}/postinst ] ; then
sh ${TMP}/postinst
rm -f ${TMP}/postinst
fi
rm -f ${TMP}/data.tar.gz
rm -f ${TMP}/control.tar.gz
rm -f ${TMP}/control
rm -f ${TMP}/${PACKAGE}
}
_check_config
_install_package uclibc-opt_0.9.28-13_mipsel.ipk
_install_package ipkg-opt_0.99.163-10_mipsel.ipk
/opt/sbin/ldconfig
/opt/bin/ipkg -verbose_wget update
/opt/bin/ipkg -force-reinstall -verbose_wget install uclibc-opt
/opt/bin/ipkg -force-reinstall -verbose_wget install ipkg-opt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment