-
Notifications
You must be signed in to change notification settings - Fork 1
/
linux-install-atlauncher.sh
executable file
·227 lines (176 loc) · 6.4 KB
/
linux-install-atlauncher.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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
#!/bin/bash
# Script for installing ATLauncher on Linux, Version 2.0
# Copyright (C) 2020-2021 DavidoTek
# === README ===
# Looks like you're trying to install ATLauncher.
# Just double-clicking the file may not work in your distribution.
# Try opening a terminal by right-clicking in the folder and choosing "Open Terminal here".
# 1. To make the file exectuable, type: chmod +x linux-install-atlauncher.sh
# 2. To finally run the installer, type: ./linux-install-atlauncher.sh
# If that doesn't work, here's more information: https://github.com/DavidoTek/linux-install-atlauncher
echo Trying to install all dependencies...
install_dependencies() {
if which zypper > /dev/null; then
echo Detected zypper Trying to install dependencies...
pkexec zypper install -y java-1_8_0-openjdk unzip zenity curl
elif which eopkg > /dev/null; then
echo Detected eopkg. Trying to install dependencies...
pkexec eopkg install -y openjdk-8 unzip zenity curl
elif which apt > /dev/null; then
echo Detected apt. Trying to install dependencies...
pkexec apt -y install openjdk-8-jre wget unzip zenity curl
elif which dnf > /dev/null; then
echo Detected dnf. Trying to install dependencies...
pkexec dnf -y install java-1.8.0-openjdk wget unzip zenity curl
elif which pacman > /dev/null; then
echo Detected pacman. Trying to install dependencies...
pkexec pacman -S --noconfirm jre8-openjdk wget unzip zenity curl
else
echo -p "Cannot install dependencies. Make sure they are installed and press [ENTER]. Press Ctrl+C to cancel the installation."
fi
}
if ! which java > /dev/null || ! which unzip > /dev/null || ! which curl > /dev/null || ! which zenity > /dev/null; then
install_dependencies
fi
ATLAUNCHER_HOME=$HOME/.local/share/atlauncher
DESKTOP_FILE_PATH=$HOME/.local/share/applications
DESKTOP_FILE=$DESKTOP_FILE_PATH/ATLauncher.desktop
JAVA_PATH=`which java`
get_download_url() {
curl --silent "https://api.github.com/repos/ATLauncher/ATLauncher/releases/latest" |
grep '"browser_download_url":' |
grep jar |
sed -E 's/.*"([^"]+)".*/\1/'
}
get_version() {
curl --silent "https://api.github.com/repos/ATLauncher/ATLauncher/releases/latest" |
grep '"tag_name":' |
sed -E 's/.*"([^"]+)".*/\1/'
}
mkdir -p $ATLAUNCHER_HOME/bin
wget `get_download_url` -O $ATLAUNCHER_HOME/bin/ATLauncher.jar
unzip -p $ATLAUNCHER_HOME/bin/ATLauncher.jar assets/image/Icon.png > $ATLAUNCHER_HOME/Icon.png
ATLAUNCHER_VERSION=`get_version`
echo `get_version` > $ATLAUNCHER_HOME/version.txt
cat << EOF > $ATLAUNCHER_HOME/linux-update-atlauncher.sh
#!/bin/bash
# Script for updating ATLauncher on Linux
ATLAUNCHER_HOME=$ATLAUNCHER_HOME
DESKTOP_FILE=$DESKTOP_FILE
# function 'vercomp' to compare version
# Copyright 2010 Dennis Williamson (https://stackoverflow.com/a/4025065)
# Licensed under CC BY-SA 2.5 (https://creativecommons.org/licenses/by-sa/2.5/)
vercomp () {
if [[ \$1 == \$2 ]]
then
return 0
fi
local IFS=.
local i ver1=(\$1) ver2=(\$2)
# fill empty fields in ver1 with zeros
for ((i=\${#ver1[@]}; i<\${#ver2[@]}; i++))
do
ver1[i]=0
done
for ((i=0; i<\${#ver1[@]}; i++))
do
if [[ -z \${ver2[i]} ]]
then
# fill empty fields in ver2 with zeros
ver2[i]=0
fi
if ((10#\${ver1[i]} > 10#\${ver2[i]}))
then
return 1
fi
if ((10#\${ver1[i]} < 10#\${ver2[i]}))
then
return 2
fi
done
return 0
}
get_download_url() {
curl --silent "https://api.github.com/repos/ATLauncher/ATLauncher/releases/latest" |
grep '"browser_download_url":' |
grep jar |
sed -E 's/.*"([^"]+)".*/\1/'
}
get_version() {
curl --silent "https://api.github.com/repos/ATLauncher/ATLauncher/releases/latest" |
grep '"tag_name":' |
sed -E 's/.*"([^"]+)".*/\1/'
}
ATLAUNCHER_VERSION=\`get_version\`
CURRENT_AT_VERSION=\`cat $ATLAUNCHER_HOME/version.txt\`
vercomp \$CURRENT_AT_VERSION \$ATLAUNCHER_VERSION
if ((\$? != 2))
then
echo \$CURRENT_AT_VERSION" >= "\$ATLAUNCHER_VERSION
echo "No update available!"
zenity --notification --text "No update available.\nCurrent version is \$CURRENT_AT_VERSION. Newest version is \$ATLAUNCHER_VERSION"
exit
fi
mkdir -p $ATLAUNCHER_HOME/bin
rm -rf $ATLAUNCHER_HOME/bin/assets
rm -rf $ATLAUNCHER_HOME/bin/cache
rm -rf $ATLAUNCHER_HOME/bin/downloads
rm -rf $ATLAUNCHER_HOME/bin/faileddownloads
rm -rf $ATLAUNCHER_HOME/bin/libraries
rm -rf $ATLAUNCHER_HOME/bin/temp
wget \`get_download_url\` -O $ATLAUNCHER_HOME/bin/ATLauncher.jar
echo \$ATLAUNCHER_VERSION > $ATLAUNCHER_HOME/version.txt
unzip -p $ATLAUNCHER_HOME/bin/ATLauncher.jar assets/image/Icon.png > $ATLAUNCHER_HOME/Icon.png
zenity --notification --text "ATLauncher was updated to \$ATLAUNCHER_VERSION."
EOF
chmod +x $ATLAUNCHER_HOME/linux-update-atlauncher.sh
cat << EOF > $ATLAUNCHER_HOME/linux-uninstall-atlauncher.sh
#!/bin/bash
# Script for uninstalling ATLauncher on Linux
if ! zenity --question --title "Uninstall ATLauncher" --text "Do you wan't to proceed? Your ATLauncher instances will be saved."; then
exit;
fi
rm -rf $ATLAUNCHER_HOME/bin/assets
rm -rf $ATLAUNCHER_HOME/bin/cache
rm -rf $ATLAUNCHER_HOME/bin/downloads
rm -rf $ATLAUNCHER_HOME/bin/faileddownloads
rm -rf $ATLAUNCHER_HOME/bin/libraries
rm -rf $ATLAUNCHER_HOME/bin/loaders
rm -rf $ATLAUNCHER_HOME/bin/logs
rm -rf $ATLAUNCHER_HOME/bin/runtimes
rm -rf $ATLAUNCHER_HOME/bin/temp
rm $ATLAUNCHER_HOME/bin/ATLauncher.jar
rm $ATLAUNCHER_HOME/bin/.test
rm $ATLAUNCHER_HOME/version.txt
rm $ATLAUNCHER_HOME/*sh
rm $ATLAUNCHER_HOME/Icon.png
rm $DESKTOP_FILE
zenity --notification --text "Uninstalled ATLauncher \$ATLAUNCHER_VERSION."
EOF
chmod +x $ATLAUNCHER_HOME/linux-uninstall-atlauncher.sh
cat << EOF > $ATLAUNCHER_HOME/start-atlauncher.sh
#!/bin/bash
# Script for starting ATLauncher
echo Starting ATLauncher...
$JAVA_PATH -jar $ATLAUNCHER_HOME/bin/ATLauncher.jar
EOF
chmod +x $ATLAUNCHER_HOME/start-atlauncher.sh
mkdir -p $DESKTOP_FILE_PATH
cat << EOF > $DESKTOP_FILE
[Desktop Entry]
Name=ATLauncher
Version=$ATLAUNCHER_VERSION
Type=Application
Exec=$ATLAUNCHER_HOME/start-atlauncher.sh
Icon=$ATLAUNCHER_HOME/Icon.png
Categories=Game;
Terminal=false
Actions=Update;Uninstall;
[Desktop Action Update]
Name=Update
Exec=$ATLAUNCHER_HOME/linux-update-atlauncher.sh
[Desktop Action Uninstall]
Name=Uninstall
Exec=$ATLAUNCHER_HOME/linux-uninstall-atlauncher.sh
EOF
echo -e "\nInstalled ATLauncher $ATLAUNCHER_VERSION successful!"