#!/bin/bash
if [[ ! -f /proc/cpuinfo ]]
then
  mount -v /proc
fi
if [[ ! -d /sys/class ]]
then
  mount -v /sys
fi
if [[ `df /dev/shm | grep -c dev.shm` -eq 0 ]]
then
  mount -v /dev/shm
fi
if [[ `grep -cE '/mnt/tmp[ 	]' /etc/fstab` -gt 0 && ! -d /mnt/tmp/tmp ]]
then
  mount -v /mnt/tmp
fi
if [[ ! -f /mnt/hd/slackware/env.sh ]]
then
  mount /mnt/hd/slackware
fi

for s in env.sh batch_compile2.sh batch_compile_patches.sh clean.sh umount.sh
do
sd=$s
if [[ "$s" = "batch_compile_patches.sh" ]]
then
  sd="compile_patches.sh"
fi
if [[ -f /mnt/hd/slackware/$s ]]
then
  diff ~/$sd /mnt/hd/slackware/$s
  if [[ $? -ne 0 ]]
  then
    \cp -p /mnt/hd/slackware/$s ~/$sd
  fi
fi
done

if [[ ! -h ~/pcommon ]]
then
  ln -s -v slackware/commonpkgs ~/pcommon
fi

if [[ -f ~/stop_compile.pl ]]
then
  if [[ ~/stop_compile.pl -nt /mnt/hd/slackware/stop_compile.pl ]]
  then
    echo "WARNING: local 'stop_compile.pl' newer than remote one"
  fi
fi

rsync -a /mnt/hd/slackware/mount.sh ~/mount.sh
