mirror of https://gitee.com/bigwinds/arangodb
66 lines
1.9 KiB
Bash
Executable File
66 lines
1.9 KiB
Bash
Executable File
#!/bin/sh
|
|
set -e
|
|
|
|
ARANGODB="/usr/sbin/arangod"
|
|
|
|
# source debconf library
|
|
. /usr/share/debconf/confmodule
|
|
|
|
if [ "$1" = "configure" -a -z "$2" ]; 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 \
|
|
--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
|
|
$ARANGODB --uid arangodb --gid arangodb --server.rest-server false --log.foreground-tty false --database.check-version \
|
|
|| UPGRADE=true
|
|
|
|
db_get @CPACK_PACKAGE_NAME@/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 " /etc/init.d/arangodb3 upgrade"
|
|
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
|
|
|
|
# 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
|
|
|
|
|
|
exit 0
|