-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·80 lines (70 loc) · 1.74 KB
/
setup.sh
File metadata and controls
executable file
·80 lines (70 loc) · 1.74 KB
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
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR
start() {
echo "*** Starting roboboat-server ***" > /var/log/roboboat-server.log
local file=".installed"
if [ ! -f $file ]; then
sudo mkdir -p /etc/roboboat
sudo chown robonation:robonation /etc/roboboat
generateResources
touch $file
fi
git pull
mvn clean jetty:run
}
stop() {
sudo killall /usr/lib/jvm/java-8-oracle/bin/java
return 0
}
uninstall() {
local file=".installed"
if [ -f $file ]; then
sudo rm -rf /etc/roboboat
rm $file
fi
sudo rm /etc/init.d/roboboat-server
}
generatePassword() {
local LEN=0
local PASSWORD=""
while [ $LEN -lt 6 ]; do
PASSWORD=$(curl -s "http://www.randomtext.me/api/gibberish/p-1/1-1" | jq '.text_out | sub("</?p>";"") | sub("\\..*$"; "") | ascii_downcase' | sed -e 's/\"//g')
let LEN=${#PASSWORD}
done
echo "$PASSWORD"
}
generateResources() {
local path="src/main/resources"
if [ ! -d $path ]; then
mkdir -p $path
fi
local file="$path/realm.properties"
if [ ! -f $file ]; then
password=$(generatePassword)
echo "** Realm auth is: login:admin password:$password"
echo "admin: $password" > $file
fi
local keystore="$path/keystore"
if [ ! -f $keystore ]; then
keytool -genkey -alias roboboat -keyalg RSA -keystore $keystore -keysize 2048 -storepass qwerty123 -keypass $password -dname "CN=RoboBoat Team, OU=RoboBoat, O=RoboNation, L='Daytona Beach', ST=FL, C=US"
echo "** Generated keystore at $keystore with storepass: qwerty123 and keypass $password"
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
uninstall)
uninstall
;;
restart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart|uninstall}"
esac