-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathogreemdb.sh
executable file
·87 lines (73 loc) · 1.58 KB
/
ogreemdb.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
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env bash
#
#Initialise MongoDB server.
#######################################
# Parse flags or use default values
# if not present.
# Flags:
# path: Path where Mongo will
# store records
# port: DB port to be exposed
# log: Path for Mongo log
# Default values:
# path: ./mdb
# port: 27017
# log: /mongod.log
#######################################
while test $# -gt 0; do
case "$1" in
-path)
shift
path=$1
shift
;;
-port)
shift
port=$1
shift
;;
-log)
shift
log=$1
shift
;;
-host)
shift
host=$1
shift
;;
*)
echo "$1 is not a recognized flag!"
return 1;
;;
esac
done
if [ -z "$path" ];
then
path="./mdb"
fi
if [ -z "$port" ];
then
port=27017
fi
if [ -z "$log" ];
then
log="./mongod.log"
fi
if [ -z "$host" ];
then
host="localhost"
fi
echo "Path : $path";
echo "Port : $port";
echo "Log : $log";
echo "Host : $host";
#killall mongod
fuser -k $port/tcp
rm -rf "$log"
rm -rf "$path"/*
mkdir "$path"
mongod --dbpath "$path" --port $port --logpath "$log" --fork
#The command below will execute the mongo script
mongosh "$host:"$port"/ogree" ./init_db/createdb.js
echo "done"