forked from duniter/duniter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
duniter.sh
executable file
·76 lines (57 loc) · 1.29 KB
/
duniter.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
##########################
# DUNITER EXECUTABLE
#
# Wraps bin/duniter.js that is called with Node.js
#
DEB_PACKAGING=
if [[ $DEB_PACKAGING ]]; then
DUNITER_DIR=/opt/duniter/sources/
fi
duniter() {
local NODE
local LOGS_FILE
if [ -z "$DEV_MODE" ]; then
### Production mode
if [[ -d $DUNITER_DIR/node ]]; then
NODE=$DUNITER_DIR/node/bin/node
else
echo "Node.js is not embedded in this version of Duniter"
return
fi;
else
### Cheating with DEV mode
DUNITER_DIR=`pwd`
NODE=node
fi
VERSION=`$NODE -v`
if [[ $VERSION != v5* && $VERSION != v4* ]]; then
echo "$NODE v5 or v4 is required";
else
case "$1" in
#---------------------------------
# DUNITER DAEMON MANAGEMENT
#---------------------------------
webwait|webstart|webstop|webrestart|start|stop|restart)
$NODE "$DUNITER_DIR/bin/daemon" $*
;;
direct_start)
$NODE "$DUNITER_DIR/bin/duniter" start ${@:2}
;;
logs)
LOGS_FILE=`$NODE "$DUNITER_DIR/bin/daemon" $*`
tail -f -n 500 "$LOGS_FILE"
;;
#---------------------------------
# DUNITER CLI COMMANDS
#---------------------------------
*)
$NODE "$DUNITER_DIR/bin/duniter" $*
;;
esac
fi;
}
# If the script was launched with parameters, try to launch the Duniter command
if [ ! -z $1 ]; then
duniter $*
fi