#!/bin/bash
# Copyright (c) 2002 SuSE Linux AG Nuernberg, Germany.  All rights reserved.
#
# $Id: archiv_user,v 1.3 2003/10/27 07:32:20 varkoly Exp $
#
# This script archive the directories fbe found in the directory /home/archiv
#


DATUM=`date +%d-%m-%Y-%H-%M`

cd /home/archiv
for i in `find -type d -maxdepth 1` 
do
  test $i = "." || { 
    test -e /home/profile/$i && mv /home/profile/$i /home/archiv/$i/profile
    tar czf $i.$DATUM.tgz $i && rm -r $i || echo "Couldn't archiv $i"
    chown root.teachers $i.$DATUM.tgz
    chmod 640 $i.$DATUM.tgz
  }
done
