Skip to content

Commit

Permalink
Merge pull request #39 from WardsParadox/main
Browse files Browse the repository at this point in the history
Fix preinstall items
  • Loading branch information
bartreardon authored Oct 26, 2023
2 parents 532e629 + feb75cc commit 457c116
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions Package/Scripts/preinstall
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/sh
#!/bin/zsh

# preinstall.sh
# Outset
#
# Created by Bart Reardon on 25/3/2023.
#
#

## Process legacy launchd items if upgrading from outset 3.0.3 or earlier

Expand All @@ -13,35 +13,35 @@ LA_ROOT="/Library/LaunchAgents"
OUTSET_ROOT="/usr/local/outset"
OUTSET_BACKUP="${OUTSET_ROOT}/backup"

USER_ID=$(id -u $(stat -f %Su /dev/console))
USER_ID=$(id -u "$(/usr/bin/stat -f %Su /dev/console)")

## LaunchDaemons
DAEMONS=(
"${LD_ROOT}/com.github.outset.boot.plist"
"${LD_ROOT}/com.github.outset.cleanup.plist"
"${LD_ROOT}/com.github.outset.login-privileged.plist"
"${LD_ROOT}/com.github.outset.boot.plist"
"${LD_ROOT}/com.github.outset.cleanup.plist"
"${LD_ROOT}/com.github.outset.login-privileged.plist"
)

## LaunchAgents
AGENTS=(
"${LA_ROOT}/com.github.outset.login.plist"
"${LA_ROOT}/com.github.outset.on-demand.plist"
"${LA_ROOT}/com.github.outset.login.plist"
"${LA_ROOT}/com.github.outset.on-demand.plist"
)

# Unload if present
for daemon in ${DAEMONS[@]}; do
for daemon in $DAEMONS; do
if [ -e "${daemon}" ]; then
/bin/launchctl bootout system "${daemon}"
sudo rm -fv "${daemon}"
rm -fv "${daemon}"
fi
done

for agent in ${AGENTS[@]}; do
for agent in $AGENTS; do
if [ -e "${agent}" ]; then
if [ ${USER_ID} -ne 0 ]; then
launchctl bootout gui/${USER_ID} "${agent}"
/bin/launchctl bootout gui/${USER_ID} "${agent}"
fi
sudo rm -fv "${agent}"
rm -fv "${agent}"
fi
done

Expand All @@ -52,7 +52,7 @@ if [ -d "${OUTSET_ROOT}/share" ]; then
cp ${OUTSET_ROOT}/share/* "${OUTSET_BACKUP}/"
fi

for user in $(ls /Users); do
for user in /Users/*; do
if [ -e "/Users/${user}/Library/Preferences/com.github.outset.once.plist" ]; then
mkdir -p "${OUTSET_ROOT}/backup/${user}"
cp "/Users/${user}/Library/Preferences/com.github.outset.once.plist" "${OUTSET_BACKUP}/${user}/"
Expand Down

0 comments on commit 457c116

Please sign in to comment.