summaryrefslogtreecommitdiffstats
path: root/encap/src
diff options
context:
space:
mode:
authorDaniel Joseph Barnhart Clark <dclark@pobox.com>2007-02-25 21:23:56 +0000
committerDaniel Joseph Barnhart Clark <dclark@pobox.com>2007-02-25 21:23:56 +0000
commit0e8421980ff04baf43bfb13486054f7fea448945 (patch)
treeb64a51b08572815401dbe60ba0fdfb9431fb0b58 /encap/src
parentdad707e42ed01f8968171b6854f2fadd68bdfe97 (diff)
downloadbcfg2-0e8421980ff04baf43bfb13486054f7fea448945.tar.gz
bcfg2-0e8421980ff04baf43bfb13486054f7fea448945.tar.bz2
bcfg2-0e8421980ff04baf43bfb13486054f7fea448945.zip
EncapPackages: Runit now installs/removes/installs/removes cleanly.
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@2878 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'encap/src')
-rw-r--r--encap/src/encap-profiles/bcfg2-0.9.2.ep40
-rw-r--r--encap/src/encap-profiles/runit-1.7.2.ep95
2 files changed, 81 insertions, 54 deletions
diff --git a/encap/src/encap-profiles/bcfg2-0.9.2.ep b/encap/src/encap-profiles/bcfg2-0.9.2.ep
index b32a799a2..6ac3b92df 100644
--- a/encap/src/encap-profiles/bcfg2-0.9.2.ep
+++ b/encap/src/encap-profiles/bcfg2-0.9.2.ep
@@ -70,44 +70,6 @@ url="http://encapsrcdist/mirror/bcfg/bcfg2-0.9.2.tar.gz
ftp://ftp.mcs.anl.gov/pub/bcfg/bcfg2-0.9.2.tar.gz"
>
-<patch options="-p1"><![CDATA[
---- bcfg2-0.9.2/src/lib/Client/XML.py.orig 2006-10-09 23:56:01.000000000 -0400
-+++ bcfg2-0.9.2/src/lib/Client/XML.py 2006-10-10 00:02:42.000000000 -0400
-@@ -1,24 +1,13 @@
- '''XML lib compatibility layer for the Bcfg2 client'''
- __revision__ = '$Revision: 2064 $'
-
--# library will use lxml, then builtin xml.etree, then ElementTree
-+# Changed for EncapPackages - always use ElementTree, or raise an exception
-
- try:
-- from lxml.etree import Element, SubElement, XML, tostring
-- from lxml.etree import XMLSyntaxError as ParseError
-- driver = 'lxml'
-+ from elementtree.ElementTree import Element, SubElement, XML, tostring
-+ from xml.parsers.expat import ExpatError as ParseError
-+ driver = 'etree'
- except ImportError:
-- # lxml not available
-- try:
-- from xml.etree.ElementTree import Element, SubElement, XML, tostring
-- from xml.parsers.expat import ExpatError as ParseError
-- driver = 'etree-py'
-- except ImportError:
-- try:
-- from elementtree.ElementTree import Element, SubElement, XML, tostring
-- from xml.parsers.expat import ExpatError as ParseError
-- driver = 'etree'
-- except ImportError:
-- print "Failed to load lxml, xml.etree and elementtree.ElementTree"
-- print "Cannot continue"
-- raise SystemExit, 1
-+ print "Failed to load elementtree.ElementTree"
-+ print "Cannot continue"
-+ raise SystemExit, 1
-
-]]></patch>
-
<configure type="unset" />
<build>
@@ -172,7 +134,7 @@ test -d etc/sv || mkdir etc/sv
test -d etc/sv/bcfg2-client || mkdir etc/sv/bcfg2-client
test -d etc/sv/bcfg2-client/log || mkdir etc/sv/bcfg2-client/log
test -d etc/sv/bcfg2-server || mkdir etc/sv/bcfg2-server
-test -d etc/sv/bcfg2-server/log || mkdir etc/sv/bcfg2-server/log
+test -d etc/sv/bcfg2-server/log || mkdir etc/sv/bcfg2-server/log
# Make "this encap is installed" sentinal file available in /usr/local/var/encap
test -d var/encap || mkdir var/encap
touch var/encap/${ENCAP_PKGNAME}
diff --git a/encap/src/encap-profiles/runit-1.7.2.ep b/encap/src/encap-profiles/runit-1.7.2.ep
index 7d7e6c245..e8474ee4d 100644
--- a/encap/src/encap-profiles/runit-1.7.2.ep
+++ b/encap/src/encap-profiles/runit-1.7.2.ep
@@ -140,49 +140,117 @@ fi
]]></include_file>
<include_file name="postinstall" mode="0755"><![CDATA[
-#!/bin/sh -e
+#!/bin/sh
umask 002
BASEDIR="`echo ${0} | xargs -n1 dirname`"
LOG=${BASEDIR}/postinstall.log
exec > $LOG 2>&1
+
printf "Running runit postinstall script...\n"
date
+
+case `uname` in
+ AIX|SunOS) PS="ps -ef" ;;
+ *) PS="ps auxw" ;;
+esac
+
+printf "1: Make sure required directories exist...\n"
test -d /usr/local/var || mkdir /usr/local/var
test -d /usr/local/var/svlogd || mkdir /usr/local/var/svlog
test -d /usr/local/var/service || mkdir /usr/local/var/service
test -d /usr/local/etc || mkdir /usr/local/etc
test -d /usr/local/etc/default || mkdir /usr/local/etc/default
test -d /usr/local/etc/sv || mkdir /usr/local/etc/sv
+
+printf "\n2: Currently running runsv and svlogd processes:\n"
+$PS | grep [r]unsv
+$PS | grep [s]vlogd
+
+printf "\n3: Killing any running runsv and svlogd processes...\n"
+$PS | grep [r]unsv | awk '{print $2}' | xargs -n1 -i{} kill -15 -{} 2>/dev/null
+$PS | grep [s]vlogd | awk '{print $2}' | xargs -n1 -i{} kill -15 -{} 2>/dev/null
+sleep 2
+$PS | grep [r]unsv | awk '{print $2}' | xargs -n1 -i{} kill -9 -{} 2>/dev/null
+$PS | grep [s]vlogd | awk '{print $2}' | xargs -n1 -i{} kill -9 -{} 2>/dev/null
+
+printf "\n4: Currently running runsv and svlogd processes:\n"
+$PS | grep [r]unsv
+$PS | grep [s]vlogd
+
+printf "\n5: Removing any stale state information in /usr/local/etc/sv...\n"
for service in `ls /usr/local/etc/sv`; do
test -d /usr/local/etc/sv/$service/supervise && rm -rf /usr/local/etc/sv/$service/supervise
test -d /usr/local/etc/sv/$service/log/supervise && rm -rf /usr/local/etc/sv/$service/log/supervise
done
+
+printf "\n6: Re-enabling services that were installed before package was removed...\n"
if [ -d /usr/local/var/service/.disabled ]; then
for service in `ls /usr/local/var/service/.disabled`; do
if [ -h /usr/local/var/service/$service ]; then
+ printf "A new version of $service exists, removing old version...\n"
rm /usr/local/var/service/.disabled/$service
else
+ printf "Re-enabling service $service...\n"
mv /usr/local/var/service/.disabled/$service /usr/local/var/service/
fi
done
fi
+
+printf "\n7: Making runsvdir run all the time...\n"
if [ -f /etc/inittab ]; then
printf "Installing to /etc/inittab ...\n"
cd ${ENCAP_SOURCE}/${ENCAP_PKGNAME} && ./inittab-install
-fi
+fi
+
if [ -d /etc/event.d ]; then
printf "Installing to /etc/event.d/SV (Upstart) ...\n"
initctl stop SV 2>/dev/null || true
cd ${ENCAP_SOURCE}/${ENCAP_PKGNAME} && cp upstart.boot /etc/event.d/SV
initctl start SV
fi
-printf "Finished runit postinstall script.\n"
+
+printf "\n8: Finished runit postinstall script.\n"
]]></include_file>
<include_file name="preremove" mode="0755"><![CDATA[
#!/bin/sh
printf "Running runit preremove script...\n"
+umask 002
date
+
+case `uname` in
+ AIX|SunOS) PS="ps -ef" ;;
+ *) PS="ps auxw" ;;
+esac
+
+printf "1: All sv processes runnning before any actions...\n"
+$PS | grep [s]v
+
+printf "\n2: Running sv force-shutdown on all /usr/local/var/service services.\n"
+printf "We wait up to an hour for each service to die - if it takes more than a\n"
+printf "minute, your daemon probably doesn't properly support signals, and you\n"
+printf "will probably want to manually kill the service process in another window.\n"
+for service in `ls /usr/local/var/service`; do
+ printf "Trying to force-shutdown /usr/local/var/service/$service ...\n"
+ sv -v -w 3600 force-shutdown /usr/local/var/service/$service
+done
+sleep 2
+printf "All sv processes runnning now...\n"
+$PS | grep [s]v
+
+printf "\n3: Removing all services from /usr/local/var/service/ - runsvdir should now\n"
+printf "shut down any runsv processes...\n"
+test -d /usr/local/var/service/.disabled || mkdir /usr/local/var/service/.disabled
+mv /usr/local/var/service/* /usr/local/var/service/.disabled/ 2>/dev/null || printf "No services to disable.\n"
+printf "Waiting 10 seconds for runsv processes to die...\n"
+sleep 10
+printf "All sv processes runnning now...\n"
+$PS | grep [s]v
+printf "If there are any runsv or svlogd processes still running, you will need\n"
+printf "to kill them manually.\n"
+
+printf "\n4: Now shutting down the runsvdir processes...\n"
+# Stop the "runsvdir" process {
if [ -f /etc/inittab ]; then
printf "Removing from /etc/inittab ...\n"
cd ${ENCAP_SOURCE}/${ENCAP_PKGNAME} && ./inittab-remove
@@ -194,22 +262,19 @@ if [ -d /etc/event.d ]; then
rm /etc/event.d/SV
fi
fi
-printf "Test, remove this code soon:\n"
-ps auxw | grep sv
-test -d /usr/local/var/service/.disabled || mkdir /usr/local/var/service/.disabled
-for service in `ls /usr/local/var/service`; do
- sv exit /usr/local/var/service/$service
-done
-printf "Waiting 7 seconds for runsv processes to die...\n"
-sleep 7
-mv /usr/local/var/service/* /usr/local/var/service/.disabled/ 2>/dev/null || printf "No services to disable.\n"
-printf "Waiting 7 more seconds for runsv processes to die...\n"
-sleep 7
+# } Stop the "runsvdir" process
+sleep 2
+printf "All sv processes runnning now...\n"
+$PS | grep [s]v
+printf "runsvdir should no longer be running.\n"
+
+printf "\n5: Removing any old state from /usr/local/etc/sv directories...\n"
for service in `ls /usr/local/etc/sv`; do
test -d /usr/local/etc/sv/$service/supervise && rm -rf /usr/local/etc/sv/$service/supervise
test -d /usr/local/etc/sv/$service/log/supervise && rm -rf /usr/local/etc/sv/$service/log/supervise
done
-printf "Finished runit preremove script.\n"
+
+printf "\n6: Finished runit preremove script.\n"
]]></include_file>
<encapinfo>