-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-server.sh
117 lines (93 loc) · 2.29 KB
/
run-server.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
#!/bin/bash
# Check the first argument provided to the script
if [ "$1" == "numport" ]; then
make
echo
echo
# Commands to run if the input is "option1"
echo "Enter the port for the server: "
read port
echo "Starting server with optional specified port command -n"
registryPort=$port
echo
echo "Killing existing rmiregistry"
killall -9 rmiregistry >& /dev/null
echo
echo "Starting new rmiregistry from $(pwd)"
export CLASSPATH=$(pwd):$CLASSPATH
rmiregistry $registryPort &
# wait for rmiregistry to start
sleep 2
echo
echo "Starting server"
echo
echo
java -cp .:lib/* IdServer -n $registryPort
echo
elif [ "$1" == "verbose" ]; then
make
echo
echo
echo "Starting server with optional verbose command -v"
registryPort=5128
echo
echo "Killing existing rmiregistry"
killall -9 rmiregistry >& /dev/null
echo
echo "Starting new rmiregistry from $(pwd)"
export CLASSPATH=$(pwd):$CLASSPATH
rmiregistry $registryPort &
# wait for rmiregistry to start
sleep 2
echo
echo "Starting server"
echo
echo
java -cp .:lib/* IdServer $registryPort -v
echo
elif [ "$1" == "both" ]; then
make
echo
echo
echo "Starting server with ALL optional commands"
echo "Enter the port for the server: "
read port
registryPort=$port
echo
echo "Killing existing rmiregistry"
killall -9 rmiregistry >& /dev/null
echo
echo "Starting new rmiregistry from $(pwd)"
export CLASSPATH=$(pwd):$CLASSPATH
rmiregistry $registryPort &
# wait for rmiregistry to start
sleep 2
echo
echo "Starting server"
echo
echo
java -cp .:lib/* IdServer -n $registryPort -v
echo
else
# Default commands to run if no recognized input is provided
make
echo
echo
echo "Starting server with default commands."
registryPort=5128
echo
echo "Killing existing rmiregistry"
killall -9 rmiregistry >& /dev/null
echo
echo "Starting new rmiregistry from $(pwd)"
export CLASSPATH=$(pwd):$CLASSPATH
rmiregistry $registryPort &
# wait for rmiregistry to start
sleep 2
echo
echo "Starting server"
echo
echo
java -cp .:lib/* IdServer $registryPort
echo
fi