-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
105 lines (102 loc) · 2.75 KB
/
install.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
#!/bin/bash
function oldversion() {
OLDVERSION=false
if test -f "processWatcher.jar"; then
OLDVERSION=true
fi
if test -f "processWatchercli.jar"; then
OLDVERSION=true
fi
}
function checkjava() {
if type -p java; then
echo found java executable in PATH
_java=java
elif [[ -n "$JAVA_HOME" ]] && [[ -x "$JAVA_HOME/bin/java" ]]; then
echo Found java executable in JAVA_HOME
_java="$JAVA_HOME/bin/java"
else
echo "No java executable found!"
echo "Please install java >= 8 first"
exit
fi
local IFS=$'\n'
# remove \r for Cygwin
local lines=$("$_java" -Xms32M -Xmx32M -version 2>&1 | tr '\r' '\n')
if [[ -z $_java ]]
then
result=no_java
else
for line in $lines; do
if [[ (-z $result) && ($line = *"version \""*) ]]
then
local ver=$(echo $line | sed -e 's/.*version "\(.*\)"\(.*\)/\1/; 1q')
# on macOS, sed doesn't support '?'
if [[ $ver = "1."* ]]
then
result=$(echo $ver | sed -e 's/1\.\([0-9]*\)\(.*\)/\1/; 1q')
else
result=$(echo $ver | sed -e 's/\([0-9]*\)\(.*\)/\1/; 1q')
fi
fi
done
echo Detect Java "$result"
if [ "$result" -ge 8 ]; then
echo "Java version check ok"
else
echo "No java 8 or higher found"
echo "Please install java >= 8 first"
exit
fi
fi
}
echo PROCESSWATCHER INSTALL SCRIPT
if [ "$EUID" -ne 0 ]
then echo "Bitte führen sie das script als root aus!"
exit
fi
checkjava
cd /usr/bin/
oldversion
if [ $OLDVERSION == true ]; then
echo "Detect an processWatcher Version!"
echo "Do you want to perform an update?[Y/N]"
read input </dev/tty
if [ "$input" == "Y" ] || [ "$input" == "y" ]; then
echo "Update ProcessWatcher"
if test -f "watcher"; then
rm watcher
rm processWatcher.jar
fi
if test -f "watchercli"; then
rm watchercli
rm processWatchercli.jar
fi
elif [ "$input" == "N" ] || [ "$input" == "n" ]; then
echo "Nothing to Do!"
echo "exit"
exit
else
echo "No Valid Input!"
echo "exit"
exit
fi
fi
curl -s https://api.github.com/repos/Jonbeckas/processWatcher/releases/latest \
| grep "processWatcher.jar" \
| cut -d : -f 2,3 \
| tr -d \" \
| wget -q --show-progress -i -
curl -s https://api.github.com/repos/Jonbeckas/processWatcher/releases/latest \
| grep "processWatchercli.jar" \
| cut -d : -f 2,3 \
| tr -d \" \
| wget -q --show-progress -i -
echo Set wrapper shell files
echo -e "#!/bin/sh\njava -jar /usr/bin/processWatcher.jar" > /usr/bin/watcher
echo -e "#!/bin/sh\njava -jar /usr/bin/processWatchercli.jar" > /usr/bin/watchercli
echo Set File to executable
chmod +x processWatcher.jar
chmod +x processWatchercli.jar
chmod +x watcher
chmod +x watchercli