-
Notifications
You must be signed in to change notification settings - Fork 4
/
LaunchUserStalker.sh
53 lines (45 loc) · 1.26 KB
/
LaunchUserStalker.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
#!/bin/bash
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
JAR_FILE="${SCRIPT_DIR}/UserStalker.jar"
LOG_FILE="${SCRIPT_DIR}/UserStalker.log"
GIT_CLONE_URL="https://github.com/SOBotics/UserStalker.git"
while true;
do
{
printf '\n'
printf '=%.0s' {1..80}
printf '\n'
} >> "${LOG_FILE}" 2>&1
cd "${SCRIPT_DIR}" || exit
java -jar "${JAR_FILE}" "${1}" >> "${LOG_FILE}" 2>&1
EXIT_STATUS=$?
if (( EXIT_STATUS == 42 )); then
# Do in-place upgrade.
{
printf '\n'
printf '\055%.0s' {1..80}
printf "\nStart of in-place upgrade attempt.\n"
printf '\055%.0s' {1..80}
printf '\n'
rm -rf 'temp'
mkdir -p "temp"
cd "temp" || exit
git clone "${GIT_CLONE_URL}" || exit
cd "UserStalker" || exit
mvn package || exit
cp "target/UserStalker-"*".jar" "${SCRIPT_DIR}/UserStalker.jar"
cp "LaunchUserStalker.sh" "${SCRIPT_DIR}"
chmod +x "${SCRIPT_DIR}/LaunchUserStalker.sh"
cp "properties/"*[^login].properties "${SCRIPT_DIR}/properties/" # do not copy "login.properties" file!
printf '\n'
printf '\055%.0s' {1..80}
printf "\nEnd of in-place upgrade attempt.\n"
printf '\055%.0s' {1..80}
printf '\n'
sudo reboot
break
} >> "${LOG_FILE}" 2>&1
elif (( EXIT_STATUS != 0 )); then
break
fi
done