-
Notifications
You must be signed in to change notification settings - Fork 12
/
nio-script.sh
executable file
·160 lines (123 loc) · 3.83 KB
/
nio-script.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#!/bin/bash
if [ "$1" = "buildProvider" ]
then
echo "Build Nio-Provider"
BUILD_DIRECTORY=$2
if [ -z "$2" ]
then
echo "No build directory specified, we use a new build directory \"nio-build-provider\""
BUILD_DIRECTORY="nio-build-provider"
fi
if [ -d "$BUILD_DIRECTORY" ]
then
echo "An existing \"$BUILD_DIRECTORY\" folder already exist, it's time to say good bye!"
rm -rf $BUILD_DIRECTORY
fi
cd nio-provider/javascript
echo "Installing Yarn"
sudo npm install -g yarn
yarn install
echo "Running JS build"
yarn run build
echo "Destroying dependencies cache"
rm -rf ./node_modules
cd ../..
pwd
sbt 'project nio-provider' 'dist'
mkdir -p $BUILD_DIRECTORY
cp nio-provider/target/universal/nio-provider.zip $BUILD_DIRECTORY
cp DockerfileProvider $BUILD_DIRECTORY
cd $BUILD_DIRECTORY
pwd
docker build --file DockerfileProvider -t maif/nio-provider .
elif [ "$1" = "build" ]
then
echo "Build Nio"
BUILD_DIRECTORY=$2
if [ -z "$2" ]
then
echo "No build directory specified, we use a new build directory \"nio-build\""
BUILD_DIRECTORY="nio-build"
fi
if [ -d "$BUILD_DIRECTORY" ]
then
echo "An existing \"$BUILD_DIRECTORY\" folder already exist, it's time to say good bye!"
rm -rf $BUILD_DIRECTORY
fi
cd nio-server/javascript
echo "Installing Yarn"
sudo npm install -g yarn
yarn install
echo "Running JS build"
yarn run build
echo "Destroying dependencies cache"
rm -rf ./node_modules
cd ../..
pwd
sbt 'project nio-server' 'dist'
mkdir -p $BUILD_DIRECTORY
cp nio-server/target/universal/nio.zip $BUILD_DIRECTORY
cp Dockerfile $BUILD_DIRECTORY
cd $BUILD_DIRECTORY
pwd
docker build -t maif/nio .
elif [ "$1" = "run" ]
then
echo "DO NOT FORGET to setup your hosts"
echo "/etc/hosts: 127.0.0.1 nio.foo.bar nio-provider.foo.bar nio-download.foo.bar kibana.foo.bar elastic.foo.bar keycloak.foo.bar otoroshi.foo.bar otoroshi-api.foo.bar privateapps.foo.bar"
echo "DO NOT FORGET to replace the ip address a line 161 and line 168 in docker-compose.prod.yml by your ip address"
echo "credentials are the following"
echo "http://keycloak.foo.bar:8889 : keycloak/password"
echo "http://otoroshi.foo.bar:8889 : [email protected]/password"
echo "http://kibana.foo.bar:8889 : index on otoroshi-events-* / @timestamp"
echo "http://nio.foo.bar:8889 : [email protected]/password"
read -p "have you setup your host and add your ip address in docker-compose.prod.yml [press y to continue] ? " -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
echo "Run Nio"
BUILD_DIRECTORY=$2
if [ -z "$2" ]
then
echo "No run directory specified, we use a new run directory \"nio-run\""
BUILD_DIRECTORY="nio-run"
fi
if [ -d "$BUILD_DIRECTORY" ]
then
echo "An existing \"$BUILD_DIRECTORY\" folder already exist, it's time to say good bye!"
sudo rm -rf $BUILD_DIRECTORY/config
docker-compose -f $BUILD_DIRECTORY/docker-compose.yml down
sudo rm -rf $BUILD_DIRECTORY
echo "it's clean!"
fi
mkdir -p $BUILD_DIRECTORY;
cd $BUILD_DIRECTORY;
cp ../docker-compose.prod.yml .
mv docker-compose.prod.yml docker-compose.yml
cp -R ../config .
mkdir -p data/es-data
echo "All folder and files copied"
sudo sysctl -w vm.max_map_count=262144
docker-compose up
fi
elif [ "$1" = "cleanRun" ] && [ -d "$2" ]
then
echo "Clean run folder"
sudo rm -rf $2/config
docker-compose -f $2/docker-compose.yml down
sudo rm -rf $2
echo "it's clean!"
elif [ "$1" = "cleanBuild" ] && [ -d "$2" ]
then
echo "Clean build folder"
sudo rm -rf $2
echo "it's clean!"
elif [ "$1" = "cleanBuild" ] && [ ! -d "$2" ]
then
echo "Nothing to clean or build directory not specified"
elif [ "$1" = "cleanRun" ] && [ ! -d "$2" ]
then
echo "Nothing to clean or run directory not specified"
else
echo "Please specify if you want to \"build\", \"run\", \"cleanRun\" or \"cleanBuild\" Nio"
fi