summaryrefslogtreecommitdiff
path: root/community/rethinkdb/rethinkdb.install
blob: 44777995319d51dd2bceebd74711ac758fe0acf9 (plain)
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
post_install() {
  groupadd rethinkdb &>/dev/null
  useradd -g rethinkdb -d /var/lib/rethinkdb -s /bin/false rethinkdb &>/dev/null

  if type -P systemd-tmpfiles &> /dev/null; then
    systemd-tmpfiles --create rethinkdb.conf
  fi

  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"

  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() {
  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."
}