#!/bin/sh
# OpenZaurus script
# symlink applications from mount points into the root dir (/)
# 
# Jason Jorgensen <jasonj@innominatus.com>
# Tested:
# SL5500 (Collie) - 3.5.1

from="/mnt/ram" # common from locations /mnt/ram /mnt/cf /mnt/card
to="/"


recurselinker () {
  echo "recurselinker called with $1"
  listing=$(ls $from/$1)
  for entry in $listing
  do
    if [ -d "$from/$1/$entry" ] && [ "$entry" != "ipkg" ]
    then
      echo "$from/$1/$entry is a directory, recursing"
      recurselinker "$1/$entry"
    fi
    echo "creating $to$1"
    mkdir -p $to$1
    echo "linking $from$1/$entry to $to$1/$entry"
    ln -sf $from$1/$entry $to$1/$entry
  done
}

recurselinker

ldconfig
