forked from MasaoFujii/my-bin
/
pgrm.sh
executable file
·48 lines (40 loc) · 842 Bytes
/
pgrm.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/sh
. pgcommon.sh
usage ()
{
echo "$PROGNAME removes the deletable PostgreSQL directories."
echo ""
echo "Usage:"
echo " $PROGNAME"
echo ""
echo "Description:"
echo " All obsolete database cluster, archive and backup directories"
echo " are removed from current directory."
}
while [ $# -gt 0 ]; do
case "$1" in
"-?"|--help)
usage
exit 0;;
*)
elog "invalid option: $1";;
esac
shift
done
here_is_installation
for pgdata in $(find_all_pgdata); do
update_pgdata "$pgdata"
$PGBIN/pg_ctl -D $PGDATA status > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo "could not delete \"$PGDATA\": PostgreSQL is still running"
continue
fi
TARGETS="$PGDATA $PGDATABKP $PGARCH $PGARCHBKP"
for target in $TARGETS; do
if [ ! -d $target ]; then
continue
fi
echo "rm -rf $target"
rm -rf "$target"
done
done