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.28 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
##########################
# UCOIN EXECUTABLE
#
# Wraps bin/ucoind.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 != v6* ]]; then
echo "$NODE v5 or v6 is required";
else
case "$1" in
#---------------------------------
# UCOIN DAEMON MANAGEMENT
#---------------------------------
webwait|webstart|webstop|webrestart|start|stop|restart)
$NODE "$DUNITER_DIR/bin/daemon" $*
;;
direct_start)
$NODE "$DUNITER_DIR/bin/ucoind" start ${@:2}
;;
logs)
LOGS_FILE=`$NODE "$DUNITER_DIR/bin/daemon" $*`
tail -f -n 500 "$LOGS_FILE"
;;
#---------------------------------
# UCOIN CLI COMMANDS
#---------------------------------
*)
$NODE "$DUNITER_DIR/bin/ucoind" $*
;;
esac
fi;
}
# If the script was launched with parameters, try to launch the Duniter command
if [ ! -z $1 ]; then
duniter $*
fi