diff --git a/Package/Scripts/preinstall b/Package/Scripts/preinstall index dad4d35..524e1d1 100755 --- a/Package/Scripts/preinstall +++ b/Package/Scripts/preinstall @@ -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 @@ -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 @@ -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}/"