forked from freenas/iocage-plugin-asigra
-
Notifications
You must be signed in to change notification settings - Fork 2
/
pre_update.sh
executable file
·29 lines (23 loc) · 797 Bytes
/
pre_update.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
#!/bin/sh
pgsql_id="$(id -u pgsql)"
if [ "${pgsql_id}" != "769" ]; then
echo "Changing uid/gid of user/group pgsql"
pw groupmod -n pgsql -g 769
pw usermod -n pgsql -u 769 -g pgsql
find -x /usr/local/pgsql -uid "${pgsql_id}" -exec chown -R pgsql:pgsql {} +
fi
echo "Starting postgresql service"
service postgresql start
echo "Generating dump of postgresql"
rm -f /tmp/update_dump
pg_dump -U pgsql -d dssystem > /tmp/update_dump
if [ $? != 0 ]; then
echo "Failed to take dump of existing database. Aborting update."
exit 1
fi
echo "Stopping postgresql"
service postgresql stop
echo "Removing postgresql data directory"
# We do this as newer version of postgresql probably won't support the directory
# initialised by an older version of postgresql
rm -rf /usr/local/pgsql/data/* || true