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." }