blob: 369b992305970c585489650fd6faa6ea02fda9be (
plain)
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
|
#!/bin/sh
set -e
xdg_data_home=${XDG_DATA_HOME:-$HOME/.local/share}
rll=$xdg_data_home/runescape-launcher-launcher
tmpdir=$(mktemp -dt runescape-launcher-launcher.XXXXXXXXXX)
trap 'echo "cleaning up temporary directory..." >&2; rm -rf "$tmpdir"' INT TERM QUIT EXIT
if [ -f "$rll/Packages" ]; then
echo "checking for runescape-launcher updates..."
else
echo "downloading runescape-launcher to $rll..."
fi
curl --compressed -sSLo "$tmpdir/Packages" https://content.runescape.com/downloads/ubuntu/dists/trusty/non-free/binary-amd64/Packages
if ! cmp "$rll/Packages" "$tmpdir/Packages" 2>/dev/null; then
ver=$(awk '$1=="Version:"{print $2}' "$tmpdir/Packages")
if [ -f "$rll/Packages" ]; then
echo "updating runescape-launcher..." >&2
fi
curl --compressed -sSLo "$tmpdir/runescape-launcher_${ver}_amd64.deb" https://content.runescape.com/downloads/ubuntu/pool/non-free/r/runescape-launcher/runescape-launcher_${ver}_amd64.deb
sha256=$(awk '$1=="SHA256:"{print $2}' "$tmpdir/Packages")
echo "$sha256 *$tmpdir/runescape-launcher_${ver}_amd64.deb" | sha256sum -c
if bsdtar=$(command -v bsdtar 2>/dev/null); then
"$bsdtar" -C "$tmpdir" -xf "$tmpdir/runescape-launcher_${ver}_amd64.deb" data.tar.xz
elif ar=$(command -v ar 2>/dev/null); then
"$ar" x --output "$tmpdir" "$tmpdir/runescape-launcher_${ver}_amd64.deb" data.tar.xz
else
echo "bsdtar or ar must be installed to extract runescape-launcher" >&2
exit 1
fi
tar -C "$tmpdir" -xf "$tmpdir/data.tar.xz" ./usr/bin/runescape-launcher ./usr/share/games/runescape-launcher/runescape
sed -e 's#/usr/share/games/runescape-launcher/#${0%/*}/#' "$tmpdir/usr/bin/runescape-launcher" > "$tmpdir/runescape-launcher"
cat
install -Dm644 "$tmpdir/Packages" "$rll/Packages"
install -m755 "$tmpdir/runescape-launcher" "$tmpdir/usr/share/games/runescape-launcher/runescape" "$rll/"
else
echo "no updates available for runescape-launcher." >&2
fi
trap '' INT TERM QUIT EXIT
rm -rf "$tmpdir"
echo "starting runescape-launcher..." >&2
set -x
exec "$rll/runescape-launcher" "$@"
|