Monday, July 15, 2013

strip a sol8/9/10 system for golden image creation

here's a nice script to clean a system prior to making a golden image.

#!/bin/sh

cd `dirname "$0"`

rm -f /var/adm/messages.*
cp /dev/null /var/adm/messages
cp /dev/null /var/adm/wtmp
cp /dev/null /var/adm/sulog
cp /dev/null /var/adm/lastlog
cp /dev/null /var/cron/log
cp /dev/null /var/saf/zsmon/log
cp /dev/null /var/saf/_log
cp /dev/null /var/sadm/system/logs/install_log
cp /dev/null /home/admin/.history
rm -rf /var/sadm/patch/*
rm -f /var/spool/clientmqueue/*
rm -rf /var/tmp/*
rm -rf /var/preserve/*
rm -f /var/sadm/system/logs/sysidtool.log
rm -f /var/sadm/system/logs/begin.log*
rm -f /var/sadm/system/logs/finish.log*

cp -p /etc/shadow ./shadow.$$

echo "Type 'root' 2 times below!"
passwd root
rm -f /etc/oshadow
rm -f /etc/opasswd

./flarcreate \
 -c \
 -x /opt/whereever \
 -a golden \
 -e "a name $1" \
 -n "$1" \
 "$1.flar"


cp -p ./shadow.$$ /etc/shadow
rm ./shadow.$$

No comments: