duniter.sh 865 Bytes
Newer Older
1 2 3
#!/bin/bash

##########################
4
#    DUNITER EXECUTABLE
5
#
6
# Wraps bin/duniter that is called with Node.js
7 8
#

9
DEB_PACKAGING=
10 11

if [[ $DEB_PACKAGING ]]; then
12
  DUNITER_DIR=/opt/duniter/
13 14
fi

15
duniter() {
16

17
	local NODE
18
	local LOGS_FILE
19

20
	if [ -z "$DEV_MODE" ]; then
21

22
		### Production mode
23 24
		if [[ -d $DUNITER_DIR/node ]]; then
			NODE=$DUNITER_DIR/node/bin/node
25 26 27
	  else
	    echo "Node.js is not embedded in this version of Duniter"
	    return
28
		fi;
29
	else
30

31
		### Cheating with DEV mode
32
		DUNITER_DIR=`pwd`
33 34
		NODE=node
	fi
35

36
	VERSION=`$NODE -v`
37

Éloïs's avatar
Éloïs committed
38 39
	if [[ $VERSION != v8* ]] && [[ $VERSION != v9* ]]; then
	  echo "$NODE v8 or v9 is required";
40
	else
41

42
	  # Calls duniter JS command
43 44
	  cd $DUNITER_DIR
	  $NODE "$DUNITER_DIR/bin/duniter" "$@"
45

46 47
	fi;
}
48

49
# If the script was launched with parameters, try to launch the Duniter command
50
if [ ! -z $1 ]; then
51
	duniter "$@"
52
fi