]> piware.de Git - bin.git/commitdiff
cleanpg: fixups for usage in root chroots
authormartin@piware.de <>
Tue, 22 Jul 2008 14:18:28 +0000 (16:18 +0200)
committermartin@piware.de <>
Tue, 22 Jul 2008 14:18:28 +0000 (16:18 +0200)
cleanpg

diff --git a/cleanpg b/cleanpg
index 49392370d52ea696a0d11bff791afd90d9836d14..475bce92ecb9bb385a206886127ee1620ad9f5ab 100755 (executable)
--- a/cleanpg
+++ b/cleanpg
@@ -1,8 +1,8 @@
 #!/bin/sh
-sudo /etc/init.d/postgresql-7.4 stop
-sudo /etc/init.d/postgresql-8.0 stop
-sudo /etc/init.d/postgresql-8.1 stop
-sudo /etc/init.d/postgresql-8.2 stop
-sudo /etc/init.d/postgresql-8.3 stop
-sudo killall pg_autovacuum postmaster postgres
-sudo rm -rf /etc/postgresql /var/lib/postgresql/ /var/log/postgresql/ /tmp/postgresql-testsuite/ /var/run/postgresql/*
+[ `id -u` = 0 ] || SUDO=sudo
+for v in 7.4 8.0 8.1 8.2 8.3; do
+    i=/etc/init.d/postgresql-$v
+    [ -x $i ] && $i stop
+done
+$SUDO killall pg_autovacuum postmaster postgres
+$SUDO rm -rf /etc/postgresql /var/lib/postgresql/ /var/log/postgresql/ /tmp/postgresql-testsuite/ /var/run/postgresql/*