-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnpflow
executable file
·86 lines (73 loc) · 2.53 KB
/
npflow
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
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
MYDIR=`dirname $0` && [ ! `echo "$0" | grep '^\/'` ] && MYDIR=`pwd`/$MYDIR
# INI/CONF file
INI_FILE=$MYDIR/etc/config.ini
CONF_FILE=$MYDIR/etc/npflow.conf
DEV=$(cat $INI_FILE | grep -E -E "^DEV *=" | cut -d'=' -f2 | tr -d "\n")
cp -f $INI_FILE $MYDIR/nmrviewer/www/etc/nmrview.conf
cp -f $INI_FILE $MYDIR/nmrspec/conf/global.ini
if [ $DEV -eq 1 ]; then
DATADIR=$(cat $INI_FILE | grep DATASETS | cut -d'=' -f2 | tr -d "\n")
HTTP_PORT=$(cat $INI_FILE | grep HTTP_PORT | cut -d'=' -f2 | tr -d "\n")
else
DATADIR=$(cat $CONF_FILE | grep DATASETS | cut -d'=' -f2 | tr -d "\n")
HTTP_PORT=$(cat $CONF_FILE | grep HTTP_PORT | cut -d'=' -f2 | tr -d "\n")
fi
mkdir -p $DATADIR/tmp/np && chmod 777 $DATADIR/tmp/np
mkdir -p $DATADIR/tmp/nv && chmod 777 $DATADIR/tmp/nv
# nmrspec Container
SPEC_PORT=$HTTP_PORT
SPEC_IMAGE=nmrprocflow/nmrprocflow:latest
SPEC_CONTAINER=npflow
SPEC_PAR="--env-file $MYDIR/etc/npflow.conf"
SPEC_SRC=''
SPEC_TMP="-v $DATADIR/tmp/np:/tmp -v $DATADIR/tmp/nv:/var/www/html/nv/tmp"
if [ $DEV -eq 1 ]; then
SPEC_PAR=''
SPEC_SRC="-v $MYDIR/nmrspec:/srv/shiny-server -v $MYDIR/nmrviewer/www:/var/www/html/nv"
fi
CMD=$1
# If you use a named volume, (assumes that your docker version >= 1.9)
# - First you have to create the /opt/data volume
# sudo docker create -v /opt/data --name npflow_data_volume ubuntu
# - Second, uncomment the line below, and
# comment the line with 'VOLS' specified further with a local directory .
#VOLS="--volumes-from npflow_data_volume"
# If you use a local directory, first you have to create the /opt/data directory
VOLS="-v $DATADIR:/opt/data"
usage() { echo "usage: sh $0 start|stop|ps|restart|logs|update"; exit 1; }
case "$CMD" in
start)
# run NMRProcFlow
sudo docker run -d $SPEC_PAR $VOLS $SPEC_SRC $SPEC_TMP -p $SPEC_PORT:80 --name $SPEC_CONTAINER $SPEC_IMAGE
# show Logs
sudo docker logs $SPEC_CONTAINER
;;
stop)
sudo docker rm -f $SPEC_CONTAINER
;;
restart)
( sh $0 stop; sh $0 start)
;;
logs)
sudo docker logs $SPEC_CONTAINER
;;
ps)
sudo docker ps | head -1
sudo docker ps | grep "nmrprocflow/"
;;
build)
( rm -rf ./nmrviewer/www/tmp/_*; sudo docker build -t $SPEC_IMAGE . )
;;
pull)
sudo docker pull $SPEC_IMAGE
;;
push)
sudo docker push $SPEC_IMAGE
;;
clean)
( rm -rf /opt/data/_*; rm -rf $DATADIR/tmp/np/Rtmp*; rm -rf /tmp/_*; rm -rf $DATADIR/tmp/nv/_* )
;;
*) usage
exit 2
esac