#!/bin/sh
#
# zhomefix -  program to move user data to alternate place
# version 0.1
#
# Copyright (C) 2005 hdluc@yahoo.com
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
######################################################################
ZHOME=/hdd2/zaurushome
#ZHOME=/hdd3/zaurushome

echo ""
echo "Zaurus SL-C3000 - zhome fixer"
echo ""
if [ ! -d $ZHOME ]; then
  echo "creating $ZHOME ..."
  mkdir $ZHOME
fi
for i in `ls -ad /home/zaurus/.*`
do
  if [ "$i" != "/home/zaurus/." ] && [ "$i" != "/home/zaurus/.." ] && [ "$i" != "/home/zaurus/.profile" ]; then
    FT=`file $i 2>/dev/null|grep symbolic`
    if [ "$FT" = ""  ]; then
      if [ -d $i ]; then
        echo linking directory $i
        mv $i $ZHOME
        ln -s $ZHOME/`basename $i` $i 
      fi
      if [ -f $i ]; then
        echo linking file $i
        mv $i $ZHOME
        ln -s $ZHOME/`basename $i` $i 
      fi
    else
      echo $i is already linked
    fi
  fi 
done
echo ""
echo "Done."
echo "hidden config files and directories"
echo "have been moved and linked to $ZHOME"
echo ""

