Skip to content

Instantly share code, notes, and snippets.

@ganapathichidambaram
Last active November 11, 2019 09:07
Show Gist options
  • Save ganapathichidambaram/3643629721003d7f2ea09cfe09ceaa72 to your computer and use it in GitHub Desktop.
Save ganapathichidambaram/3643629721003d7f2ea09cfe09ceaa72 to your computer and use it in GitHub Desktop.
Sample Post Installation KickStart Script - Anaconda
#
# Set up the serial console
#
%post
echo ":: Setting up Serial Console ::" >> /root/post.log
perl -p -i -e 's/^(default.*)$/$1\nserial --unit=0 --speed=9600 --data=8 --parity=no --stop=1\nterminal --timeout=5 serial console/' /boot/grub/grub.conf >> /root/post.log 2>&1
perl -p -i -e 's/^(\s+kernel.*)$/$1 console=tty0 console=ttyS0,9600/' /boot/grub/grub.conf >> /root/post.log 2>&1
echo "" >> /etc/inittab
echo "# Run serial console on ttyS0" >> /etc/inittab
echo "S1:2345:respawn:/sbin/agetty ttyS0 9600 vt100" >> /etc/inittab
echo "ttyS0" >> /etc/securetty
echo ":: Done Setting up Serial Console ::" >> /root/post.log
#
# Save the configuration information for later reference
#
%post
echo ":: Saving configuration information ::" >> /root/post.log
mkdir -p /var/installation
cd /var/installation
mv /root/install.log* /var/installation >> /root/post.log 2>&1
mv /root/anaconda-ks.cfg /var/installation >> /root/post.log 2>&1
cp /tmp/partition.ks /var/installation >> /root/post.log 2>&1
mv /root/post.log /var/installation
#
# Post-install scripts
# SAG pp 21-22
%post --interpreter /bin/bash
/sbin/chkconfig xfs off
/sbin/chkconfig lvm2-monitor off
/sbin/chkconfig sendmail off
/sbin/chkconfig autofs off
/sbin/chkconfig portmap off
/sbin/chkconfig ntpd on
%post --interpreter /bin/bash
# We have to set up the issue files here because it changes for every
# revision of the OS.
rm -f /etc/issue /etc/issue.net
cat <<EOT > /etc/issue
***********************************************************************
* Access to this computer system is limited to authorised users only. *
* Unauthorised users may be subject to prosecution under the Crimes *
* Act or State legislation *
* *
* Please note, ALL CUSTOMER DETAILS are confidential and must *
* not be disclosed. *
***********************************************************************
EOT
cp /etc/issue /etc/issue.net
# Add users
echo ":: Adding users and groups ::" >> /var/installation/post.log
groupadd -g 100 myusers >> /var/installation/post.log 2>&1
useradd -c "Peter Papagiannopoulos" -d /home/ppapa -m -s /bin/tcsh -u 1000 -g 100 -p 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX' ppapa >> /var/installation/post.log 2>&1
echo ":: Adding users to wheel group ::" >> /var/installation/post.log
cp -p /etc/group /etc/group.bk>> /var/installation/post.log 2>&1
sed -e 's/wheel:x:10:root/wheel:x:10:root,ppapa/' /etc/group.bk > /etc/group
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment