summaryrefslogtreecommitdiff
path: root/community/rethinkdb/rethinkdb.install
diff options
context:
space:
mode:
authorNicolás Reynolds <fauno@endefensadelsl.org>2014-02-22 03:50:02 +0000
committerNicolás Reynolds <fauno@endefensadelsl.org>2014-02-22 03:50:02 +0000
commitd681aef185938981d5b5eb582d09fbc49927cf24 (patch)
treeadbebafcefcedb7b35b765eb8bc451eac8482d32 /community/rethinkdb/rethinkdb.install
parent96cf9235f114b8d960c16a8625937b16979ae1aa (diff)
Sat Feb 22 03:44:10 UTC 2014
Diffstat (limited to 'community/rethinkdb/rethinkdb.install')
-rw-r--r--community/rethinkdb/rethinkdb.install47
1 files changed, 47 insertions, 0 deletions
diff --git a/community/rethinkdb/rethinkdb.install b/community/rethinkdb/rethinkdb.install
new file mode 100644
index 000000000..8c74c4f0b
--- /dev/null
+++ b/community/rethinkdb/rethinkdb.install
@@ -0,0 +1,47 @@
+post_install() {
+ groupadd rethinkdb &>/dev/null
+ useradd -g rethinkdb -d /var/lib/rethinkdb -s /bin/false rethinkdb &>/dev/null
+
+ /usr/bin/systemd-tmpfiles --create rethinkdb.conf
+
+ if [ -d /var/lib/rethinkdb ]; then
+ echo "Database directory '/var/lib/rethinkdb' already exists. If you want to recreate default database then delete the directory and run 'rethinkdb create -d /var/lib/rethinkdb/default'."
+ fi
+
+ if [ ! -d /var/lib/rethinkdb/default ]; then
+ mkdir -p /var/lib/rethinkdb
+ /usr/bin/rethinkdb create -d /var/lib/rethinkdb/default
+ fi
+ chown -R rethinkdb:rethinkdb /var/lib/rethinkdb
+}
+
+post_upgrade() {
+ IFS='.' read -a new_version <<< "$1"
+ IFS='.' read -a old_version <<< "$2"
+
+ # previously data diecotry was /var/lib/rethinkdb/
+ # now we moved to multi-instance location: /var/lib/rethinkdb/default
+ # convert from previous location, remove this check Q3'13
+ if [ -e /var/lib/rethinkdb/metadata -a ! -d /var/lib/rethinkdb/default ]; then
+ echo "You store rethinkdb data in /var/lib/rethinkdb. Moving this data to per-instance location /var/lib/rethinkdb/default."
+ mkdir /var/lib/rethinkdb/default
+ mv /var/lib/rethinkdb/* /var/lib/rethinkdb/default
+ chown -R rethinkdb:rethinkdb /var/lib/rethinkdb
+ fi
+
+ if [ "${old_version[0]}" != "${new_version[0]}" -o "${old_version[1]}" != "${new_version[1]}" ]; then
+ echo "This release changed data storage format. Please upgrade your data using following information https://github.com/rethinkdb/rethinkdb/tree/next/scripts/migration"
+ fi
+
+ getent group rethinkdb >/dev/null 2>&1 || groupadd rethinkdb &>/dev/null
+ getent passwd rethinkdb >/dev/null 2>&1 || useradd -g rethinkdb -d /var/lib/rethinkdb -s /bin/false rethinkdb &>/dev/null
+}
+
+post_remove() {
+ #/usr/bin/systemctl stop rethinkdb@default.service
+
+ getent passwd rethinkdb >/dev/null && userdel rethinkdb
+ getent group rethinkdb >/dev/null && groupdel rethinkdb
+
+ echo "RethinkDB data directory '/var/lib/rethinkdb' is left untouched. Remove it if you really sure you won't need your data in the future."
+}