2 # Optware pre-installation script, Leon Kos 2006-2008
4 REPOSITORY
=http
://ipkg.nslu2-linux.org
/feeds
/optware
/oleg
/cross
/stable
7 PATH
=/bin
:/sbin
:/usr
/bin
:/usr
/sbin
:/opt
/bin
:/opt
/sbin
13 echo "Checking system config ..."
14 GATEWAY
=$
(netstat
-rn |
15 sed -n 's/^0.0.0.0[ \t]\{1,\}\([0-9.]\{8,\}\).*/\1/p' )
16 if [ -n "${GATEWAY}" ]; then
17 echo "Using ${GATEWAY} as default gateway."
19 echo "Error: No default gateway set!"
22 if [ -s /etc
/resolv.conf
]; then
23 echo "Using the following nameserver(s):"
24 if grep nameserver
/etc
/resolv.conf
; then
25 GATEWAY_SUBNET
=$
(echo "${GATEWAY}" |
26 sed 's/\.[0-9]\{1,3\}\.[0-9]\{1,3\}$//')
27 if [ "${GATEWAY_SUBNET}" = "192.168" ]; then
28 if grep -q ${GATEWAY} /etc
/resolv.conf
; then
29 echo "Gateway ${GATEWAY} is also nameserver."
31 echo "Warning: local nameserver is different than gateway!"
32 echo "Check config or enter:"
33 if test -L /etc
/resolv.conf
; then
34 echo " sed -i s/192.168.*/${GATEWAY}/ /tmp/resolv.conf"
36 echo " sed -i s/192.168.*/${GATEWAY}/ /etc/resolv.conf"
38 echo "to correct this."
42 echo "Error: No nameserver specified in /etc/resolv.conf"
46 echo "Error: Empty or nonexistent /etc/resolv.conf"
50 if mount |
grep -q /opt
; then
51 [ -d /opt
/etc
] && echo "Warning: /opt partition not empty!"
53 echo "Error: /opt partition not mounted."
55 echo " mkdir /jffs/opt"
56 echo " mount -o bind /jffs/opt /opt"
57 echo "to correct this."
66 echo "Installing package ${PACKAGE} ..."
67 wget
-O ${TMP}/${PACKAGE} ${REPOSITORY}/${PACKAGE}
69 tar xzf
${TMP}/${PACKAGE}
70 tar xzf
${TMP}/control.
tar.gz
72 if [ -f ${TMP}/preinst
] ; then
76 tar xzf
${TMP}/data.
tar.gz
77 if [ -f ${TMP}/postinst
] ; then
81 rm -f ${TMP}/data.
tar.gz
82 rm -f ${TMP}/control.
tar.gz
84 rm -f ${TMP}/${PACKAGE}
88 _install_package uclibc-opt_0.9
.28-13_mipsel.ipk
89 _install_package ipkg-opt_0.99
.163-10_mipsel.ipk
92 /opt
/bin
/ipkg
install -force-reinstall uclibc-opt
93 /opt
/bin
/ipkg
install -force-reinstall ipkg-opt
95 ## shibby`s repository ##
96 echo "src shibby http://tomato.groov.pl/repo" >> /opt
/etc
/ipkg.conf