-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·82 lines (70 loc) · 2.16 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
#!/bin/bash
# Configuration
BRANCH="main"
INSTALLATION_DIR=~/.steamjar
SHORTCUT_PATH=~/.local/share/applications/SteamJar.desktop
REPOSITORY_URL="https://raw.githubusercontent.com/pbaja/SteamJar/$BRANCH"
# Liftoff
echo '=> Welcome to the SteamJar installer!'
# Check installed version
installed_version=0
if [[ -f $INSTALLATION_DIR/version.txt ]]; then
installed_version=$(cat $INSTALLATION_DIR/version.txt)
echo "-> Installed version: "$installed_version
installed_version=$(sed 's/[^0-9]*//g' <<< "$installed_version")
else
echo "-> No installation found"
fi
# Check latest version
latest_version=$(curl -s -f $REPOSITORY_URL/version.txt)
if [[ "$?" -ne "0" ]]; then
echo "-> Failed to check latest version"
read
exit 1
else
echo "-> Latest version: "$latest_version
latest_version=$(sed 's/[^0-9]*//g' <<< "$latest_version")
fi
# Check if a latest version is newer
if [[ "$installed_version" -ge "$latest_version" ]]; then
echo "-> Latest version is already installed"
read
exit 0
fi
# Remove old files, create new directory
echo "-> Removing previous installation if exists"
rm -r ~/SteamJar &> /dev/null
rm -r "$INSTALLATION_DIR" &> /dev/null
mkdir "$INSTALLATION_DIR"
# Download latest zip
echo "-> Downloading latest version..."
curl -fsL "https://github.com/pbaja/SteamJar/archive/refs/heads/$BRANCH.zip" --output "/tmp/SteamJar.zip"
if [[ "$?" -ne "0" ]]; then
echo "-> Failed to download"
read
exit 2
fi
# Unzip
echo "-> Unpacking archive"
bsdtar xf "/tmp/SteamJar.zip" -C "/tmp"
rm /tmp/SteamJar.zip
# Move to installation directory
echo "-> Moving files"
mv "/tmp/SteamJar-$BRANCH"/* "$INSTALLATION_DIR"
rm -r "/tmp/SteamJar-$BRANCH"
# Link desktop shortcut. Remove old one
echo "-> Creating desktop shortcut"
echo "[Desktop Entry]
Name=SteamJar
Comment=Import your games into Steam
Exec=python \"$INSTALLATION_DIR/run.py\"
Icon=applications-games
Terminal=false
Type=Application
Categories=Game;" > $SHORTCUT_PATH
rm ~/Desktop/SteamJar.desktop &> /dev/null
ln -s $SHORTCUT_PATH ~/Desktop/SteamJar.desktop
# Bye
echo '=> Finished! Start SteamJar by double-clicking it on your desktop'
echo 'You can close this terminal'
read