mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'devel' of github.com:triAGENS/ArangoDB into devel
Conflicts: Installation/epm/arangodb.list
This commit is contained in:
commit
7fdb024fef
|
@ -1,6 +1,14 @@
|
|||
v1.2.alpha (XXXX-XX-XX)
|
||||
-----------------------
|
||||
|
||||
* removed arango-password script and added Javascript functionality to add/delete
|
||||
users instead. The functionality is contained in module `users` and can be invoked
|
||||
as follows from arangosh and arangod:
|
||||
* require("users").saveUser("name", "passwd");
|
||||
* require("users").replaceUser("name", "newPasswd");
|
||||
* require("users").removeUser("name");
|
||||
These functions are intentionally not offered via the web interface.
|
||||
|
||||
* changed print output in arangosh and the web interface for JSON objects.
|
||||
Previously, printing a JSON object in arangosh resulted in the attribute values
|
||||
being printed as proper JSON, but attribute names were printed unquoted and
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
arangosh> require("users").removeUser("my-user");
|
|
@ -0,0 +1 @@
|
|||
arangosh> require("users").replaceUser("my-user", "my-changed-password");
|
|
@ -0,0 +1 @@
|
|||
arangosh> require("users").saveUser("my-user", "my-secret-password");
|
|
@ -24,6 +24,7 @@ DOXYGEN = \
|
|||
Doxygen/js/common/modules/jsunity.c \
|
||||
Doxygen/js/common/modules/simple-query-basics.c \
|
||||
Doxygen/js/common/modules/statement-basics.c \
|
||||
Doxygen/js/common/modules/users.c \
|
||||
Doxygen/js/server/modules/org/arangodb/actions.c \
|
||||
Doxygen/js/server/modules/simple-query.c \
|
||||
Doxygen/js/server/server.c
|
||||
|
@ -91,6 +92,7 @@ WIKI = \
|
|||
ShellIndex \
|
||||
SimpleQueries \
|
||||
Upgrading \
|
||||
UserManagement \
|
||||
UserManual \
|
||||
UserManualArangosh \
|
||||
UserManualWebInterface \
|
||||
|
@ -233,9 +235,7 @@ dist_man_MANS += \
|
|||
Documentation/man/man1/arangosh.1 \
|
||||
Documentation/man/man8/rcarangod.8 \
|
||||
Documentation/man/man8/arangod.8 \
|
||||
Documentation/man/man8/arango-dfdb.8 \
|
||||
Documentation/man/man8/arango-password.8 \
|
||||
Documentation/man/man8/arango-upgrade.8
|
||||
Documentation/man/man8/arango-dfdb.8
|
||||
|
||||
|
||||
if ENABLE_ARANGOB
|
||||
|
|
|
@ -31,57 +31,42 @@ check at startup.
|
|||
|
||||
It will look for a file named _VERSION_ in its database directory. If
|
||||
the file is not present (it will not be present in an ArangoDB 1.0
|
||||
database), _arangod_ in version 1.1 will refuse to start and ask the
|
||||
user to run the script _arango-upgrade_ first.
|
||||
database), _arangod_ in version 1.1 will perform an auto-upgrade.
|
||||
This auto-upgrade will create the system collections necessary to run
|
||||
ArangoDB 1.1, and it will also create the VERSION file.
|
||||
|
||||
If the _VERSION_ file is present but is from a non-matching version of
|
||||
ArangoDB, _arangod_ will also refuse to start and ask the user to run
|
||||
the upgrade script first. This procedure shall ensure that users have
|
||||
full control over when they perform any updates/upgrades of their
|
||||
data, and do not risk running an incompatible tandem of server and
|
||||
database.
|
||||
ArangoDB, _arangod_ will also refuse to start and ask the user to start
|
||||
the server with the option `--upgrade`.
|
||||
|
||||
ArangoDB users are asked to run _arango-upgrade_ when upgrading from
|
||||
one version of ArangoDB to a higher version (e.g. from 1.0 to 1.1 in
|
||||
this case), but also after pulling the latest ArangoDB source code
|
||||
while staying in the same minor version (e.g. when updating from
|
||||
This procedure shall ensure that users in the future will have full
|
||||
control over when they perform any updates/upgrades of their data, and
|
||||
do not risk running an incompatible tandem of server and database.
|
||||
|
||||
ArangoDB users are asked to start the server with the `--upgrade` option
|
||||
when upgrading from one version of ArangoDB to a higher version (e.g.
|
||||
from 1.0 to 1.1 in this case), but also after pulling the latest ArangoDB
|
||||
source code while staying in the same minor version (e.g. when updating from
|
||||
1.1-beta1 to 1.1-beta2).
|
||||
|
||||
When installing ArangoDB from scratch, users should also run
|
||||
_arango-upgrade_ once to initialise their database directory with some
|
||||
system collections that ArangoDB requires. When not run, _arangod_
|
||||
will refuse to start as mentioned before.
|
||||
The upgrade procedure is started when the server is started with the
|
||||
additional command line option `--upgrade` as follows:
|
||||
|
||||
_arango-upgrade_ can be invoked from the command-line, and takes the
|
||||
database directory as its only argument:
|
||||
|
||||
> bin/arango-upgrade --database.directory /tmp/voctest
|
||||
> bin/arangod --server.endpoint tcp://127.0.0.1:8529 --database.directory /tmp/voctest --upgrade
|
||||
|
||||
...
|
||||
2012-11-21T18:00:38Z [2411] INFO Upgrade script ./js/server/arango-upgrade.js started
|
||||
2012-11-21T18:00:38Z [2411] INFO Server version: 1.1.beta2, database directory version: (not set)
|
||||
2012-11-21T18:00:38Z [2411] INFO Found 9 defined task(s), 9 task(s) to run
|
||||
2012-11-21T18:00:38Z [2411] INFO Executing task #1 (setupUsers): setup _users collection
|
||||
2012-11-21T18:00:38Z [2411] INFO Task successful
|
||||
2012-12-03T11:22:08Z [11573] INFO Starting upgrade from version 1.0 to 1.1.beta2
|
||||
2012-12-03T11:22:08Z [11573] INFO Found 9 defined task(s), 9 task(s) to run
|
||||
...
|
||||
2012-11-21T18:00:40Z [2411] INFO Upgrade script successfully finished
|
||||
2012-11-21T18:00:42Z [2411] INFO ArangoDB has been shut down
|
||||
2012-12-03T11:22:08Z [11573] INFO Upgrade successfully finished
|
||||
|
||||
The _arango-upgrade_ will execute the defined tasks to run _arangod_
|
||||
The upgrade procecure will execute the defined tasks to run _arangod_
|
||||
with all new features and data formats. It should normally run without
|
||||
problems and indicate success at script end. If it detects a problem
|
||||
that it cannot fix, it will halt on the first error and warn the user.
|
||||
|
||||
Re-executing _arango-upgrade_ will execute only the previously failed
|
||||
and not yet executed tasks.
|
||||
|
||||
_arango-upgrade_ needs exclusive access to the database, so it cannot
|
||||
be executed while an instance of _arangod_ is currently running.
|
||||
|
||||
If ArangoDB normaly runs with a lower privileged UID than _arango-upgrade_
|
||||
requires the option `--uid username` to upgrade the database:
|
||||
|
||||
> bin/arango-upgrade --database.directory /tmp/voctest --uid arangodb
|
||||
Re-starting arangod with the `--upgrade` option will execute only the
|
||||
previously failed and not yet executed tasks.
|
||||
|
||||
Server startup options changes
|
||||
------------------------------
|
||||
|
@ -132,8 +117,8 @@ Clients sending requests without HTTP autorization headers or with
|
|||
invalid usernames/passwords will be rejected by arangod with an HTTP
|
||||
401 error.
|
||||
|
||||
_arango-upgrade_ will create a default user _root_ with an empty
|
||||
password when run initially.
|
||||
The upgrade procedure for ArangoDB 1.1 will create a default user _root_
|
||||
with an empty password when run initially.
|
||||
|
||||
To turn authorization off, the server can be started with the
|
||||
following command line option:
|
||||
|
@ -218,8 +203,8 @@ Collections in 1.1 are now either _document_-only or _edge_
|
|||
collections, but the two concepts cannot be mixed in the same
|
||||
collection.
|
||||
|
||||
_arango-upgrade_ will determine the types of existing collections from
|
||||
1.0 once on upgrade, based on the inspection of the first 50 documents
|
||||
The upgrade procedure for ArangoDB 1.1 will determine the types of existing
|
||||
collections from 1.0 once, based on the inspection of the first 50 documents
|
||||
in the collection.
|
||||
|
||||
If one of the documents contains either a `_from` or a `_to`
|
||||
|
|
|
@ -50,7 +50,7 @@ r2 = re.compile(r'^\s*function\s*([a-zA-Z0-9_]*)\s*\((.*)\)\s*{')
|
|||
r3 = re.compile(r'^\s*$')
|
||||
r4 = re.compile(r'^\s*([a-zA-Z0-9\._]*)\s*=\s*function\s*\((.*)\)\s*{')
|
||||
r5 = re.compile(r'^\s*actions\.defineHttp\(')
|
||||
r6 = re.compile(r'^/// @fn ([a-zA-Z0-_]*)\s*')
|
||||
r6 = re.compile(r'^/// @fn ([a-zA-Z0-9_]*)\s*')
|
||||
|
||||
f = open(file_name, "r")
|
||||
|
||||
|
|
|
@ -61,8 +61,7 @@ For Linux:
|
|||
- visit the official ArangoDB download page at
|
||||
@EXTREF{http://www.arangodb.org/download,http://www.arangodb.org/download}
|
||||
and download the correct package for you Linux distribution
|
||||
- install the package using you favorite package manager
|
||||
- initialise (or upgrade) the database `/usr/local/bin/arango-upgrade`
|
||||
- install the package using your favorite package manager
|
||||
- start up the database server, normally this is done by
|
||||
executing `/etc/init.d/arangod start`. The exact command
|
||||
depends on your Linux distribution
|
||||
|
@ -70,7 +69,6 @@ For Linux:
|
|||
For MacOS X:
|
||||
|
||||
- execute `brew install arangodb`
|
||||
- initialise (or upgrade) the database `/usr/local/bin/arango-upgrade`
|
||||
- and start the server using `/usr/local/sbin/arangod &`
|
||||
|
||||
After these steps there should be a running instance of _arangod_ -
|
||||
|
@ -82,14 +80,11 @@ the ArangoDB database server.
|
|||
If there is no such process, check the log file
|
||||
`/var/log/arangodb/arangod.log` for errors. If you see a log message
|
||||
like
|
||||
2012-12-03T11:35:29Z [12882] ERROR Database directory version (1) is lower than server version (1.2).
|
||||
2012-12-03T11:35:29Z [12882] ERROR It seems like you have upgraded the ArangoDB binary. If this is what you wanted to do, please restart with the --upgrade option to upgrade the data in the database directory.
|
||||
2012-12-03T11:35:29Z [12882] FATAL Database version check failed. Please start the server with the --upgrade option
|
||||
|
||||
2012-11-20T00:36:55Z [17253] ERROR No version information file found in database directory.
|
||||
2012-11-20T00:36:55Z [17253] FATAL Database version check failed. Please run arango-upgrade --database.directory "/tmp/my-database-path"
|
||||
|
||||
make sure that the program `arango-upgrade` has been used to initialse
|
||||
(or update) the database stored at `/tmp/my-database-path`. If not run
|
||||
|
||||
arango-upgrade --database.directory /tmp/my-database-path
|
||||
make sure to start the server once with the `--upgrade` option.
|
||||
|
||||
|
||||
ArangoDB programs {#FirstStepsArangoDBBinaries}
|
||||
|
@ -101,7 +96,6 @@ The ArangoDB database package comes with the following programs:
|
|||
intended to run as daemon process and to server the various clients
|
||||
connection to the server via TCP / HTTP. See @ref
|
||||
FirstStepsServerStartStop.
|
||||
- _arango-update_: Used to initialize or update the database.
|
||||
- _arangosh_: The ArangoDB shell. A client that implements a
|
||||
read-eval-print loop (REPL) and provides functions to access and
|
||||
administrate the ArangoDB server. See @ref FirstStepsShellStartStop.
|
||||
|
@ -118,7 +112,6 @@ The ArangoDB database package comes with the following programs:
|
|||
intended to run as daemon process and to server the various clients
|
||||
connection to the server via TCP / HTTP. See @ref
|
||||
FirstStepsServerStartStop.
|
||||
- _arango-update_: Used to initialize or update the database.
|
||||
- _arangosh_: The ArangoDB shell. A client that implements a
|
||||
read-eval-print loop (REPL) and provides functions to access and
|
||||
administrate the ArangoDB server. See @ref FirstStepsShellStartStop.
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
.TH arango-password 8 "So 30. Sep 01:36:14 CEST 2012" "" "ArangoDB"
|
||||
.SH NAME
|
||||
arango-password - user setup utility for the ArangoDB database server
|
||||
.SH SYNOPSIS
|
||||
arango-password database-directory username [password]
|
||||
.SH DESCRIPTION
|
||||
The arango-password utility can be used to create additional users in an
|
||||
ArangoDB database server.
|
||||
The utility must be run with exclusive access to the server's data directory,
|
||||
meaning the ArangoDB server must not be running and accessing the
|
||||
datafiles in the specified data directory.
|
||||
.SH OPTIONS
|
||||
The options of the arango-password utility are:
|
||||
.IP "--database.directory <string>"
|
||||
path to the database directory
|
||||
.IP "username"
|
||||
name of the user to add
|
||||
.IP "password"
|
||||
password for the user. Leave empty for a password prompt
|
||||
.SH EXAMPLES
|
||||
.EX
|
||||
shell> arango-password --database.directory /data/arangodb fuchsia
|
||||
creates a new user "fuchsia". Password prompt will follow
|
||||
.EE
|
||||
|
||||
.EX
|
||||
shell> arango-password --database.directory /data/arangodb fuchsia "1234@ab"
|
||||
creates a new user "fuchsia" with the specified password
|
||||
.EE
|
||||
|
||||
|
||||
.SH AUTHOR
|
||||
Copyright 2012, triAGENS GmbH, Cologne, Germany
|
|
@ -1,30 +0,0 @@
|
|||
.TH arango-upgrade 8 "So 30. Sep 01:36:14 CEST 2012" "" "ArangoDB"
|
||||
.SH NAME
|
||||
arango-upgrade - upgrade script for the ArangoDB database server
|
||||
.SH SYNOPSIS
|
||||
arango-upgrade --database.directory database-directory
|
||||
.SH DESCRIPTION
|
||||
The arango-upgrade command can be used to perform any necessary system
|
||||
data modification in an ArangoDB database after a version upgrade.
|
||||
The command must be run with exclusive access to the server's data directory,
|
||||
that means the ArangoDB server must not be running and accessing the
|
||||
datafiles in the specified data directory.
|
||||
|
||||
The arango-upgrade command will print a list of tasks it executes and a
|
||||
success/failure status for each. If some task cannot be accomplished
|
||||
successfully, the root cause must be fixed and the arango-upgrade command be
|
||||
run again afterwards.
|
||||
.SH OPTIONS
|
||||
The arango-upgrade binary the following option:
|
||||
|
||||
.IP "--database.directory <string>"
|
||||
path to the database directory
|
||||
.SH EXAMPLES
|
||||
.EX
|
||||
shell> arango-upgrade --database.directory /data/arangodb
|
||||
starts the upgrade script with database directory /data/arangodb
|
||||
.EE
|
||||
|
||||
|
||||
.SH AUTHOR
|
||||
Copyright 2012, triAGENS GmbH, Cologne, Germany
|
|
@ -1,25 +0,0 @@
|
|||
COMMAND SECTION "DATE" "" "ArangoDB"
|
||||
NAME
|
||||
COMMAND - upgrade script for the ArangoDB database server
|
||||
SYNOPSIS
|
||||
COMMAND --database.directory database-directory
|
||||
DESCRIPTION
|
||||
The COMMAND command can be used to perform any necessary system
|
||||
data modification in an ArangoDB database after a version upgrade.
|
||||
The command must be run with exclusive access to the server's data directory,
|
||||
that means the ArangoDB server must not be running and accessing the
|
||||
datafiles in the specified data directory.
|
||||
|
||||
The COMMAND command will print a list of tasks it executes and a
|
||||
success/failure status for each. If some task cannot be accomplished
|
||||
successfully, the root cause must be fixed and the COMMAND command be
|
||||
run again afterwards.
|
||||
OPTIONS
|
||||
The COMMAND binary the following option:
|
||||
|
||||
OPTION "--database.directory <string>"
|
||||
path to the database directory ENDOPTION
|
||||
EXAMPLES
|
||||
EXAMPLE COMMAND --database.directory /data/arangodb
|
||||
starts the upgrade script with database directory /data/arangodb ENDEXAMPLE
|
||||
AUTHOR
|
|
@ -33,8 +33,6 @@ l 000 ${rusr} ${rgrp} ${sbindir}/arangod ${sbindir}/arangod-${arangodb_version}
|
|||
|
||||
f 0755 ${susr} ${sgrp} ${bindir}/arangoimp ${project_dir}/bin/arangoimp
|
||||
f 0755 ${susr} ${sgrp} ${bindir}/arangosh ${project_dir}/bin/arangosh
|
||||
f 0755 ${susr} ${sgrp} ${bindir}/arango-password ${project_dir}/bin/arango-password
|
||||
f 0755 ${susr} ${sgrp} ${bindir}/arango-upgrade ${project_dir}/bin/arango-upgrade
|
||||
|
||||
# database directory
|
||||
d 0755 ${rusr} ${rgrp} ${data_dir} -
|
||||
|
@ -78,10 +76,6 @@ launchctl unload /Library/LaunchDaemons/org.arangodb.plist
|
|||
/usr/sbin/chown -R ${susr}:${sgrp} /var/log/arangodb
|
||||
/usr/sbin/chown -R ${susr}:${sgrp} ${data_dir}/arangodb
|
||||
|
||||
if [ "`/usr/bin/find ${data_dir}/arangodb -type d -name 'collection-*'`" == "" ] ; then
|
||||
${bindir}/arango-upgrade --database.directory "${data_dir}/arangodb"
|
||||
fi
|
||||
|
||||
launchctl load /Library/LaunchDaemons/org.arangodb.plist
|
||||
|
||||
EOF
|
||||
|
@ -117,10 +111,6 @@ chown -R ${susr}:${sgrp} /var/run/arangodb
|
|||
chown -R ${susr}:${sgrp} /var/log/arangodb
|
||||
chown -R ${susr}:${sgrp} ${data_dir}/arangodb
|
||||
|
||||
if [ "`find ${data_dir}/arangodb -type d -name 'collection-*'`" == "" ] ; then
|
||||
${bindir}/arango-upgrade --database.directory "${data_dir}/arangodb" --uid ${susr}
|
||||
fi
|
||||
|
||||
echo "${install_message}"
|
||||
|
||||
exit 0
|
||||
|
@ -147,10 +137,6 @@ chown -R ${susr}:${sgrp} /var/run/arangodb
|
|||
chown -R ${susr}:${sgrp} /var/log/arangodb
|
||||
chown -R ${susr}:${sgrp} ${data_dir}/arangodb
|
||||
|
||||
if [ "`find ${data_dir}/arangodb -type d -name 'collection-*'`" == "" ] ; then
|
||||
${bindir}/arango-upgrade --database.directory "${data_dir}/arangodb" --uid ${susr}
|
||||
fi
|
||||
|
||||
echo "${install_message}"
|
||||
|
||||
exit 0
|
||||
|
@ -178,10 +164,6 @@ chown -R ${susr}:${sgrp} /var/run/arangodb
|
|||
chown -R ${susr}:${sgrp} /var/log/arangodb
|
||||
chown -R ${susr}:${sgrp} ${data_dir}/arangodb
|
||||
|
||||
if [ "`find ${data_dir}/arangodb -type d -name 'collection-*'`" == "" ] ; then
|
||||
${bindir}/arango-upgrade --database.directory "${data_dir}/arangodb" --uid ${susr}
|
||||
fi
|
||||
|
||||
echo "${install_message}"
|
||||
|
||||
exit 0
|
||||
|
@ -227,12 +209,6 @@ chown -R ${susr}:${sgrp} /var/run/arangodb
|
|||
chown -R ${susr}:${sgrp} /var/log/arangodb
|
||||
chown -R ${susr}:${sgrp} ${data_dir}/arangodb
|
||||
|
||||
if [ ! "`find ${data_dir}/arangodb -type d -name 'collection-*'`" ] ; then
|
||||
/etc/init.d/arangodb stop
|
||||
${bindir}/arango-upgrade --database.directory "${data_dir}/arangodb" --uid ${susr}
|
||||
/etc/init.d/arangodb start
|
||||
fi
|
||||
|
||||
echo "${install_message}"
|
||||
|
||||
exit 0
|
||||
|
|
|
@ -111,7 +111,6 @@ start-server:
|
|||
|
||||
@test -d "$(VOCDIR)"
|
||||
|
||||
@builddir@/bin/arango-upgrade --relative --database.directory "$(VOCDIR)"
|
||||
($(VALGRIND) @builddir@/bin/arangod "$(VOCDIR)" $(SERVER_OPT) --pid-file $(PIDFILE) --watch-process $(PID) && rm -rf "$(VOCDIR)") &
|
||||
|
||||
@test "$(PROTO)" == "unix" || (rm -f "$(STARTFILE)"; while [ ! -s "$(STARTFILE)" ]; do $(CURL) $(CURL_OPT) --insecure -X GET -s "$(PROTO)://$(VOCHOST):$(VOCPORT)/_api/version" > "$(STARTFILE)" || sleep 2; done)
|
||||
|
@ -234,7 +233,6 @@ unittests-shell-server:
|
|||
@rm -rf "$(VOCDIR)"
|
||||
@mkdir "$(VOCDIR)"
|
||||
|
||||
@builddir@/bin/arango-upgrade --relative --database.directory "$(VOCDIR)"
|
||||
$(VALGRIND) @builddir@/bin/arangod "$(VOCDIR)" $(SERVER_OPT) $(UNITTESTS_SERVER) || test "x$(FORCE)" == "x1"
|
||||
|
||||
@rm -rf "$(VOCDIR)"
|
||||
|
@ -304,7 +302,6 @@ unittests-shell-server-ahuacatl:
|
|||
@rm -rf "$(VOCDIR)"
|
||||
@mkdir "$(VOCDIR)"
|
||||
|
||||
@test "x$(SKIP_AHUACATL)" == "x1" || @builddir@/bin/arango-upgrade --relative --database.directory "$(VOCDIR)"
|
||||
@test "x$(SKIP_AHUACATL)" == "x1" || $(VALGRIND) @builddir@/bin/arangod "$(VOCDIR)" $(SERVER_OPT) $(UNITTESTS_SERVER_AHUACATL) || test "x$(FORCE)" == "x1"
|
||||
@test "x$(SKIP_AHUACATL)" == "x1" || test "x$(SKIP_RANGES)" == "x1" || $(VALGRIND) @builddir@/bin/arangod "$(VOCDIR)" $(SERVER_OPT) $(UNITTESTS_SERVER_AHUACATL_EXTENDED) || test "x$(FORCE)" == "x1"
|
||||
|
||||
|
@ -441,7 +438,6 @@ unittests-bitarray-index:
|
|||
@rm -rf "$(VOCDIR)"
|
||||
@mkdir "$(VOCDIR)"
|
||||
|
||||
@builddir@/bin/arango-upgrade --relative --database.directory "$(VOCDIR)"
|
||||
$(VALGRIND) @builddir@/bin/arangod "$(VOCDIR)" $(SERVER_OPT) $(UNITTESTS_SERVER_BITARRAY) || test "x$(FORCE)" == "x1"
|
||||
|
||||
@ rm -rf "$(VOCDIR)"
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief user management
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2012 triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Jan Steemann
|
||||
/// @author Copyright 2012, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- USER MANAGEMENT
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @page UserManagementTOC
|
||||
///
|
||||
/// <ul>
|
||||
/// <li>@ref UserManagementSave "users.save"</li>
|
||||
/// <li>@ref UserManagementReplace "users.replace"</li>
|
||||
/// <li>@ref UserManagementRemove "users.remove"</li>
|
||||
/// </ul>
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @page UserManagement User Management
|
||||
///
|
||||
/// @EMBEDTOC{ UserManagementTOC}
|
||||
///
|
||||
/// ArangoDB provides basic functionality to add, modify and remove database
|
||||
/// users programmatically. The following functionality is provided by the
|
||||
/// @LIT{users} module and can be used from inside arangosh and arangod.
|
||||
///
|
||||
/// @CLEARPAGE
|
||||
/// @anchor UserManagementSave
|
||||
/// @copydetails JSF_saveUser
|
||||
///
|
||||
/// @CLEARPAGE
|
||||
/// @anchor UserManagementReplace
|
||||
/// @copydetails JSF_replaceUser
|
||||
///
|
||||
/// @CLEARPAGE
|
||||
/// @anchor UserManagementRemove
|
||||
/// @copydetails JSF_removeUser
|
||||
////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- END-OF-FILE
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// Local Variables:
|
||||
// mode: outline-minor
|
||||
// outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|// --SECTION--\\|/// @page\\|/// @\\}\\)"
|
||||
// End:
|
|
@ -0,0 +1,3 @@
|
|||
gcc -Wall -g zstrreg.c zstr.c zcode.c -o zstrreg
|
||||
gcc -Wall -Wextra -g avodoc.c FTS_index.c zstr.c zcode.c -o avo
|
||||
|
Binary file not shown.
|
@ -187,6 +187,7 @@ ArangoServer::ArangoServer (int argc, char** argv)
|
|||
: _argc(argc),
|
||||
_argv(argv),
|
||||
_runningOnValgrind(false),
|
||||
_performUpgrade(false),
|
||||
_binaryPath(),
|
||||
_applicationScheduler(0),
|
||||
_applicationDispatcher(0),
|
||||
|
@ -305,6 +306,7 @@ void ArangoServer::buildApplicationServer () {
|
|||
|
||||
additional[ApplicationServer::OPTIONS_CMDLINE]
|
||||
("console", "do not start as server, start a JavaScript emergency console instead")
|
||||
("upgrade", "perform a database upgrade")
|
||||
;
|
||||
|
||||
#ifdef TRI_ENABLE_MRUBY
|
||||
|
@ -521,7 +523,10 @@ int ArangoServer::startupServer () {
|
|||
|
||||
_applicationV8->setVocbase(_vocbase);
|
||||
_applicationV8->setConcurrency(_dispatcherThreads);
|
||||
_applicationV8->enableVersionCheck();
|
||||
|
||||
if (_applicationServer->programOptions().has("upgrade")) {
|
||||
_applicationV8->performUpgrade();
|
||||
}
|
||||
|
||||
#if TRI_ENABLE_MRUBY
|
||||
_applicationMR->setVocbase(_vocbase);
|
||||
|
|
|
@ -209,6 +209,12 @@ namespace triagens {
|
|||
|
||||
bool _runningOnValgrind;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief perform a database upgrade
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool _performUpgrade;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief path to binary
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -179,7 +179,7 @@ ApplicationV8::ApplicationV8 (string const& binaryPath)
|
|||
_startupModules(),
|
||||
_actionPath(),
|
||||
_useActions(true),
|
||||
_runVersionCheck(false),
|
||||
_performUpgrade(false),
|
||||
_gcInterval(1000),
|
||||
_gcFrequency(10.0),
|
||||
_v8Options(""),
|
||||
|
@ -232,11 +232,11 @@ void ApplicationV8::setVocbase (TRI_vocbase_t* vocbase) {
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief enable the database version check
|
||||
/// @brief perform a database upgrade
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ApplicationV8::enableVersionCheck () {
|
||||
_runVersionCheck = true;
|
||||
void ApplicationV8::performUpgrade () {
|
||||
_performUpgrade = true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -693,20 +693,27 @@ bool ApplicationV8::prepareV8Instance (const size_t i) {
|
|||
}
|
||||
|
||||
|
||||
if (i == 0 && _runVersionCheck) {
|
||||
if (i == 0) {
|
||||
LOGGER_DEBUG << "running database version check";
|
||||
|
||||
const string script = _startupLoader.buildScript(JS_server_version_check);
|
||||
|
||||
// special check script to be run just once in first thread (not in all)
|
||||
v8::HandleScope scope;
|
||||
|
||||
context->_context->Global()->Set(TRI_V8_SYMBOL("UPGRADE"), _performUpgrade ? v8::True() : v8::False());
|
||||
v8::Handle<v8::Value> result = TRI_ExecuteJavaScriptString(context->_context,
|
||||
v8::String::New(script.c_str()),
|
||||
v8::String::New("version-check.js"),
|
||||
false);
|
||||
|
||||
if (! TRI_ObjectToBoolean(result)) {
|
||||
LOGGER_FATAL << "Database version check failed. Please run arango-upgrade --database.directory \"" << _vocbase->_path << "\"";
|
||||
if (_performUpgrade) {
|
||||
LOGGER_FATAL << "Database upgrade failed. Please inspect the logs from the upgrade procedure";
|
||||
}
|
||||
else {
|
||||
LOGGER_FATAL << "Database version check failed. Please start the server with the --upgrade option";
|
||||
}
|
||||
|
||||
context->_context->Exit();
|
||||
context->_isolate->Exit();
|
||||
|
|
|
@ -204,7 +204,7 @@ namespace triagens {
|
|||
/// @brief enable the database version check
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void enableVersionCheck ();
|
||||
void performUpgrade ();
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief enters an context
|
||||
|
@ -369,10 +369,10 @@ namespace triagens {
|
|||
bool _useActions;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief run the database version check
|
||||
/// @brief perform a database upgrade
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool _runVersionCheck;
|
||||
bool _performUpgrade;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief JavaScript garbage collection interval (each x requests)
|
||||
|
|
|
@ -945,6 +945,10 @@ SimpleQueryRange.prototype.constructor = SimpleQueryRange;
|
|||
/// An attribute name of the form @LIT{a.b} is interpreted as attribute path,
|
||||
/// not as attribute.
|
||||
///
|
||||
/// For range queries it is required that a skiplist index is present for the
|
||||
/// queried attribute. If no skiplist index is present on the attribute, an
|
||||
/// error will be thrown.
|
||||
///
|
||||
/// @EXAMPLES
|
||||
///
|
||||
/// Use @FN{toArray} to get all documents at once:
|
||||
|
|
|
@ -1093,7 +1093,7 @@ function Graph(name, vertices, edges) {
|
|||
graphPropertiesId;
|
||||
|
||||
if (gdb === null) {
|
||||
throw "_graphs collection does not exist. please run arango-upgrade";
|
||||
throw "_graphs collection does not exist.";
|
||||
}
|
||||
|
||||
if (typeof name !== "string" || name === "") {
|
||||
|
|
|
@ -944,6 +944,10 @@ SimpleQueryRange.prototype.constructor = SimpleQueryRange;
|
|||
/// An attribute name of the form @LIT{a.b} is interpreted as attribute path,
|
||||
/// not as attribute.
|
||||
///
|
||||
/// For range queries it is required that a skiplist index is present for the
|
||||
/// queried attribute. If no skiplist index is present on the attribute, an
|
||||
/// error will be thrown.
|
||||
///
|
||||
/// @EXAMPLES
|
||||
///
|
||||
/// Use @FN{toArray} to get all documents at once:
|
||||
|
|
|
@ -0,0 +1,220 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief User management
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2012 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Jan Steemann
|
||||
/// @author Copyright 2012, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
var internal = require("internal");
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- ArangoUsers
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- constructors and destructors
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup ArangoUsers
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief validate a username
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
var validateName = function (username) {
|
||||
if (typeof username !== 'string' || ! username.match(/^[a-zA-Z0-9\-_]+$/)) {
|
||||
throw "username must be a string";
|
||||
}
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief validate password
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
var validatePassword = function (passwd) {
|
||||
if (typeof passwd !== 'string') {
|
||||
throw "password must be a string";
|
||||
}
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief return the users collection
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
var getStorage = function () {
|
||||
var users = internal.db._collection("_users");
|
||||
|
||||
if (users == null) {
|
||||
throw "collection _users does not exist.";
|
||||
}
|
||||
|
||||
return users;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief create a new user
|
||||
///
|
||||
/// @FUN{@FA{users}.save(@FA{username}, @FA{passwd})}
|
||||
///
|
||||
/// This will create a new ArangoDB user.
|
||||
/// The username must be a string and contain only the letters a-z (lower or
|
||||
/// upper case), the digits 0-9, the dash or the underscore symbol.
|
||||
///
|
||||
/// The password must be given as a string, too, but can be left empty if
|
||||
/// required.
|
||||
///
|
||||
/// This method will fail if either the username or the passwords are not
|
||||
/// specified or given in a wrong format, or there already exists a user with
|
||||
/// the specified name.
|
||||
///
|
||||
/// Note: this function will not work from within the web interface
|
||||
///
|
||||
/// @EXAMPLES
|
||||
///
|
||||
/// @TINYEXAMPLE{user-save,saving a new user}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
saveUser = function (username, passwd) {
|
||||
// validate input
|
||||
validateName(username);
|
||||
validatePassword(passwd);
|
||||
|
||||
var users = getStorage();
|
||||
var user = users.firstExample({ user: username });
|
||||
|
||||
if (user == null) {
|
||||
var hash = internal.encodePassword(passwd);
|
||||
return users.save({ user: username, _key: username, password: hash, active: true });
|
||||
}
|
||||
else {
|
||||
throw "cannot create user: user already exists.";
|
||||
}
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief update an existing user
|
||||
///
|
||||
/// @FUN{@FA{users}.replace(@FA{username}, @FA{passwd})}
|
||||
///
|
||||
/// This will update an existing ArangoDB user with a new password.
|
||||
///
|
||||
/// The username must be a string and contain only the letters a-z (lower or
|
||||
/// upper case), the digits 0-9, the dash or the underscore symbol. The user
|
||||
/// must already exist in the database.
|
||||
///
|
||||
/// The password must be given as a string, too, but can be left empty if
|
||||
/// required.
|
||||
///
|
||||
/// This method will fail if either the username or the passwords are not
|
||||
/// specified or given in a wrong format, or if the specified user cannot be
|
||||
/// found in the database.
|
||||
///
|
||||
/// Note: this function will not work from within the web interface
|
||||
///
|
||||
/// @EXAMPLES
|
||||
///
|
||||
/// @TINYEXAMPLE{user-replace,replacing an existing user}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
replaceUser = function (username, passwd) {
|
||||
// validate input
|
||||
validateName(username);
|
||||
validatePassword(passwd);
|
||||
|
||||
var users = getStorage();
|
||||
var user = users.firstExample({ user: username });
|
||||
|
||||
if (user == null) {
|
||||
throw "cannot update user: user does not exist.";
|
||||
}
|
||||
|
||||
var hash = internal.encodePassword(passwd);
|
||||
var data = user.shallowCopy;
|
||||
data.password = hash;
|
||||
return users.replace(user, data);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief delete an existing user
|
||||
///
|
||||
/// @FUN{@FA{users}.remove(@FA{username}, @FA{passwd})}
|
||||
///
|
||||
/// Removes an existing ArangoDB user from the database.
|
||||
///
|
||||
/// The username must be a string and contain only the letters a-z (lower or
|
||||
/// upper case), the digits 0-9, the dash or the underscore symbol. The user
|
||||
/// must already exist in the database.
|
||||
///
|
||||
/// This method will fail if the user cannot be found in the database.
|
||||
///
|
||||
/// Note: this function will not work from within the web interface
|
||||
///
|
||||
/// @EXAMPLES
|
||||
///
|
||||
/// @TINYEXAMPLE{user-remove,removing an existing user}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
removeUser = function (username) {
|
||||
// validate input
|
||||
validateName(username);
|
||||
|
||||
var users = getStorage();
|
||||
var user = users.firstExample({ user: username });
|
||||
|
||||
if (user == null) {
|
||||
throw "cannot delete: user does not exist.";
|
||||
}
|
||||
|
||||
return users.remove(user);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- MODULE EXPORTS
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup ArangoUsers
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
exports.save = saveUser;
|
||||
exports.replace = replaceUser;
|
||||
exports.update = replaceUser;
|
||||
exports.remove = removeUser;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Local Variables:
|
||||
// mode: outline-minor
|
||||
// outline-regexp: "^\\(/// @brief\\|/// @addtogroup\\|// --SECTION--\\|/// @page\\|/// @}\\)"
|
||||
// End:
|
||||
|
|
@ -1,116 +0,0 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief arango change password
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2004-2012 triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Copyright 2012, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- arango-password
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup ArangoDB
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief creates or changes the passwords
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function main (argv) {
|
||||
var argc = argv.length;
|
||||
var internal = require("internal");
|
||||
var console = require("console");
|
||||
var db = internal.db;
|
||||
var users = null;
|
||||
var username = null;
|
||||
var pasword = null;
|
||||
|
||||
users = db._collection("_users");
|
||||
|
||||
if (users == null) {
|
||||
console.error("users collection '_users' not available. please run arango-upgrade.");
|
||||
return 2;
|
||||
}
|
||||
|
||||
internal.output("\n");
|
||||
|
||||
if (argc < 1 || argc > 3) {
|
||||
internal.output("usage: ", argv[0], " <username> [<password>]\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (argc == 1) {
|
||||
internal.output("Enter User: ");
|
||||
username = console.getline();
|
||||
|
||||
internal.output("Enter Password: ");
|
||||
password = console.getline();
|
||||
}
|
||||
else if (argc == 2) {
|
||||
username = argv[1];
|
||||
internal.output("Enter Password: ");
|
||||
password = console.getline();
|
||||
}
|
||||
else if (argc == 3) {
|
||||
username = argv[1];
|
||||
password = argv[2];
|
||||
}
|
||||
|
||||
var hash = internal.encodePassword(password);
|
||||
|
||||
if (username == "" ) {
|
||||
internal.output("username must not be empty\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
var user = users.firstExample({ user: username });
|
||||
|
||||
if (user == null) {
|
||||
users.save({ user: username, password: hash, active: true });
|
||||
console.info("created user '%s'", username);
|
||||
}
|
||||
else {
|
||||
var data = user.shallowCopy;
|
||||
data.password = hash;
|
||||
|
||||
users.replace(user, data);
|
||||
console.info("updated user '%s'", username);
|
||||
}
|
||||
|
||||
console.info("password hash '%s'", hash);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- END-OF-FILE
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// Local Variables:
|
||||
// mode: outline-minor
|
||||
// outline-regexp: "^\\(/// @brief\\|/// @addtogroup\\|// --SECTION--\\|/// @page\\|/// @}\\)"
|
||||
// End:
|
|
@ -1,337 +0,0 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief arango upgrade actions
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2004-2012 triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Jan Steemann
|
||||
/// @author Copyright 2012, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- arango-upgrade
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup ArangoDB
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief updates the database
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function main (argv) {
|
||||
var internal = require("internal");
|
||||
var console = require("console");
|
||||
var db = internal.db;
|
||||
|
||||
// path to the VERSION file
|
||||
var versionFile = DATABASEPATH + "/VERSION";
|
||||
|
||||
var allTasks = [ ];
|
||||
var activeTasks = [ ];
|
||||
|
||||
|
||||
var lastVersion = null;
|
||||
var lastTasks = { };
|
||||
|
||||
if (FS_EXISTS(versionFile)) {
|
||||
// VERSION file exists, read its contents
|
||||
var versionInfo = SYS_READ(versionFile);
|
||||
if (versionInfo != '') {
|
||||
var versionValues = JSON.parse(versionInfo);
|
||||
if (versionValues && versionValues.version && ! isNaN(versionValues.version)) {
|
||||
lastVersion = parseFloat(versionValues.version);
|
||||
}
|
||||
if (versionValues && versionValues.tasks && typeof(versionValues.tasks) === 'object') {
|
||||
lastTasks = versionValues.tasks || { };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log("Upgrade script " + argv[0] + " started");
|
||||
console.log("Server version: " + VERSION + ", database directory version: " + (lastVersion || "(not set)"));
|
||||
|
||||
var currentServerVersion = VERSION.match(/^(\d+\.\d+).*$/);
|
||||
if (! currentServerVersion) {
|
||||
// server version is invalid for some reason
|
||||
console.error("Unexpected arangodb server version found.");
|
||||
console.error("Refusing to start.");
|
||||
return 1;
|
||||
}
|
||||
var currentVersion = parseFloat(currentServerVersion[1]);
|
||||
|
||||
if (lastVersion != null && lastVersion > currentVersion) {
|
||||
// downgrade??
|
||||
console.error("Database directory version is higher than server version. This seems like a downgrade, which is not supported.");
|
||||
console.error("Refusing to start.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
function getCollection (name) {
|
||||
return db._collection(name);
|
||||
}
|
||||
|
||||
function collectionExists (name) {
|
||||
var collection = getCollection(name);
|
||||
return (collection != undefined) && (collection != null) && (collection.name() == name);
|
||||
}
|
||||
|
||||
function createSystemCollection (name, attributes) {
|
||||
if (collectionExists(name)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var realAttributes = attributes || { };
|
||||
realAttributes['isSystem'] = true;
|
||||
|
||||
if (db._create(name, realAttributes)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return collectionExists(name);
|
||||
}
|
||||
|
||||
// helper function to define tasks
|
||||
function addTask (name, description, code) {
|
||||
// "description" is a textual description of the task that will be printed out on screen
|
||||
// "maxVersion" is the maximum version number the task will be applied for
|
||||
var task = { name: name, description: description, code: code };
|
||||
|
||||
allTasks.push(task);
|
||||
|
||||
if (lastTasks[name] === undefined || lastTasks[name] === false) {
|
||||
// task never executed or previous execution failed
|
||||
activeTasks.push(task);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// the actual upgrade tasks. all tasks defined here should be "re-entrant"
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// set up the collection _users
|
||||
addTask("setupUsers", "setup _users collection", function () {
|
||||
return createSystemCollection("_users", { waitForSync : true });
|
||||
});
|
||||
|
||||
// create a unique index on username attribute in _users
|
||||
addTask("createUsersIndex", "create index on username attribute in _users collection", function () {
|
||||
var users = getCollection("_users");
|
||||
if (! users) {
|
||||
return false;
|
||||
}
|
||||
|
||||
users.ensureUniqueConstraint("username");
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
// add a default root user with no passwd
|
||||
addTask("addDefaultUser", "add default root user", function () {
|
||||
var users = getCollection("_users");
|
||||
if (! users) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (users.count() == 0) {
|
||||
// only add account if user has not created his/her own accounts already
|
||||
users.save({ user: "root", password: internal.encodePassword(""), active: true });
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
// set up the collection _graphs
|
||||
addTask("setupGraphs", "setup _graphs collection", function () {
|
||||
return createSystemCollection("_graphs", { waitForSync : true });
|
||||
});
|
||||
|
||||
// create a unique index on name attribute in _graphs
|
||||
addTask("createGraphsIndex", "create index on name attribute in _graphs collection", function () {
|
||||
var graphs = getCollection("_graphs");
|
||||
|
||||
if (! graphs) {
|
||||
return false;
|
||||
}
|
||||
|
||||
graphs.ensureUniqueConstraint("name");
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
// make distinction between document and edge collections
|
||||
addTask("addCollectionVersion", "set new collection type for edge collections and update collection version", function () {
|
||||
var collections = db._collections();
|
||||
|
||||
for (var i in collections) {
|
||||
var collection = collections[i];
|
||||
|
||||
try {
|
||||
if (collection.version() > 1) {
|
||||
// already upgraded
|
||||
continue;
|
||||
}
|
||||
|
||||
if (collection.type() == 3) {
|
||||
// already an edge collection
|
||||
collection.setAttribute("version", 2);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (collection.count() > 0) {
|
||||
var isEdge = true;
|
||||
// check the 1st 50 documents from a collection
|
||||
var documents = collection.ALL(0, 50);
|
||||
|
||||
for (var j in documents) {
|
||||
var doc = documents[j];
|
||||
|
||||
// check if documents contain both _from and _to attributes
|
||||
if (! doc.hasOwnProperty("_from") || ! doc.hasOwnProperty("_to")) {
|
||||
isEdge = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isEdge) {
|
||||
collection.setAttribute("type", 3);
|
||||
console.log("made collection '" + collection.name() + " an edge collection");
|
||||
}
|
||||
}
|
||||
collection.setAttribute("version", 2);
|
||||
}
|
||||
catch (e) {
|
||||
console.error("could not upgrade collection '" + collection.name() + "'");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
// create the _modules collection
|
||||
addTask("createModules", "setup _modules collection", function () {
|
||||
return createSystemCollection("_modules");
|
||||
});
|
||||
|
||||
// create the _routing collection
|
||||
addTask("createRouting", "setup _routing collection", function () {
|
||||
return createSystemCollection("_routing");
|
||||
});
|
||||
|
||||
// create the _routing collection
|
||||
addTask("insertDefaultRoute", "insert default route for the admin interface", function () {
|
||||
var routing = getCollection("_routing");
|
||||
if (! routing) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (routing.count() == 0) {
|
||||
// only add route if no other route has been defined
|
||||
routing.save({ url: "/", action: { "do": "org/arangodb/actions/redirectRequest", options: { permanently: true, destination: "/_admin/html/index.html" } } });
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
// update markers in all collection datafiles to key markers
|
||||
addTask("upgradeMarkers12", "update markers in all collection datafiles", function () {
|
||||
var collections = db._collections();
|
||||
|
||||
for (var i in collections) {
|
||||
var collection = collections[i];
|
||||
|
||||
try {
|
||||
if (collection.version() >= 3) {
|
||||
// already upgraded
|
||||
continue;
|
||||
}
|
||||
|
||||
if (collection.upgrade()) {
|
||||
// success
|
||||
collection.setAttribute("version", 3);
|
||||
}
|
||||
else {
|
||||
// fail
|
||||
console.error("could not upgrade collection datafiles for '" + collection.name() + "'");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
console.error("could not upgrade collection datafiles for '" + collection.name() + "'");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
// loop through all tasks and execute them
|
||||
console.log("Found " + allTasks.length + " defined task(s), " + activeTasks.length + " task(s) to run");
|
||||
|
||||
var taskNumber = 0;
|
||||
for (var i in activeTasks) {
|
||||
var task = activeTasks[i];
|
||||
|
||||
console.log("Executing task #" + (++taskNumber) + " (" + task.name + "): " + task.description);
|
||||
|
||||
// assume failure
|
||||
var result = false;
|
||||
try {
|
||||
// execute task
|
||||
result = task.code();
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
|
||||
if (result) {
|
||||
// success
|
||||
lastTasks[task.name] = true;
|
||||
// save/update version info
|
||||
SYS_SAVE(versionFile, JSON.stringify({ version: currentVersion, tasks: lastTasks }));
|
||||
console.log("Task successful");
|
||||
}
|
||||
else {
|
||||
console.error("Task failed. Aborting upgrade script.");
|
||||
console.error("Please fix the problem and try running the upgrade script again.");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
console.log("Upgrade script successfully finished");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- END-OF-FILE
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// Local Variables:
|
||||
// mode: outline-minor
|
||||
// outline-regexp: "^\\(/// @brief\\|/// @addtogroup\\|// --SECTION--\\|/// @page\\|/// @}\\)"
|
||||
// End:
|
|
@ -881,12 +881,6 @@ function reloadRouting () {
|
|||
// .............................................................................
|
||||
|
||||
routing = internal.db._collection("_routing");
|
||||
|
||||
if (routing === null) {
|
||||
// TODO: remove this auto-creation. this should be done by arango-upgrade
|
||||
routing = internal.db._create("_routing", { isSystem: true });
|
||||
}
|
||||
|
||||
routes = routing.all();
|
||||
|
||||
// .............................................................................
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief version check at the start of the server
|
||||
/// @brief version check at the start of the server, will optionally perform
|
||||
/// necessary upgrades
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
|
@ -39,16 +40,290 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
(function() {
|
||||
var internal = require("internal");
|
||||
var console = require("console");
|
||||
var db = internal.db;
|
||||
|
||||
// path to the VERSION file
|
||||
var versionFile = DATABASEPATH + "/VERSION";
|
||||
var lastVersion = null;
|
||||
|
||||
if (! FS_EXISTS(versionFile)) {
|
||||
console.error("No version information file found in database directory.");
|
||||
function runUpgrade (currentVersion) {
|
||||
var allTasks = [ ];
|
||||
var activeTasks = [ ];
|
||||
var lastVersion = null;
|
||||
var lastTasks = { };
|
||||
|
||||
function getCollection (name) {
|
||||
return db._collection(name);
|
||||
}
|
||||
|
||||
function collectionExists (name) {
|
||||
var collection = getCollection(name);
|
||||
return (collection != undefined) && (collection != null) && (collection.name() == name);
|
||||
}
|
||||
|
||||
function createSystemCollection (name, attributes) {
|
||||
if (collectionExists(name)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var realAttributes = attributes || { };
|
||||
realAttributes['isSystem'] = true;
|
||||
|
||||
if (db._create(name, realAttributes)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return collectionExists(name);
|
||||
}
|
||||
|
||||
// helper function to define tasks
|
||||
function addTask (name, description, code) {
|
||||
// "description" is a textual description of the task that will be printed out on screen
|
||||
// "maxVersion" is the maximum version number the task will be applied for
|
||||
var task = { name: name, description: description, code: code };
|
||||
|
||||
allTasks.push(task);
|
||||
|
||||
if (lastTasks[name] === undefined || lastTasks[name] === false) {
|
||||
// task never executed or previous execution failed
|
||||
activeTasks.push(task);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (FS_EXISTS(versionFile)) {
|
||||
// VERSION file exists, read its contents
|
||||
var versionInfo = SYS_READ(versionFile);
|
||||
if (versionInfo != '') {
|
||||
var versionValues = JSON.parse(versionInfo);
|
||||
if (versionValues && versionValues.version && ! isNaN(versionValues.version)) {
|
||||
lastVersion = parseFloat(versionValues.version);
|
||||
}
|
||||
if (versionValues && versionValues.tasks && typeof(versionValues.tasks) === 'object') {
|
||||
lastTasks = versionValues.tasks || { };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log("Starting upgrade from version " + (lastVersion || "unknown") + " to " + VERSION);
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// the actual upgrade tasks. all tasks defined here should be "re-entrant"
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// set up the collection _users
|
||||
addTask("setupUsers", "setup _users collection", function () {
|
||||
return createSystemCollection("_users", { waitForSync : true });
|
||||
});
|
||||
|
||||
// create a unique index on username attribute in _users
|
||||
addTask("createUsersIndex", "create index on username attribute in _users collection", function () {
|
||||
var users = getCollection("_users");
|
||||
if (! users) {
|
||||
return false;
|
||||
}
|
||||
|
||||
users.ensureUniqueConstraint("username");
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
// add a default root user with no passwd
|
||||
addTask("addDefaultUser", "add default root user", function () {
|
||||
var users = getCollection("_users");
|
||||
if (! users) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (users.count() == 0) {
|
||||
// only add account if user has not created his/her own accounts already
|
||||
users.save({ user: "root", password: internal.encodePassword(""), active: true });
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
// set up the collection _graphs
|
||||
addTask("setupGraphs", "setup _graphs collection", function () {
|
||||
return createSystemCollection("_graphs", { waitForSync : true });
|
||||
});
|
||||
|
||||
// create a unique index on name attribute in _graphs
|
||||
addTask("createGraphsIndex", "create index on name attribute in _graphs collection", function () {
|
||||
var graphs = getCollection("_graphs");
|
||||
|
||||
if (! graphs) {
|
||||
return false;
|
||||
}
|
||||
|
||||
graphs.ensureUniqueConstraint("name");
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
// make distinction between document and edge collections
|
||||
addTask("addCollectionVersion", "set new collection type for edge collections and update collection version", function () {
|
||||
var collections = db._collections();
|
||||
|
||||
for (var i in collections) {
|
||||
var collection = collections[i];
|
||||
|
||||
try {
|
||||
if (collection.version() > 1) {
|
||||
// already upgraded
|
||||
continue;
|
||||
}
|
||||
|
||||
if (collection.type() == 3) {
|
||||
// already an edge collection
|
||||
collection.setAttribute("version", 2);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (collection.count() > 0) {
|
||||
var isEdge = true;
|
||||
// check the 1st 50 documents from a collection
|
||||
var documents = collection.ALL(0, 50);
|
||||
|
||||
for (var j in documents) {
|
||||
var doc = documents[j];
|
||||
|
||||
// check if documents contain both _from and _to attributes
|
||||
if (! doc.hasOwnProperty("_from") || ! doc.hasOwnProperty("_to")) {
|
||||
isEdge = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isEdge) {
|
||||
collection.setAttribute("type", 3);
|
||||
console.log("made collection '" + collection.name() + " an edge collection");
|
||||
}
|
||||
}
|
||||
collection.setAttribute("version", 2);
|
||||
}
|
||||
catch (e) {
|
||||
console.error("could not upgrade collection '" + collection.name() + "'");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
// create the _modules collection
|
||||
addTask("createModules", "setup _modules collection", function () {
|
||||
return createSystemCollection("_modules");
|
||||
});
|
||||
|
||||
// create the _routing collection
|
||||
addTask("createRouting", "setup _routing collection", function () {
|
||||
return createSystemCollection("_routing");
|
||||
});
|
||||
|
||||
// create the _routing collection
|
||||
addTask("insertDefaultRoute", "insert default route for the admin interface", function () {
|
||||
var routing = getCollection("_routing");
|
||||
if (! routing) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (routing.count() == 0) {
|
||||
// only add route if no other route has been defined
|
||||
routing.save({ url: "/", action: { "do": "org/arangodb/actions/redirectRequest", options: { permanently: true, destination: "/_admin/html/index.html" } } });
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
// update markers in all collection datafiles to key markers
|
||||
addTask("upgradeMarkers12", "update markers in all collection datafiles", function () {
|
||||
var collections = db._collections();
|
||||
|
||||
for (var i in collections) {
|
||||
var collection = collections[i];
|
||||
|
||||
try {
|
||||
if (collection.version() >= 3) {
|
||||
// already upgraded
|
||||
continue;
|
||||
}
|
||||
|
||||
if (collection.upgrade()) {
|
||||
// success
|
||||
collection.setAttribute("version", 3);
|
||||
}
|
||||
else {
|
||||
// fail
|
||||
console.error("could not upgrade collection datafiles for '" + collection.name() + "'");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
console.error("could not upgrade collection datafiles for '" + collection.name() + "'");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
// loop through all tasks and execute them
|
||||
console.log("Found " + allTasks.length + " defined task(s), " + activeTasks.length + " task(s) to run");
|
||||
|
||||
var taskNumber = 0;
|
||||
for (var i in activeTasks) {
|
||||
var task = activeTasks[i];
|
||||
|
||||
console.log("Executing task #" + (++taskNumber) + " (" + task.name + "): " + task.description);
|
||||
|
||||
// assume failure
|
||||
var result = false;
|
||||
try {
|
||||
// execute task
|
||||
result = task.code();
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
|
||||
if (result) {
|
||||
// success
|
||||
lastTasks[task.name] = true;
|
||||
// save/update version info
|
||||
SYS_SAVE(versionFile, JSON.stringify({ version: currentVersion, tasks: lastTasks }));
|
||||
console.log("Task successful");
|
||||
}
|
||||
else {
|
||||
console.error("Task failed. Aborting upgrade procedure.");
|
||||
console.error("Please fix the problem and try starting the server again.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// save file so version gets saved even if there are no tasks
|
||||
SYS_SAVE(versionFile, JSON.stringify({ version: currentVersion, tasks: lastTasks }));
|
||||
|
||||
console.log("Upgrade successfully finished");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
var lastVersion = null;
|
||||
var currentServerVersion = VERSION.match(/^(\d+\.\d+).*$/);
|
||||
if (! currentServerVersion) {
|
||||
// server version is invalid for some reason
|
||||
console.error("Unexpected ArangoDB server version: " + VERSION);
|
||||
return false;
|
||||
}
|
||||
|
||||
var currentVersion = parseFloat(currentServerVersion[1]);
|
||||
|
||||
if (! FS_EXISTS(versionFile)) {
|
||||
console.info("No version information file found in database directory.");
|
||||
return runUpgrade(currentVersion);
|
||||
}
|
||||
|
||||
// VERSION file exists, read its contents
|
||||
var versionInfo = SYS_READ(versionFile);
|
||||
|
@ -60,25 +335,35 @@
|
|||
}
|
||||
|
||||
if (lastVersion == null) {
|
||||
console.error("No version information file found in database directory.");
|
||||
return false;
|
||||
console.info("No VERSION file found in database directory.");
|
||||
return runUpgrade(currentVersion);
|
||||
}
|
||||
|
||||
var currentServerVersion = VERSION.match(/^(\d+\.\d+).*$/);
|
||||
if (! currentServerVersion) {
|
||||
// server version is invalid for some reason
|
||||
console.error("Unexpected arangodb server version found.");
|
||||
return false;
|
||||
}
|
||||
var currentVersion = parseFloat(currentServerVersion[1]);
|
||||
|
||||
if (lastVersion != null && lastVersion > currentVersion) {
|
||||
if (lastVersion == currentVersion) {
|
||||
// version match!
|
||||
return true;
|
||||
}
|
||||
|
||||
if (lastVersion > currentVersion) {
|
||||
// downgrade??
|
||||
console.error("Database directory version is higher than server version.");
|
||||
console.error("It seems like you are running arangodb on a database directory that was created with a newer version. This is not supported.");
|
||||
console.error("Database directory version (" + lastVersion + ") is higher than server version (" + currentVersion + ").");
|
||||
console.error("It seems like you are running ArangoDB on a database directory that was created with a newer version of ArangoDB. Maybe this is what you wanted but it is not supported by ArangoDB.");
|
||||
// still, allow the start
|
||||
return true;
|
||||
}
|
||||
else if (lastVersion < currentVersion) {
|
||||
// upgrade
|
||||
if (UPGRADE) {
|
||||
return runUpgrade(currentVersion);
|
||||
}
|
||||
|
||||
console.error("Database directory version (" + lastVersion + ") is lower than server version (" + currentVersion + ").");
|
||||
console.error("It seems like you have upgraded the ArangoDB binary. If this is what you wanted to do, please restart with the --upgrade option to upgrade the data in the database directory.");
|
||||
// do not start unless started with --upgrade
|
||||
return false;
|
||||
}
|
||||
|
||||
// we should never get here
|
||||
return true;
|
||||
})();
|
||||
|
||||
|
|
|
@ -282,7 +282,7 @@ void ApplicationServer::setupLogging () {
|
|||
if (NULL == TRI_CreateLogAppenderFile(_logFile.c_str())) {
|
||||
if (_logFile.length() > 0) {
|
||||
// the user specified a log file to use but it could not be created. bail out
|
||||
std::cerr << "failed to create logfile " << _logFile << std::endl;
|
||||
std::cerr << "failed to create logfile '" << _logFile << "'. Please check the path and permissions." << std::endl;
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
}
|
||||
|
|
|
@ -9,36 +9,10 @@
|
|||
################################################################################
|
||||
|
||||
bin_SCRIPTS += \
|
||||
bin/arango-password \
|
||||
bin/arango-dfdb \
|
||||
bin/arango-upgrade
|
||||
bin/arango-dfdb
|
||||
|
||||
CLEANUP += $(bin_SCRIPTS)
|
||||
|
||||
################################################################################
|
||||
### @brief arango password
|
||||
################################################################################
|
||||
|
||||
bin/arango-password: utils/arango-password.in
|
||||
sed \
|
||||
-e 's%@SBINDIR@%${TRI_SBINDIR}%g' \
|
||||
-e 's%@DATABASEDIR@%${TRI_DATABASEDIR}%g' \
|
||||
-e 's%@PKGDATADIR@%${TRI_PKGDATADIR}%g' \
|
||||
$< > $@
|
||||
chmod 755 $@
|
||||
|
||||
################################################################################
|
||||
### @brief arango upgrade
|
||||
################################################################################
|
||||
|
||||
bin/arango-upgrade: utils/arango-upgrade.in
|
||||
sed \
|
||||
-e 's%@SBINDIR@%${TRI_SBINDIR}%g' \
|
||||
-e 's%@DATABASEDIR@%${TRI_DATABASEDIR}%g' \
|
||||
-e 's%@PKGDATADIR@%${TRI_PKGDATADIR}%g' \
|
||||
$< > $@
|
||||
chmod 755 $@
|
||||
|
||||
################################################################################
|
||||
### @brief arango datafile debugger
|
||||
################################################################################
|
||||
|
|
|
@ -1,58 +0,0 @@
|
|||
#!/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-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 -z "$DATABASE"; then
|
||||
echo "$0: please specify a database directory using '--database'"
|
||||
exit 1
|
||||
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.modules-path "$MODULESPATH" \
|
||||
--javascript.script "$SCRIPT" \
|
||||
--javascript.script-parameter "$USER"
|
||||
else
|
||||
$ARANGOD \
|
||||
-c none \
|
||||
--database.directory "$DATABASE" \
|
||||
--javascript.modules-path "$MODULESPATH" \
|
||||
--javascript.script "$SCRIPT" \
|
||||
--javascript.script-parameter "$USER" \
|
||||
--javascript.script-parameter "$2"
|
||||
fi
|
|
@ -1,92 +0,0 @@
|
|||
#!/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" == "root" ] && [ "$UIDUSER" == "" ] ; then
|
||||
echo "Warning:"
|
||||
echo " $0 started without '--uid <user>' option."
|
||||
echo " Change owner of database files if needed!"
|
||||
exit 1
|
||||
fi
|
Loading…
Reference in New Issue