mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-04-25 04:20:14 +10:00
AutoPkg: Modularize pre/postinstall scripts
This commit is contained in:
@@ -1,13 +1,64 @@
|
||||
#!/bin/sh
|
||||
#!/bin/zsh --no-rcs
|
||||
# ------------------------------------------------------
|
||||
# AutoPkg Assets Postinstall Script
|
||||
# ------------------------------------------------------
|
||||
# Create alias for app, start patching and reboot.
|
||||
# ------------------------------------------------------
|
||||
|
||||
# Create alias for OpenCore-Patcher.app
|
||||
if [ ! -d "/Applications/OpenCore-Patcher.app" ]; then
|
||||
ln -s "/Library/Application Support/Dortania/OpenCore-Patcher.app" "/Applications/OpenCore-Patcher.app"
|
||||
fi
|
||||
|
||||
# Start root patching
|
||||
app_path="/Library/Application Support/Dortania/OpenCore-Patcher.app/Contents/MacOS/OpenCore-Patcher"
|
||||
args="--patch_sys_vol"
|
||||
"$app_path" "$args" &> "/Users/Shared/.OCLP-AutoPatcher-Log-$(date +"%Y_%m_%d_%I_%M_%p").txt"
|
||||
log show --last boot > "/Users/Shared/.OCLP-System-Log-$(date +"%Y_%m_%d_%I_%M_%p").txt"
|
||||
reboot
|
||||
# MARK: Variables
|
||||
# ---------------------------
|
||||
|
||||
mainAppPath="/Library/Application Support/Dortania/OpenCore-Patcher.app"
|
||||
shimAppPath="/Applications/OpenCore-Patcher.app"
|
||||
executablePath="$mainAppPath/Contents/MacOS/OpenCore-Patcher"
|
||||
|
||||
|
||||
# MARK: Functions
|
||||
# ---------------------------
|
||||
|
||||
function _createAlias() {
|
||||
local mainPath=$1
|
||||
local aliasPath=$2
|
||||
|
||||
# Check if alias path exists
|
||||
if [[ -e $aliasPath ]]; then
|
||||
# Check if alias path is a symbolic link
|
||||
if [[ -L $aliasPath ]]; then
|
||||
/bin/rm -f $aliasPath
|
||||
else
|
||||
/bin/rm -rf $aliasPath
|
||||
fi
|
||||
fi
|
||||
|
||||
# Create symbolic link
|
||||
/bin/ln -s $mainPath $aliasPath
|
||||
}
|
||||
|
||||
function _startPatching() {
|
||||
local executable=$1
|
||||
local logPath=$(_logFile)
|
||||
|
||||
# Start patching
|
||||
"$executable" "--patch_sys_vol" &> $logPath
|
||||
}
|
||||
|
||||
function _logFile() {
|
||||
echo "/Users/Shared/.OCLP-AutoPatcher-Log-$(/bin/date +"%Y_%m_%d_%I_%M_%p").txt"
|
||||
}
|
||||
|
||||
function _reboot() {
|
||||
/sbin/reboot
|
||||
}
|
||||
|
||||
function _main() {
|
||||
_createAlias "$mainAppPath" "$shimAppPath"
|
||||
_startPatching "$executablePath"
|
||||
_reboot
|
||||
}
|
||||
|
||||
|
||||
# MARK: Main
|
||||
# ---------------------------
|
||||
|
||||
_main
|
||||
Reference in New Issue
Block a user