vpnrouting: fix to works it with mipsel
[tomato.git] / release / src / router / others / optware-install.sh
blobcf5b1affeacde25172af4ac49aae0239c759b7f4
1 #!/bin/sh
2 # Optware pre-installation script, Leon Kos 2006-2008
4 REPOSITORY=http://ipkg.nslu2-linux.org/feeds/optware/oleg/cross/stable
5 TMP=/tmp
7 PATH=/bin:/sbin:/usr/bin:/usr/sbin:/opt/bin:/opt/sbin
8 unset LD_PRELOAD
9 unset LD_LIBRARY_PATH
11 _check_config()
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."
18 else
19 echo "Error: No default gateway set!"
20 exit 2
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."
30 else
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"
35 else
36 echo " sed -i s/192.168.*/${GATEWAY}/ /etc/resolv.conf"
38 echo "to correct this."
41 else
42 echo "Error: No nameserver specified in /etc/resolv.conf"
43 exit 5
45 else
46 echo "Error: Empty or nonexistent /etc/resolv.conf"
47 exit 3
50 if mount | grep -q /opt ; then
51 [ -d /opt/etc ] && echo "Warning: /opt partition not empty!"
52 else
53 echo "Error: /opt partition not mounted."
54 echo "Enter"
55 echo " mkdir /jffs/opt"
56 echo " mount -o bind /jffs/opt /opt"
57 echo "to correct this."
58 exit 4
63 _install_package()
65 PACKAGE=$1
66 echo "Installing package ${PACKAGE} ..."
67 wget -O ${TMP}/${PACKAGE} ${REPOSITORY}/${PACKAGE}
68 cd ${TMP}
69 tar xzf ${TMP}/${PACKAGE}
70 tar xzf ${TMP}/control.tar.gz
71 cd /
72 if [ -f ${TMP}/preinst ] ; then
73 sh ${TMP}/preinst
74 rm -f ${TMP}/preints
76 tar xzf ${TMP}/data.tar.gz
77 if [ -f ${TMP}/postinst ] ; then
78 sh ${TMP}/postinst
79 rm -f ${TMP}/postinst
81 rm -f ${TMP}/data.tar.gz
82 rm -f ${TMP}/control.tar.gz
83 rm -f ${TMP}/control
84 rm -f ${TMP}/${PACKAGE}
87 _check_config
88 _install_package uclibc-opt_0.9.28-13_mipsel.ipk
89 _install_package ipkg-opt_0.99.163-10_mipsel.ipk
90 /opt/sbin/ldconfig
91 /opt/bin/ipkg update
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
97 /opt/bin/ipkg update