mirror of https://gitee.com/bigwinds/arangodb
42 lines
1.0 KiB
Bash
Executable File
42 lines
1.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Placeholders starting with @ will be replaced by make
|
|
|
|
ARANGOD="@SBINDIR@/arangod"
|
|
DATABASE="@DATABASE@"
|
|
SCRIPT="@STATICFILES@/js/server/arango-password.js"
|
|
|
|
if [ "$#" -lt 1 ]; then
|
|
echo "usage: $0 [--database <path>] <username> [<password>]"
|
|
exit 1
|
|
fi
|
|
|
|
if [ "$1" == "--database" ] || [ "$1" == "--database.directory" ] ; then
|
|
if [ "$#" -lt 3 ]; then
|
|
echo "usage: $0 [--database <path>] <username> [<password>]"
|
|
exit 1
|
|
fi
|
|
|
|
shift
|
|
DATABASE="$1"
|
|
shift
|
|
fi
|
|
|
|
if test ! -d "$DATABASE"; then
|
|
echo "$0: database directory '$DATABASE' does not exist"
|
|
exit 1
|
|
fi
|
|
|
|
USER="$1"
|
|
|
|
if echo "$USER" | grep -q "[^a-zA-Z0-0_-]"; then
|
|
echo "$0: username '$USER' should only contain letters, numbers, underscore and minus"
|
|
exit 1
|
|
fi
|
|
|
|
if [ "$#" -lt 2 ]; then
|
|
$ARANGOD -c none --database.directory "$DATABASE" --javascript.script "$SCRIPT" --javascript.script-parameter "$USER"
|
|
else
|
|
$ARANGOD -c none --database.directory "$DATABASE" --javascript.script "$SCRIPT" --javascript.script-parameter "$USER" --javascript.script-parameter "$2"
|
|
fi
|