Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix preinstall items #39

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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