summaryrefslogtreecommitdiffstats
path: root/genome-firstboot
diff options
context:
space:
mode:
authorChris Alfonso <calfonso@redhat.com>2008-07-07 17:20:43 -0400
committerChris Alfonso <calfonso@redhat.com>2008-07-08 10:43:59 -0400
commit40598cb7bfeb6b1042482fe91701770b179c1803 (patch)
tree57d9b019a845fbcf4a7fcb8ccbce836bfc45174c /genome-firstboot
parent9b9d481f6684777e90bb144193251244d14926ae (diff)
downloadtools-40598cb7bfeb6b1042482fe91701770b179c1803.tar.gz
tools-40598cb7bfeb6b1042482fe91701770b179c1803.tar.xz
tools-40598cb7bfeb6b1042482fe91701770b179c1803.zip
Renaming everying everest to genome
Diffstat (limited to 'genome-firstboot')
-rw-r--r--genome-firstboot/Makefile36
-rw-r--r--genome-firstboot/genome-firstboot.spec54
-rwxr-xr-xgenome-firstboot/src/etc/init.d/genome-firstboot82
-rw-r--r--genome-firstboot/src/usr/sbin/genome-firstboot33
4 files changed, 205 insertions, 0 deletions
diff --git a/genome-firstboot/Makefile b/genome-firstboot/Makefile
new file mode 100644
index 0000000..129f396
--- /dev/null
+++ b/genome-firstboot/Makefile
@@ -0,0 +1,36 @@
+NAME := genome-firstboot
+SPECFILE = $(NAME).spec
+VERSION := $(shell rpm -q --qf "%{VERSION}\n" --specfile $(SPECFILE)| head -1)
+RELEASE := $(shell rpm -q --qf "%{RELEASE}\n" --specfile $(SPECFILE)| head -1)
+UPSTREAM_NAME = $(PROJECT)
+
+TAG = $(subst .,_,$(NAME)-$(VERSION)-$(RELEASE))
+
+CVS = cvs
+RPMBUILD = rpmbuild
+INSTALL = /usr/bin/install
+INSTALL_DIR = $(INSTALL) --verbose -d -m 755
+ARCHIVE = $(NAME).tar.gz
+
+RPM_TOPDIR = /tmp/$(NAME)-$(VERSION)-$(RELEASE)-build
+_RPM_OPTS = --define "_topdir $(RPM_TOPDIR)" \
+ --define "_builddir %{_topdir}" \
+ --define "_sourcedir $(shell pwd)" \
+ --define "_specdir $(shell pwd)" \
+ --define "_rpmdir $(shell pwd)" \
+ --define "_srcrpmdir $(shell pwd)" \
+ --define '_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm'
+RPM_OPTS = $(strip $(_RPM_OPTS))
+
+rpm: clean $(RPM_TOPDIR) $(SPECFILE) $(ARCHIVE)
+ $(RPMBUILD) --clean $(RPM_OPTS) -bb $(SPECFILE)
+ rm -f $(ARCHIVE)
+
+clean:
+ @rm -rfv *~ *.rpm $(RPM_TOPDIR) $(ARCHIVE)
+
+$(ARCHIVE):
+ cd src; tar cvzf ../$(ARCHIVE) ./*; cd ..
+
+$(RPM_TOPDIR):
+ @$(INSTALL_DIR) $@
diff --git a/genome-firstboot/genome-firstboot.spec b/genome-firstboot/genome-firstboot.spec
new file mode 100644
index 0000000..49b389c
--- /dev/null
+++ b/genome-firstboot/genome-firstboot.spec
@@ -0,0 +1,54 @@
+Summary: Genome bootstrapping service
+Name: genome-firstboot
+Source: genome-firstboot.tar.gz
+Version: 1.0.0
+Release: 1
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
+Group: RHWWW/Development
+Vendor: Red Hat
+URL: http://clearspace.knowledge.str.redhat.com/docs/DOC-1456
+License: GPL
+BuildArch: noarch
+
+%description
+Genome firstboot-like bootstrapping service
+
+%prep
+
+%setup -c
+
+%build
+
+%install
+# Cleaning up the build root
+rm -rf $RPM_BUILD_ROOT
+
+# Create the directory structure required to lay down our files
+mkdir -p $RPM_BUILD_ROOT/etc/sysconfig $RPM_BUILD_ROOT/etc/init.d $RPM_BUILD_ROOT/usr/sbin
+
+cp etc/init.d/genome-firstboot $RPM_BUILD_ROOT/etc/init.d
+cp usr/sbin/genome-firstboot $RPM_BUILD_ROOT/usr/sbin
+
+# This gets set to yes by another genome tool
+echo "RUN_BOOTSTRAP=NO" > $RPM_BUILD_ROOT/etc/sysconfig/genome-firstboot
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%preun
+if [ "$1" = "0" ] ; then # last uninstall
+ /sbin/chkconfig genome-firstboot off
+fi
+
+%post
+if [ "$1" = "1" ] ; then # first install
+ /sbin/chkconfig genome-firstboot on
+fi
+
+%files
+%defattr(-,root,root,-)
+%config /etc/sysconfig/genome-firstboot
+
+%defattr(744,root,root,-)
+/etc/init.d/genome-firstboot
+/usr/sbin/genome-firstboot
diff --git a/genome-firstboot/src/etc/init.d/genome-firstboot b/genome-firstboot/src/etc/init.d/genome-firstboot
new file mode 100755
index 0000000..118f11d
--- /dev/null
+++ b/genome-firstboot/src/etc/init.d/genome-firstboot
@@ -0,0 +1,82 @@
+#!/bin/bash
+#
+# genome-firstboot: Starts genome-firstboot if it hasn't been run before
+#
+# chkconfig: 35 99 95
+#
+# description: Firstboot is a program that runs on the first time \
+# a machine is booted after install. It checks for the existence \
+# of an /etc/sysconfig/genome-firstboot file. If it doesn't find the file, \
+# then the genome-firstboot program needs to run. If it finds the file, \
+# genome-firstboot will not be run.
+# If /etc/reconfigSys exists, run the reconfiguration
+# program and remove /etc/reconfigSys when done.
+#
+# Also will run if 'reconfig' is on the kernel cmdline.
+#
+
+# Source function library.
+. /etc/init.d/functions
+
+FILENAME=/etc/sysconfig/genome-firstboot
+LOCKFILE=/var/lock/subsys/genome-firstboot
+
+[ -z "$HOME" ] && export HOME=/
+
+case "$1" in
+ start)
+ action=run
+
+ [ -f "$LOCKFILE" ] && exit 0
+
+ if [ -f "$FILENAME" ] && ! grep -q '^RUN_BOOTSTRAP=YES' "$FILENAME"; then
+ action=skip
+ fi
+
+ if grep -i reconfig /proc/cmdline >/dev/null || [ -f /etc/reconfigSys ]; then
+ action=reconfig
+ fi
+
+ [ $action = skip ] && exit 0
+
+ runlevel=$(set -- $(runlevel); eval "echo \$$#" )
+ if grep -q "^id:5:initdefault:" /etc/inittab && [ "x$runlevel" = x5 ]; then
+ . /etc/sysconfig/i18n
+ if [ ! -f /etc/X11/xorg.conf -a ! -f /etc/X11/XF86Config ] ; then
+ echo -n $"X is not configured. Running system-config-display"
+ /usr/bin/system-config-display
+ echo -n $"X is now configured. Starting Setup Agent"
+ fi
+ fi
+
+ if [ $action = reconfig ]; then
+ echo -n $"Running system reconfiguration tool"
+ /usr/sbin/genome-firstboot --reconfig
+ exit 0
+ fi
+
+ touch $LOCKFILE
+ /usr/sbin/genome-firstboot
+ RETVAL=$?
+
+ if [ "$RETVAL" -eq 0 ]; then
+ action "" /bin/true
+ else
+ action "" /bin/false
+ fi
+
+ sed -i -e "s/\(RUN_BOOTSTRAP=\)YES/\1NO/" $FILENAME
+
+ exit 0
+ ;;
+
+ stop)
+ rm -f $LOCKFILE
+ ;;
+
+ *)
+ echo $"Usage: $0 {start|stop}"
+ RETVAL=1
+esac
+
+exit $RETVAL
diff --git a/genome-firstboot/src/usr/sbin/genome-firstboot b/genome-firstboot/src/usr/sbin/genome-firstboot
new file mode 100644
index 0000000..f83a9b1
--- /dev/null
+++ b/genome-firstboot/src/usr/sbin/genome-firstboot
@@ -0,0 +1,33 @@
+#!/bin/bash
+
+# TODO: check that these are set
+# GENOME_REPO
+# FQDN
+
+# source our config file
+. /etc/sysconfig/genome-firstboot
+
+# yum-updatesd will hold on to the yum lock file and mess things up
+service yum-updatesd stop
+chkconfig yum-updatesd off
+
+# set the hostname for this session
+# This will also make sure the hostname
+# is set correctly the first time we login
+hostname $FQDN
+
+grep HOSTNAME /etc/sysconfig/network
+if [ $? == 0 ]
+then
+ sed -i -e "s/\(HOSTNAME=\).*/\1$FQDN/" /etc/sysconfig/network
+else
+ echo "HOSTNAME=${FQDN}" >> /etc/sysconfig/network
+fi
+
+# Call back to the repo machine and clean the cert
+curl -d clean=$FQDN http://$GENOME_REPO/cgi-bin/puppetca.cgi
+
+# Wait for the cert to be cleared
+sleep 5
+
+puppetd --server $GENOME_REPO --fqdn $FQDN --test &