Skip to content

Commit

Permalink
feat(installer): add argument for upgrading agent (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
bjarn authored Nov 7, 2023
1 parent d2574f0 commit cb53921
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions install-latest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ TOKEN=$1
OS=$2
ARCH=$3

if [ -z "$TOKEN" ]; then
CHECK_UPGRADE=$4

if [ -z "$TOKEN" ] && [ "$CHECK_UPGRADE" != "--upgrade" ]; then
echo "Missing token"
exit 1
fi
Expand Down Expand Up @@ -49,25 +51,36 @@ echo -n "Making spectated executable... "
chmod +x /usr/bin/spectated
echo "done"

# Install service
echo -n "Installing spectated as service... "
/usr/bin/spectated install
echo "done"
if [[ "$CHECK_UPGRADE" != "--upgrade" ]]; then
# Install service
echo -n "Installing spectated as service... "
/usr/bin/spectated install
echo "done"

# Run auth command
echo -n "Registering this host in Spectate... "
/usr/bin/spectated auth "$TOKEN"
echo "done"
# Run auth command
echo -n "Registering this host in Spectate... "
/usr/bin/spectated auth "$TOKEN"
echo "done"
fi

# Start service
# Start or Restart service
echo -n "Starting spectated service... "
if [[ "$OS" == "linux" ]]; then
if [[ -x "$(command -v systemctl)" ]]; then
systemctl start spectated
if [[ "$CHECK_UPGRADE" == "--upgrade" ]]; then
systemctl restart spectated
else
systemctl start spectated
fi
else
service spectated start
if [[ "$CHECK_UPGRADE" == "--upgrade" ]]; then
service spectated restart
else
service spectated start
fi
fi
elif [[ "$OS" == "darwin" ]]; then
launchctl unload -w ~/Library/LaunchAgents/spectated.plist
launchctl load -w ~/Library/LaunchAgents/spectated.plist
fi
echo "done"

0 comments on commit cb53921

Please sign in to comment.