diff options
| author | Matthew Hicks <mhicks@mhicks-host.usersys.redhat.com> | 2008-06-24 15:29:34 -0400 |
|---|---|---|
| committer | Matthew Hicks <mhicks@mhicks-host.usersys.redhat.com> | 2008-06-24 15:29:34 -0400 |
| commit | c8b3989c5a13f7d66dc056407fef438035f9c8fc (patch) | |
| tree | 4147b2e88328dc6a475600092c5b8ed68a0ad4c6 | |
| parent | 285b224b15956e236eeba4304ee5c71bf8720503 (diff) | |
More cleanup
| -rw-r--r-- | everest-replace-self/Makefile | 2 | ||||
| -rw-r--r-- | everest-replace-self/everest-replace-self.spec (renamed from everest-replace-self/everest-cloud.spec) | 22 | ||||
| -rwxr-xr-x | everest-replace-self/repo/everest-cloud-replace-self | 124 | ||||
| -rwxr-xr-x | everest-replace-self/repo/everest-cloud-replace-self.rb | 26 |
4 files changed, 12 insertions, 162 deletions
diff --git a/everest-replace-self/Makefile b/everest-replace-self/Makefile index ed784f9..5eb1afd 100644 --- a/everest-replace-self/Makefile +++ b/everest-replace-self/Makefile @@ -1,4 +1,4 @@ -NAME := everest-cloud +NAME := everest-replace-self 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) diff --git a/everest-replace-self/everest-cloud.spec b/everest-replace-self/everest-replace-self.spec index 8bcc6df..03fa34d 100644 --- a/everest-replace-self/everest-cloud.spec +++ b/everest-replace-self/everest-replace-self.spec @@ -1,18 +1,18 @@ -Summary: Everest Cloud Packages -Name: everest-cloud -Source: everest-cloud-bin.tar.gz -Version: 0.1.0 -Release: 1 +Summary: Everest Replace Self Utility +Name: everest-replace-self +Source: everest-replace-self-bin.tar.gz +Version: 1.0.0 +Release: 1%{?dist} BuildArch: noarch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot -Group: Red Hat -Vendor: Red Hat -URL: http://www.redhat.com -License: TBD +Group: Application/Systems +URL: https://fedorahosted.org/everest +License: GPLv2 %description -Everest scripts to reformat a machine to either act as a cloud -master or participate in an existing cloud. +Everest scripts to bring a system to a certain state +to allow a koan --replace-self to be run on the machine +using a default or specified profile. %prep diff --git a/everest-replace-self/repo/everest-cloud-replace-self b/everest-replace-self/repo/everest-cloud-replace-self deleted file mode 100755 index c888954..0000000 --- a/everest-replace-self/repo/everest-cloud-replace-self +++ /dev/null @@ -1,124 +0,0 @@ -#!/bin/bash - -LOG=/var/log/cloud.log -RHEL4_REPO=http://download.fedora.redhat.com/pub/epel/4/i386/epel-release-4-9.noarch.rpm -RHEL5_REPO=http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm -FEDORA_REPO=http://download.fedora.redhat.com/pub/fedora/linux/releases/8/Everything/i386/os/Packages/fedora-release-8-3.noarch.rpm -DEFAULT_PROFILE=EverestCloud-F8-i386 - -if [ "$USER" != "root" ]; then - echo "You need to run this as root" - exit 1 -fi - -# -# Check for options and print out help if necessary -# -USAGE=""" -Usage: everest-cloud-replace-self -[c]obbler_server -cloud_[m]aster -[p]rofile - -where options include: - -c (required) the cobbler server from which to provision this machine - -m (optional) the cloud master on which to connect this cloud instance - -p (optional) a specific profile to use for this machine""" - -while getopts ":n:c:m:p:" opt; do - case $opt in - c ) COBBLER="$OPTARG" ;; - m ) CLOUD="$OPTARG" ;; - p ) PROFILE="$OPTARG" ;; - * ) echo -e "$USAGE" - exit 1 - esac -done - -shift $(($OPTIND - 1)) - -if [ -z "$COBBLER" ]; then - echo "ERROR: The cobbler option is required" - echo -e "$USAGE" - exit 1 -fi - -if [ -z "$CLOUD" ]; then - CLOUD="localhost" -fi - -if [ -z "$PROFILE" ]; then - PROFILE="$DEFAULT_PROFILE" -fi - -echo "WARNING: This is going to completely reformat your system." -echo "Proceed? [y/N]:" -read confirm - -if [ "$confirm" != "y" ]; then - exit 1 -fi - -echo "Checking for required dependencies..." - -which ruby &> $LOG -RESULT=$? - -if [ "$RESULT" == "1" ]; then - echo "Upgrading ruby..." - yum install -y ruby &> /dev/null -fi - -which ruby &> $LOG -RESULT=$? - -if [ "$RESULT" == "1" ]; then - echo "ERROR: Please install ruby manually and try again." - exit 1 -fi - -# Check the version of koan -rpm -q koan | grep "koan-1\.*" &> $LOG -RESULT=$? - -if [ "$RESULT" == "1" ]; then - echo "Upgrading koan..." - echo "Cleaning up current yum repositories to get the right version of koan..." - - rpm -e --force epel-release &> $LOG - rm -rf /etc/yum.repos.d/* &> $LOG - yum clean all &> $LOG - - echo "Installing the yum repository required for koan..." - - # Install EPEL for the right version of RHEL - if [ "`grep 'Red Hat.*4' /etc/redhat-release`" != "" ]; then - rpm -Uvh --force $RHEL4_REPO &> $LOG - elif [ "`grep 'Red Hat.*5' /etc/redhat-release`" != "" ]; then - rpm -Uvh --force $RHEL5_REPO &> $LOG - elif [ "`grep 'Fedora' /etc/redhat-release`" != "" ]; then - rpm -Uvh --force $FEDORA_REPO &> $LOG - elif [ "`grep 'Red Hat' /etc/redhat-release`" != "" ]; then - echo "ERROR: Unknown operating system - please install koan manually." - exit 1 - else - echo "Not RHEL 4 or 5, assuming koan is available through yum" - fi - - yum install -y koan &> $LOG -fi - -# Double-check koan version -rpm -q koan | grep "koan-1\.*" &> $LOG -RESULT=$? - -if [ "$RESULT" == "1" ]; then - echo "ERROR: Please install koan >= 1.0 manually and try again." - exit 1 -fi - -# Now, call out to our script to do the cobbler system registration and koan -ruby /usr/bin/everest-cloud-replace-self.rb $COBBLER $CLOUD $PROFILE &> $LOG -RESULT=$? -if [ "$RESULT" == "1" ]; then - echo "ERROR: An unknown error occured, please check /var/log/cloud.log for details" -else - echo "You can now reboot your system to join the cloud." -fi diff --git a/everest-replace-self/repo/everest-cloud-replace-self.rb b/everest-replace-self/repo/everest-cloud-replace-self.rb deleted file mode 100755 index 3aeedac..0000000 --- a/everest-replace-self/repo/everest-cloud-replace-self.rb +++ /dev/null @@ -1,26 +0,0 @@ -require 'xmlrpc/client' - -# Parse out the arguments -cobbler = ARGV[0] -certmaster = ARGV[1] -profile = ARGV[2] -mac_addr = `/sbin/ifconfig eth0 | grep HWaddr | awk '{print $5}'`.chomp - -cobblerd = XMLRPC::Client.new2("http://#{cobbler}:25152") - -# TODO: figure out a way to pass these values in -token = cobblerd.call2("login", "cobbler", "password")[1] - -# Register the system with the MAC address as the name -system_id = cobblerd.call2("new_system", token)[1] -cobblerd.call2('modify_system', system_id, 'name', mac_addr, token) -cobblerd.call2('modify_system', system_id, 'profile', profile, token) - -# We pass up the certmaster to configure the machine as a func minion -ksmeta = "certmaster=#{certmaster}" - -cobblerd.call2('modify_system', system_id, 'ksmeta', ksmeta, token) -cobblerd.call2('save_system', system_id, token) - -koan_command = "/usr/bin/koan -s #{cobbler} --system=#{mac_addr} --replace-self" -`#{koan_command}` |
