Permalink
Browse files

[fixes] rpm postun script, use pkill if reload fails

  • Loading branch information...
1 parent 694924b commit 4f4c22f480bb42399af8ec25b8c9a74df653678c @portertech portertech committed Mar 19, 2013
Showing with 37 additions and 20 deletions.
  1. +1 −0 Rakefile
  2. +1 −1 pkg_scripts/deb/prerm
  3. +1 −0 pkg_scripts/rpm/post
  4. +32 −0 pkg_scripts/rpm/postun
  5. +2 −19 pkg_scripts/rpm/preun
View
1 Rakefile
@@ -46,6 +46,7 @@ Bunchr::Packages.new do |t|
t.scripts[:before_install] = 'pkg_scripts/rpm/pre'
t.scripts[:after_install] = 'pkg_scripts/rpm/post'
t.scripts[:before_remove] = 'pkg_scripts/rpm/preun'
+ t.scripts[:after_remove] = 'pkg_scripts/rpm/postun'
end
t.include_software('ruby')
View
2 pkg_scripts/deb/prerm
@@ -24,7 +24,7 @@ stop_sensu_services() {
# send sensu-runsvdir a hup to stop itself and supervised services
if [ -f "/etc/init/sensu-runsvdir.conf" ]; then
- reload sensu-runsvdir || true
+ reload sensu-runsvdir || pkill -HUP -f /opt/sensu/embedded/bin/runsvdir || true
fi
if [ -f "/etc/inittab" ]; then
if grep -q sensu-runsvdir /etc/inittab; then
View
1 pkg_scripts/rpm/post
@@ -1,3 +1,4 @@
+# Install package - add services and change permissions
# On first install, register the init scripts but disable services.
# User should choose the services they want to run after install
if [ $1 -eq 1 ]; then
View
32 pkg_scripts/rpm/postun
@@ -0,0 +1,32 @@
+# Uninstall package - delete files and user
+if [ $1 -eq 0 ]; then
+ sensu_services="sensu-client sensu-server sensu-api sensu-dashboard"
+
+ # Delete service scripts
+ for service in $sensu_services; do
+ if [ -f "/etc/init.d/$service" ]; then
+ rm /etc/init.d/$service
+ fi
+ done
+ if [ -f "/etc/init/sensu-runsvdir.conf" ]; then
+ rm /etc/init/sensu-runsvdir.conf
+ fi
+
+ # Delete sensu files
+ if [ -d "/usr/share/sensu" ]; then
+ rm -r /usr/share/sensu
+ fi
+ if [ -d "/opt/sensu" ]; then
+ rm -r /opt/sensu
+ fi
+
+ # Delete sensu user
+ if getent passwd sensu >/dev/null; then
+ userdel -f sensu
+ fi
+
+ # Delete sensu group
+ if getent group sensu >/dev/null; then
+ groupdel -f sensu
+ fi
+fi
View
21 pkg_scripts/rpm/preun
@@ -1,4 +1,4 @@
-# Uninstall package - stop services and remove user
+# Uninstall package - stop services
if [ $1 -eq 0 ]; then
sensu_services="sensu-client sensu-server sensu-api sensu-dashboard"
@@ -8,14 +8,12 @@ if [ $1 -eq 0 ]; then
chkconfig --del $service
if [ -f "/etc/init.d/$service" ]; then
/etc/init.d/$service stop || true
- rm /etc/init.d/$service
fi
done
# send sensu-runsvdir a hup to stop itself and supervised services
if [ -f "/etc/init/sensu-runsvdir.conf" ]; then
- reload sensu-runsvdir || true
- rm /etc/init/sensu-runsvdir.conf
+ reload sensu-runsvdir || pkill -HUP -f /opt/sensu/embedded/bin/runsvdir || true
fi
if [ -f "/etc/inittab" ]; then
if grep -q sensu-runsvdir /etc/inittab; then
@@ -24,19 +22,4 @@ if [ $1 -eq 0 ]; then
pkill -HUP -f /opt/sensu/embedded/bin/runsvdir || true
fi
fi
-
- # Delete sensu user
- if getent passwd sensu >/dev/null; then
- userdel -f sensu
- fi
-
- # Delete sensu group
- if getent group sensu >/dev/null; then
- groupdel -f sensu
- fi
-
- # Remove sensu share files
- if [ -d "/usr/share/sensu" ]; then
- rm -r /usr/share/sensu
- fi
fi

0 comments on commit 4f4c22f

Please sign in to comment.