forked from Maclay74/steam-patch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
53 lines (40 loc) · 1.52 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
#!/bin/sh
[ "$UID" -eq 0 ] || exec sudo "$0" "$@"
echo "Installing Steam Patch release..."
USER_DIR="$(getent passwd $SUDO_USER | cut -d: -f6)"
WORKING_FOLDER="${USER_DIR}/steam-patch"
# Create folder structure
mkdir "${WORKING_FOLDER}"
# Enable CEF debugging
touch "${USER_DIR}/.steam/steam/.cef-enable-remote-debugging"
# Download latest release and install it
RELEASE=$(curl -s 'https://api.github.com/repos/Maclay74/steam-patch/releases' | jq -r "first(.[] | select(.prerelease == "false"))")
VERSION=$(jq -r '.tag_name' <<< ${RELEASE} )
DOWNLOAD_URL=$(jq -r '.assets[].browser_download_url | select(endswith("steam-patch"))' <<< ${RELEASE})
printf "Installing version %s...\n" "${VERSION}"
curl -L $DOWNLOAD_URL --output ${WORKING_FOLDER}/steam-patch
chmod +x ${WORKING_FOLDER}/steam-patch
systemctl --user stop steam-patch 2> /dev/null
systemctl --user disable steam-patch 2> /dev/null
systemctl stop steam-patch 2> /dev/null
systemctl disable steam-patch 2> /dev/null
# Add new service file
cat > "${WORKING_FOLDER}/steam-patch.service" <<- EOM
[Unit]
Description=Steam Patches Loader
Wants=network.target
After=network.target
[Service]
Type=simple
User=root
ExecStart=${WORKING_FOLDER}/steam-patch --user=${SUDO_USER}
WorkingDirectory=${WORKING_FOLDER}
[Install]
WantedBy=multi-user.target
EOM
rm -f "/etc/systemd/system/steam-patch.service"
cp "${WORKING_FOLDER}/steam-patch.service" "/etc/systemd/system/steam-patch.service"
# Run service
systemctl daemon-reload
systemctl enable steam-patch.service
systemctl start steam-patch.service