2013-04-17 22:15:10 +02:00
|
|
|
#!/bin/sh
|
2020-05-30 01:12:20 +02:00
|
|
|
set -x
|
|
|
|
set -e
|
2013-04-22 17:06:54 +02:00
|
|
|
|
2021-05-18 05:35:41 +02:00
|
|
|
# This file only exists on the server, ignore its non-existence locally
|
|
|
|
# shellcheck disable=SC1091
|
|
|
|
. "/sys/dev/block/259:0/uevent"
|
2013-04-22 17:06:54 +02:00
|
|
|
|
2021-05-18 05:35:41 +02:00
|
|
|
LOCALDISK="/dev/$DEVNAME"
|
|
|
|
if ! grep -q "$LOCALDISK" /etc/fstab; then
|
2020-10-15 04:55:57 +02:00
|
|
|
echo "$LOCALDISK /srv xfs nofail,noatime 1 1" >>/etc/fstab
|
2020-05-30 01:12:20 +02:00
|
|
|
fi
|
2016-07-19 03:37:50 +02:00
|
|
|
|
2020-05-30 01:12:20 +02:00
|
|
|
if ! mountpoint -q /srv; then
|
2021-05-18 05:35:41 +02:00
|
|
|
mkfs.xfs "$LOCALDISK"
|
2021-05-19 01:37:18 +02:00
|
|
|
# Move any existing files/directories out of the way
|
|
|
|
TMPDIR=$(mktemp -d)
|
|
|
|
mv /srv/* "$TMPDIR"
|
2020-05-30 01:12:20 +02:00
|
|
|
mount /srv
|
2021-05-19 01:37:18 +02:00
|
|
|
mv "$TMPDIR/"* /srv
|
|
|
|
rmdir "$TMPDIR"
|
2020-05-30 01:12:20 +02:00
|
|
|
fi
|
2013-04-17 22:15:10 +02:00
|
|
|
|
2020-05-30 01:12:20 +02:00
|
|
|
if [ ! -L /var/lib/postgresql ]; then
|
|
|
|
service postgresql stop
|
|
|
|
if [ -e /var/lib/postgresql ]; then
|
2020-10-27 23:33:35 +01:00
|
|
|
mv /var/lib/postgresql "/root/postgresql-data-$(date +'%m-%d-%Y-%T')"
|
2020-05-30 01:12:20 +02:00
|
|
|
fi
|
|
|
|
ln -s /srv/postgresql/ /var/lib
|
|
|
|
fi
|
2013-05-08 22:54:25 +02:00
|
|
|
|
2020-05-30 01:12:20 +02:00
|
|
|
if [ ! -e "/srv/postgresql" ]; then
|
|
|
|
service postgresql stop
|
|
|
|
mkdir "/srv/postgresql"
|
|
|
|
chown postgres:postgres /srv/postgresql
|
|
|
|
fi
|