Skip to content

Commit

Permalink
New installer from StudioGoin
Browse files Browse the repository at this point in the history
  • Loading branch information
JustTemmie committed Aug 5, 2023
2 parents 34a6fb8 + a14c80e commit 75359e3
Showing 1 changed file with 15 additions and 34 deletions.
49 changes: 15 additions & 34 deletions installer.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/bin/bash
#!/usr/bin/env bash

echo "This script is LINUX ONLY, and it's still in testing phases, if you encounter any bugs please open an issue"
read -p "Press the enter key to continue..."
echo ""


# Check if script is running as root
if [ "$(id -u)" == "0" ]; then
if [ `whoami` == "root" ]; then
echo "This script cannot be run as root. Please run as a regular user"
exit 1
fi
Expand All @@ -19,13 +19,6 @@ if [ ! -f "config.json" ]; then
exit 1
fi

# Create steam-presence folder if it does not exist
if [ ! -d "$HOME/steam-presence" ]; then
mkdir -p "$HOME/steam-presence"
fi

echo "Creating symlinks of necessary files..."

# Create games.txt if it doesn't exist
if [ ! -e "$(pwd)/games.txt" ]; then
echo "creating games.txt"
Expand All @@ -44,44 +37,32 @@ if [ ! -e "$(pwd)/customGameIDs.json" ]; then
echo "{}" > "$(pwd)/customGameIDs.json"
fi


# Create symlinks of necessary files
ln -s "$(pwd)/main.py" "$HOME/steam-presence/main.py"
ln -s "$(pwd)/requirements.txt" "$HOME/steam-presence/requirements.txt"
ln -s "$(pwd)/steam-presence.service" "$HOME/steam-presence/steam-presence.service"
ln -s "$(pwd)/config.json" "$HOME/steam-presence/config.json"
ln -s "$(pwd)/games.txt" "$HOME/steam-presence/games.txt"
ln -s "$(pwd)/icons.txt" "$HOME/steam-presence/icons.txt"
ln -s "$(pwd)/customGameIDs.json" "$HOME/steam-presence/customGameIDs.json"

echo "Symlinks created."

# Change to steam-presence directory
cd "$HOME/steam-presence"

echo "Executing commands in steam-presence directory..."

# Execute commands in steam-presence directory
echo "Setting up virtual environment"
mkdir venv
cd venv
python3 -m venv .
./bin/python -m pip install --upgrade pip wheel
./bin/python -m pip install -r requirements.txt
./bin/python -m pip install -r ../requirements.txt
cd ..

echo ""
echo "Testing if the script works"
echo ""

timeout 2.5s ./bin/python ./main.py
timeout 2.5s ./venv/bin/python ./main.py

echo "Test might've worked, did it spit out any errors?"
echo "Commands executed."

# Replace "deck" user with local username in steam-presence.service file
echo "Editing service file"
local_username=$(whoami)
sed -i "s/deck/$local_username/g" "$HOME/steam-presence/steam-presence.service"
# Turn steam-presence/bin/python into steam-presence/venv/bin/python and replace "/home/deck" with current directory in steam-presence.service file
echo "Setting up service file"
mkdir -p "$HOME/.config/systemd/user"
sed -e "s~steam-presence/bin/python~steam-presence/venv/bin/python~g" -e "s~/home/deck/steam-presence~$PWD~g" "$PWD/steam-presence.service" > $HOME/.config/systemd/user/steam-presence.service


echo "Starting service"
systemctl --user --now enable "$HOME/steam-presence/steam-presence.service"
systemctl --user daemon-reload
systemctl --user --now enable "steam-presence.service"

echo "If you encountered any errors with this script, please create an issue on the GitHub page"
echo ""
Expand Down

0 comments on commit 75359e3

Please sign in to comment.