#!/bin/bash
-# for some reason not all systems have @base installed
-yum install -y -q @base
-
-# also make sure that a few other utilities are definitely installed
-yum install -y -q unzip xz
-
-# install some needed internal networking configurations
-yum install -y dnsmasq puppet
-
-# install specific versions of puppet modules
-puppet module install puppetlabs-stdlib -v 4.5.1
-puppet module install puppetlabs-concat -v 1.2.0
-puppet module install lex-dnsmasq -v 2.6.1
-
# script requires information about subdomain
if [ -z "$1" ]; then
>&2 echo "Please provide the subdomain to Vagrant"
exit 1
+else
+ SUBDOM=$1
fi
-# write the subdomain information into a custom facter fact
-mkdir -p /etc/facter/facts.d/
-echo "subdomain=${1}" > /etc/facter/facts.d/subdomain.txt
-# remove current networking configurations
-rm -f /etc/sysconfig/network-scripts/{ifcfg,route}-{eth,docker}*
+all_systems() {
+ # install specific versions of puppet modules
+ puppet module install puppetlabs-stdlib -v 4.5.1
+ puppet module install puppetlabs-concat -v 1.2.0
+ puppet module install lex-dnsmasq -v 2.6.1
+
+ # write the subdomain information into a custom facter fact
+ mkdir -p /etc/facter/facts.d/
+ echo "subdomain=${SUBDOM}" > /etc/facter/facts.d/subdomain.txt
+
+ # final bits
+ puppet apply /vagrant/confignetwork.pp
+
+}
+
+rh_systems_init() {
+ # for some reason not all systems have @base installed
+ yum install -y -q @base
+
+ # also make sure that a few other utilities are definitely installed
+ yum install -y -q unzip xz
-# final bits
-puppet apply /vagrant/confignetwork.pp
+ # install some needed internal networking configurations
+ yum install -y dnsmasq puppet
-# so that cloud-init doesn't futz with our resolv config after we've
-# configured it
-chattr +i /etc/resolv.conf
+ # remove current networking configurations
+ rm -f /etc/sysconfig/network-scripts/{ifcfg,route}-{eth,docker}*
+}
-# don't let cloud-init do funny things to our routing
-chattr +i /etc/sysconfig/network-scripts/route-eth0
+rh_systems_post() {
+ # don't let cloud-init do funny things to our routing
+ chattr +i /etc/sysconfig/network-scripts/route-eth0
-# setup the needed routing
-cat <<EOL >> /etc/rc.d/post-cloud-init
+ # setup the needed routing
+ cat <<EOL >> /etc/rc.d/post-cloud-init
#!/bin/bash
# always force puppet to rerun
/usr/bin/puppet apply /vagrant/confignetwork.pp
EOL
-chmod +x /etc/rc.d/post-cloud-init
+ chmod +x /etc/rc.d/post-cloud-init
+
+ # so that the network stack doesn't futz with our resolv config
+ # after we've configured it
+ chattr +i /etc/resolv.conf
+}
+
+ubuntu_systems_post() {
+ # don't let cloud-init destroy our routing
+# chattr +i /etc/network/if-up.d/0000routing
+ echo "---> do nothing for now"
+}
systemd_init() {
# create a post-cloud-init.service and enable it
/sbin/chkconfig post-cloud-init on
}
-echo "Checking distribution"
-if [ `/usr/bin/facter operatingsystem` = "Fedora" ]; then
- echo "---> Fedora found"
- systemd_init
-else
- if [ `/usr/bin/facter operatingsystemrelease | /bin/cut -d '.' -f1` = "7" ]; then
- echo "---> CentOS 7"
- systemd_init
- else
- echo "---> CentOS 6"
- sysv_init
- fi
-fi
+# Execute setup that all systems need
+all_systems
+
+echo "---> Checking distribution"
+FACTER_OSFAMILY=`/usr/bin/facter osfamily`
+FACTER_OS=`/usr/bin/facter operatingsystem`
+case "$FACTER_OSFAMILY" in
+ RedHat)
+ rh_systems_init
+ case "$FACTER_OS" in
+ Fedora)
+ echo "---> Fedora found"
+ systemd_init
+ ;;
+ RedHat|CentOS)
+ if [ `/usr/bin/facter operatingsystemrelease | /bin/cut -d '.' -f1` = "7" ]; then
+ echo "---> CentOS 7"
+ systemd_init
+ else
+ echo "---> CentOS 6"
+ sysv_init
+ fi
+ ;;
+ *)
+ echo "---> Unknown RH Family OS: ${FACTER_OS}"
+ ;;
+ esac
+ rh_systems_post
+ ;;
+ Debian)
+ case "$FACTER_OS" in
+ Ubuntu)
+ echo "---> Ubuntu found"
+ ubuntu_systems_post
+ ;;
+ *)
+ "---> Nothing to do for ${FACTER_OS}"
+ ;;
+ esac
+ ;;
+ *)
+ echo "---> Unknown OS: ${FACTER_OSFAMILY}"
+ ;;
+esac
# vim: sw=4 ts=4 sts=4 et :
#!/bin/bash
+# vim: sw=2 ts=2 sts=2 et :
+
+if [ -f /.autorelabel ]; then
+ echo "**********************************************"
+ echo "* SYSTEM REQUIRES RELABELING SKIPPING RESEAL *"
+ echo "* PLEASE RESTART SYSTEM AND RERUN *"
+ echo "* PROVISIONING SCRIPTS *"
+ echo "**********************************************"
+ exit 1;
+fi
+
+# clean-up from any prior cloud-init networking
+rm -rf /etc/sysconfig/network-scripts/{ifcfg,route}-eth*
+
rm -rf /etc/Pegasus/*.cnf /etc/Pegasus/*.crt /etc/Pegasus/*.csr /etc/Pegasus/*.pem /etc/Pegasus/*.srl /root/anaconda-ks.cfg /root/anaconda-post.log /root/initial-setup-ks.cfg /root/install.log /root/install.log.syslog /var/cache/fontconfig/* /var/cache/gdm/* /var/cache/man/* /var/lib/AccountService/users/* /var/lib/fprint/* /var/lib/logrotate.status /var/log/*.log* /var/log/BackupPC/LOG /var/log/ConsoleKit/* /var/log/anaconda.syslog /var/log/anaconda/* /var/log/apache2/*_log /var/log/apache2/*_log-* /var/log/apt/* /var/log/aptitude* /var/log/audit/* /var/log/btmp* /var/log/ceph/*.log /var/log/chrony/*.log /var/log/cron* /var/log/cups/*_log /var/log/debug* /var/log/dmesg* /var/log/exim4/* /var/log/faillog* /var/log/gdm/* /var/log/glusterfs/*glusterd.vol.log /var/log/glusterfs/glusterfs.log /var/log/httpd/*log /var/log/installer/* /var/log/jetty/jetty-console.log /var/log/journal/* /var/log/lastlog* /var/log/libvirt/libvirtd.log /var/log/libvirt/lxc/*.log /var/log/libvirt/qemu/*.log /var/log/libvirt/uml/*.log /var/log/lightdm/* /var/log/mail/* /var/log/maillog* /var/log/messages* /var/log/ntp /var/log/ntpstats/* /var/log/ppp/connect-errors /var/log/rhsm/* /var/log/sa/* /var/log/secure* /var/log/setroubleshoot/*.log /var/log/spooler* /var/log/squid/*.log /var/log/syslog* /var/log/tallylog* /var/log/tuned/tuned.log /var/log/wtmp* /var/named/data/named.run
rm -rf ~/.viminfo /etc/ssh/ssh*key*
+# kill any cloud-init related bits
+rm -rf /var/lib/cloud/*
+
+if [ -e /usr/bin/facter ]
+then
+ if [ `/usr/bin/facter operatingsystem` = 'Ubuntu' ]
+ then
+ rm -rf /etc/hostname* /etc/hosts /etc/network/interfaces /etc/network/interfaces.*.bak~
+ cat <<EOINT >> /etc/network/interfaces
+# Used by ifup(8) and ifdown(8). See the interfaces(5) manpage or
+# /usr/share/doc/ifupdown/examples for more information.
+# The loopback network interface
+auto lo
+iface lo inet loopback
+EOINT
+ fi
+fi
+
echo "********************************************"
echo "* PLEASE SNAPSHOT IMAGE AT THIS TIME *"
echo "********************************************"