Browse Source

Enhancement in instance creation script

Nescessary for refs #145
Yann Weber 8 years ago
parent
commit
67631445e6
1 changed files with 25 additions and 9 deletions
  1. 25
    9
      scripts/create_instance.sh

+ 25
- 9
scripts/create_instance.sh View File

1
 #!/bin/bash
1
 #!/bin/bash
2
 
2
 
3
 usage() {
3
 usage() {
4
-	echo -e "Usage : $0 instance_name (instance_dir|-u) [lodel_libdir]" 1>&2
4
+	echo -e "Usage : $0 instance_name (instance_dir|-u) [install_tpl] [em_file]" 1>&2
5
 	echo -e "\n\tIf -u given as first argument update instance's loader.py" 1>&2
5
 	echo -e "\n\tIf -u given as first argument update instance's loader.py" 1>&2
6
 	exit 1
6
 	exit 1
7
 }
7
 }
8
 
8
 
9
 cp_loader() {
9
 cp_loader() {
10
-	cp -Rv $libdir/install/loader.py $instdir/
10
+	cp -Rv $install_tpl/loader.py $instdir/
11
 	# Adding lib path to loader
11
 	# Adding lib path to loader
12
 	sed -i -E "s#^(LODEL2_LIB_ABS_PATH = )None#\1'$libdir'#" "$loader"
12
 	sed -i -E "s#^(LODEL2_LIB_ABS_PATH = )None#\1'$libdir'#" "$loader"
13
 }
13
 }
24
 name="$1"
24
 name="$1"
25
 instdir="$2"
25
 instdir="$2"
26
 
26
 
27
-libdir="$3"
28
-libdir="${libdir:=$(realpath $(dirname $0)/..)}/"
27
+
28
+libdir=$(realpath $(dirname $0))
29
+install_tpl="$3"
30
+install_tpl="${install_tpl:=$libdir/install}"
31
+em_file="$4"
32
+em_file="${em_file:=$libdir/examples/em_test.pickle}"
33
+
34
+libdir=$(realpath $libdir)
35
+install_tpl=$(realpath $install_tpl)
36
+em_file=$(realpath $em_file)
37
+
38
+
39
+if test ! -d $install_tpl
40
+then
41
+	echo "Install template directory '$install_tpl' not found"
42
+	echo ""
43
+	usage
44
+fi
29
 
45
 
30
 loader="$instdir/loader.py"
46
 loader="$instdir/loader.py"
31
 conf="$instdir/conf.d/lodel2.ini"
47
 conf="$instdir/conf.d/lodel2.ini"
48
 mkdir -pv "$instdir/sessions"
64
 mkdir -pv "$instdir/sessions"
49
 chmod 700 "$instdir/sessions"
65
 chmod 700 "$instdir/sessions"
50
 
66
 
51
-#cp -Rv $libdir/install/* $instdir
52
-cp -Rv $libdir/install/conf.d $instdir/
53
-cp -Rv $libdir/examples/em_test.pickle $instdir/editorial_model.pickle
54
-ln -sv $libdir/install/Makefile $instdir/Makefile
55
-ln -sv $libdir/install/lodel_admin.py $instdir/lodel_admin.py
67
+#cp -Rv $install_tpl/* $instdir
68
+cp -Rv $install_tpl/conf.d $instdir/
69
+cp -Rv $em_file $instdir/editorial_model.pickle
70
+ln -sv $install_tpl/Makefile $instdir/Makefile
71
+ln -sv $install_tpl/lodel_admin.py $instdir/lodel_admin.py
56
 ln -sv $libdir/plugins $instdir/plugins
72
 ln -sv $libdir/plugins $instdir/plugins
57
 cp_loader
73
 cp_loader
58
 # Adding instance name to conf
74
 # Adding instance name to conf

Loading…
Cancel
Save