1
0
Fork 0
arangodb/Installation/debian/postinst.in

106 lines
3.6 KiB
Bash
Executable File

#!/bin/sh
set -e
action="$1"
ARANGODB="/usr/sbin/arangod"
# source debconf library
. /usr/share/debconf/confmodule
set +x
db_get @CPACK_PACKAGE_NAME@/storage_engine
STORAGE_ENGINE=$RET
export GLIBCXX_FORCE_NEW=1
db_get @CPACK_PACKAGE_NAME@/new_install_existing_db_dir
NEW_INSTALL_EXISTING_DIR=$RET
#fill in correct storage engine into arangod.conf
sed -i /etc/arangodb3/arangod.conf -e "s;storage-engine = auto;storage-engine = $STORAGE_ENGINE;"
if test "$action" = "configure" -a \
-z "$2" -a \
"$NEW_INSTALL_EXISTING_DIR" = "false" ; then
db_get @CPACK_PACKAGE_NAME@/password
# Escape backslashes and quotes
if [ -n "$RET" ]; then
ARANGODB_DEFAULT_ROOT_PASSWORD="$(echo "$RET" | sed -e 's;\\\\;\\\\\\\\;g' -e 's;";\\\\";g')" \
/usr/sbin/arango-init-database \
--server.rest-server false \
--server.statistics false --foxx.queues false \
--uid arangodb --gid arangodb || true
fi
db_set @CPACK_PACKAGE_NAME@/password_again ""
db_set @CPACK_PACKAGE_NAME@/password ""
db_go
fi
# check if we should upgrade the database directory
UPGRADE=false #requires upgrade
$ARANGODB --uid arangodb --gid arangodb \
--server.rest-server false --log.foreground-tty false
--database.check-version \
|| UPGRADE=true
db_get @CPACK_PACKAGE_NAME@/upgrade #wants upgrade
if [ "$RET" = "true" ]; then
if [ "$UPGRADE" = "true" ]; then
db_get @CPACK_PACKAGE_NAME@/backup
if [ "$RET" = "true" ]; then
BACKUP="/var/lib/arangodb3-$(date +%F-%H-%M-%S)"
cp -a /var/lib/arangodb3 "$BACKUP"
echo "A backup of your database files has been stored in $BACKUP."
fi
echo "Upgrading database files."
$ARANGODB --uid arangodb --gid arangodb --server.rest-server false --log.level error --database.auto-upgrade true
else
echo "Database files are up-to-date."
fi
elif [ "$UPGRADE" = "true" ]; then
echo "Warning: database files need upgrade, automatic upgrade is disable, please do it manually."
echo "After you've prepared your system for upgrade run "
echo " /usr/share/arangodb3/arangodb-update-db"
echo " dpkg --pending --configure"
echo "after the packaging system is in stable state again."
else
echo "Database files are up-to-date."
fi
db_stop
if test "@CPACK_SYSTEMD_FOUND@" -eq 1 ; then
# This will only remove masks created by d-s-h on package removal.
deb-systemd-helper unmask @CPACK_PACKAGE_NAME@.service >/dev/null || true
# was-enabled defaults to true, so new installations run enable.
if deb-systemd-helper --quiet was-enabled @CPACK_PACKAGE_NAME@.service; then
# Enables the unit on first installation, creates new
# symlinks on upgrades if the unit file has changed.
deb-systemd-helper enable @CPACK_PACKAGE_NAME@.service >/dev/null || true
else
# Update the statefile to add new symlinks (if any), which need to be
# cleaned up on purge. Also remove old symlinks.
deb-systemd-helper update-state @CPACK_PACKAGE_NAME@.service >/dev/null || true
fi
# Automatically added by dh_systemd_start
if [ -d /run/systemd/system ]; then
systemctl --system daemon-reload >/dev/null || true
deb-systemd-invoke start @CPACK_PACKAGE_NAME@.service >/dev/null || true
fi
# End automatically added section
else
# Automatically added by dh_installinit
if [ -x "/etc/init.d/arangodb3" ]; then
update-rc.d arangodb3 defaults >/dev/null
invoke-rc.d arangodb3 start || exit $?
fi
# End automatically added section
fi
exit 0