Problem:
--You need to add a new script (versus modifying an existing one), and
--You want put do it within /etc/e-smith/templates-custom so it will be documented as a change to the base installation (as a script not yet part of a rpm).
Solution:
--put the script (either shell script or perl script) inside the following code snippet, between the lines containing EOF_SCRIPT
{ # DO NOT CHANGE THESE First Two LINES
$OUT=<<'EOF_SCRIPT'; # DO NOT CHANGE THESE First Two LINES
EOF_SCRIPT
$OUT =~ s/(.+)\n$/$1/s; # DO NOT CHANGE THESE Last Four LINES
system("echo \" chmod 554 $ARGV[0] \" | at now + 1 minutes ");
}
EXAMPLE: Add a script to perform a weekly file system check on an umounted drive/partition
1) cd /etc/e-smith/templates-custom/etc/cron.weekly
2) create a new file named fsck-for-dev-sda1, containing the following...
{ # DO NOT CHANGE THESE First Two LINES
$OUT=<<'EOF_SCRIPT'; # DO NOT CHANGE THESE First Two LINES
#!/bin/sh
# fdisk /dev/sda # run-once: here now as documentation
# and create new partition
# mkfs -t ext3 /dev/sda1 # run-once: here now as documentation
# tune2fs -c 336 /dev/sda1 # run-once: here now as documentation
# mkdir /mnt/sda # run-once: here now as documentation
# vi /etc/fstab # run-once: here now as documentation
# and add following line
#/dev/sda1 /mnt/sda ext3 defaults 1 2
# mkdir /var/log/fsck # run-once: here now as documentation
# if drive is already mounted, mail error message and exit
# NOTE: the following is contained all on a single line
{ mount /mnt/sda 2> /var/log/fsck/dev-sda1 && umount /mnt/sda ;} || { cat /var/log/fsck/dev-sda1 | /var/qmail/bin/mailsubj 'FSCK skipped for /dev/sda1 because drive was busy ' admin && exit 1 ; }
# do fsck, log the output and mail the output if exit status is non-zero
# NOTE: the following is contained all on a single line
fsck -a /dev/sda1 > /var/log/fsck/dev-sda1 || cat /var/log/fsck/dev-sda1 | /var/qmail/bin/mailsubj 'FSCK for /dev/sda1 had non-zero exit status' admin
exit 0
EOF_SCRIPT
$OUT =~ s/(.+)\n$/$1/s; # DO NOT CHANGE THESE Last Four LINES
system("echo \" chmod 554 $ARGV[0] \" | at now + 1 minutes ");
}
3) Expand the script...
/sbin/e-smith/expand-template /etc/cron.weekly/fsck-for-dev-sda1
4) wait one minute after the script is expanded, so that its permissions will allow execution
[%sig%]