#!/bin/sh perm_cron() { NEW="$1" OLD="$(dirname $NEW)/$(basename $NEW .new)" if [ -e $OLD ]; then chmod 0644 $NEW else chmod 0755 $NEW fi } perm() { # Keep same perms on file NEW="$1" OLD="$(dirname $NEW)/$(basename $NEW .new)" if [ -e $OLD ]; then cp -a $OLD $NEW.incoming cat $NEW > $NEW.incoming mv $NEW.incoming $NEW else chmod 0755 $NEW fi } config() { NEW="$1" OLD="$(dirname $NEW)/$(basename $NEW .new)" # If there's no config file by that name, mv it over: if [ ! -r $OLD ]; then mv $NEW $OLD elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then # toss the redundant copy rm $NEW fi # Otherwise, we leave the .new copy for the admin to consider... } perm etc/rc.d/rc.sysstat.new perm_cron etc/cron.daily/sysstat.new perm_cron etc/cron.hourly/sysstat.new config etc/rc.d/rc.sysstat.new config etc/cron.daily/sysstat.new config etc/cron.hourly/sysstat.new