#!/bin/sh # # Bootstrap script for OpenWRT on the D-Link DSL-502T # Version 1.0 # # Copyright (c) 2007 Christopher Pascoe # # # This script fetches the components required to generate an OpenWRT image # that can be flashed directly onto a D-Link DSL-502T. # PATCH_URL=http://www.itee.uq.edu.au/~chrisp/DSL-502T_OpenWRT DSL502T_PATCH_FILENAME=dsl-502t-openwrt-2.4-1.patch PPP_CRASH_PATCH_FILENAME=ppp-crash-workarounds.patch DEFCONFIG_FILENAME=dsl-502t-defconfig if [ "x`pwd`" = "x$HOME" ] then echo "Are you sure you want to run this in the top level of your home directory?" echo "This script downloads files into the current directory." echo "Press ctrl-c to abort within 60 seconds if not." sleep 60 fi if [ "x$1" = "xunpatch" ] then if [ ! -f trunk/.cjp_patched ] then echo "Tree does not appear to be patched." exit 1 fi cd trunk patch -p0 -R < ../$PPP_CRASH_PATCH_FILENAME patch -p0 -R < ../$DSL502T_PATCH_FILENAME rm .cjp_patched exit 0 fi makehelp() { cat << EOM To build the tree: make -C trunk After the build completes, the image to flash is: trunk/bin/DLinkAU_DSL-502T_openwrt-2.4-squashfs.img EOM } notify() { cat << EOM ============================================================================== $1 ============================================================================== EOM sleep 1 } if [ -f trunk/.cjp_patched ] then cat << EOM You already seem to have run this script. You should only run it once. To change configuration options: make -C trunk menuconfig EOM makehelp exit 1 fi notify "Downloading patches and default configuration" if ! wget -N $PATCH_URL/$DSL502T_PATCH_FILENAME $PATCH_URL/$PPP_CRASH_PATCH_FILENAME $PATCH_URL/$DEFCONFIG_FILENAME then echo "Unable to obtain patch or config." exit 1 fi # Check out source and packages if [ ! -d trunk ] then notify "Checking out OpenWRT trunk" svn co https://svn.openwrt.org/openwrt/trunk || exit 1 else notify "Updating OpenWRT trunk" ( cd trunk && exec svn update ) || exit 1 fi if [ ! -d packages ] then notify "Checking out OpenWRT package tree" svn co https://svn.openwrt.org/openwrt/packages || exit 1 else notify "Updating OpenWRT package tree" ( cd packages && exec svn update ) || exit 1 fi cd trunk || exit 1 # Link in extra packages that were selected notify "Adding packages based on default configuration" for i in `grep ^CONFIG_PACKAGE_ ../$DEFCONFIG_FILENAME` do i=${i##CONFIG_PACKAGE_} i=${i%%=[my]} PDIR=`echo ../packages/*/$i` if [ -d package/$i ] then continue elif [ -d "$PDIR" ] then echo "* Added $i from OpenWRT package tree" ln -sf ../"$PDIR" package/ fi done echo echo "You can find more packages at: https://dev.openwrt.org/browser/packages" echo sleep 2 MD5="" MD5_DEF="" if [ -f .config ] then # Compare MD5=`cat .config | egrep -v '^(#|$)' | sort | md5sum -` MD5_DEF=`cat ../$DEFCONFIG_FILENAME | egrep -v '^(#|$)' | sort | md5sum -` fi if [ "x$MD5" != "x$MD5_DEF" ] then D=`date +%s` notify "Resetting configuration. Your old config will be saved into config.saved.$D" mv .config ../config.saved.$D else notify "Selecting default configuration." fi cp ../$DEFCONFIG_FILENAME .config notify "Patching the source tree with DSL-502T specific patches." if ! patch -p0 < ../$DSL502T_PATCH_FILENAME then exit 1 fi svn add target/linux/ar7-2.4/image/dsl502t `grep '(revision 0)$' ../$DSL502T_PATCH_FILENAME | awk '{print $2}' | uniq` notify "Patching the source tree with PPP crash workarounds." if ! patch -p0 < ../$PPP_CRASH_PATCH_FILENAME then exit 1 fi :> .cjp_patched || exit 1 notify "Run first configuration." sleep 2 make menuconfig makehelp