1
0
Fork 0
arangodb/utils/arango-upgrade.in

93 lines
1.7 KiB
Bash

#!/bin/bash
# Placeholders starting with @ will be replaced by make
ARANGOD="@SBINDIR@/arangod"
DATABASE="@DATABASEDIR@"
MODULESPATH="@PKGDATADIR@/js/server/modules;@PKGDATADIR@/js/common/modules"
SCRIPT="@PKGDATADIR@/js/server/arango-upgrade.js"
UIDOPTION=""
UIDUSER=""
WHOAMI=$(whoami)
function print_help {
echo ""
echo "usage:"
echo " $0 --database.directory <path to directory> [options]"
echo ""
echo "options:"
echo " --uid <user> change user to <user> for upgrading"
echo " --help this message"
echo ""
echo "options for developers:"
echo " --relative use arangod and javascript in current directory"
echo ""
exit 1
}
function checkOptions {
case "$1" in
--help)
print_help
;;
*)
echo "unknown option: $1"
print_help
;;
esac
}
while [ "$#" -gt 1 ]; do
case "$1" in
--database|--database.directory)
DATABASE="$2"
shift
;;
--uid)
UIDOPTION="--uid"
UIDUSER="$2"
shift
;;
--relative)
ARANGOD="./bin/arangod"
MODULESPATH="./js/server/modules;./js/common/modules"
SCRIPT="./js/server/arango-upgrade.js"
;;
*)
checkOptions $1
;;
esac
shift
done
if [ "$#" -gt 0 ]; then
checkOptions $1
fi
if test ! -d "$DATABASE"; then
echo "$0: database directory '$DATABASE' does not exist"
print_help
exit 1
fi
$ARANGOD \
-c none \
--database.directory "$DATABASE" \
--javascript.script "$SCRIPT" \
--javascript.modules-path "$MODULESPATH" \
$UIDOPTION $UIDUSER
if [ "$WHOAMI" == "abrandt" ] && [ "$UIDUSER" == "" ] ; then
echo "Warning:"
echo " $0 started without '--uid <user>' option."
echo " Change owner of database files if needed!"
exit 1
fi