#!/bin/sh
# vim:set sw=4 ts=4:
#
# $Id: make_cron,v 1.7 2005/04/11 14:14:39 fabian Exp $
#
#############################################################################
#
# ALICE
# Automatic Linux Installation and Configuration Environment
#
# Copyright (c) 2000-2002 SuSE Linux Solutions AG, Eschborn, Germany
#               2002-2004 SuSE Linux AG, Eschborn, Germany
#               2005      SUSE GmbH, Nuernberg, Germany
#
# 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 of the License, 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.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
#############################################################################
#
# Author: Fabian Herschel
#
############################################################################
#
# make_cron
# Configures the inetd
#
# Sections: crontabs
# Tags:     ALL_USERS, CRONTAB_<user>
#
test -n "$alice_dir" || alice_dir="/usr/lib/alice2/"
export alice_dir

while [ $# -gt 0 ]
do
   case $1 in
       -h | --help | -? ) usage
                          exit 1
                          ;;
       -fqhn ) export fqhn=$2; shift
            ;;

   esac
   shift
done   

. $alice_dir/lib/alicerc

WELCOME
std_inetd_conf=/etc/inetd.conf
ALL_USERS=$( cat /etc/passwd | awk -F: '{ print $1 }' )
#
############################################################################
#
GET_CONFIGURATION crontabs $CFG_DEBUG
for user in $ALL_USERS
do
   case "$user" in
        +* ) # just do nothing for NIS/YP users
           ;;
         *)
            CRON_TABLE=""
            eval CRON_TABLE=\$CRONTAB_$user
            if [ -n "$CRON_TABLE" ]
            then
               #
               # a cron table is defined for this specific user
               #
               crontab -l -u $user > $alice_backup_dir/crontab.$user.$$ 2>/dev/null
               if [ $? -eq 1 ]
               then
                  # the users old crontable was empty, so we can remove
                  # the backup 
                  rm $alice_backup_dir/crontab.$user.$$
               fi
               #
               # change users cron table
               #
               echo "$CRON_TABLE" | crontab -u $user -
            fi
            ;;
   esac
done
#
############################################################################
# Thats all
GOOD_BYE 
