mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-06-21 06:30:52 +10:00
AutoPkg: Modularize pre/postinstall scripts
This commit is contained in:
@@ -12,6 +12,10 @@
|
|||||||
- Resolve unpatching Nvidia Web Drivers failing to clean up `/Library/Extensions`
|
- Resolve unpatching Nvidia Web Drivers failing to clean up `/Library/Extensions`
|
||||||
- Implement preflight code signature checks for macOS installer creation
|
- Implement preflight code signature checks for macOS installer creation
|
||||||
- Ensures validity of `createinstallmedia` binary before execution
|
- Ensures validity of `createinstallmedia` binary before execution
|
||||||
|
- Modularize AutoPkg's pre/postinstall scripts
|
||||||
|
- Adjusted to use functions for better readability
|
||||||
|
- Implements ZSH shebang
|
||||||
|
- Removes OS logging
|
||||||
|
|
||||||
## 1.4.3
|
## 1.4.3
|
||||||
- Update non-Metal Binaries for macOS Sonoma:
|
- Update non-Metal Binaries for macOS Sonoma:
|
||||||
|
|||||||
@@ -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
|
# MARK: Variables
|
||||||
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"
|
mainAppPath="/Library/Application Support/Dortania/OpenCore-Patcher.app"
|
||||||
log show --last boot > "/Users/Shared/.OCLP-System-Log-$(date +"%Y_%m_%d_%I_%M_%p").txt"
|
shimAppPath="/Applications/OpenCore-Patcher.app"
|
||||||
reboot
|
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
|
||||||
@@ -1,12 +1,64 @@
|
|||||||
#!/bin/sh
|
#!/bin/zsh --no-rcs
|
||||||
app_path="/Library/Application Support/Dortania/OpenCore-Patcher.app"
|
# ------------------------------------------------------
|
||||||
launch_agent_path="/Library/LaunchAgents/com.dortania.opencore-legacy-patcher.auto-patch.plist"
|
# AutoPkg Assets Preinstall Script
|
||||||
if [ -d "$app_path" ]; then
|
# ------------------------------------------------------
|
||||||
echo "Found OpenCore-Patcher.app, removing..."
|
# Remove old files, and prepare directories.
|
||||||
rm -rf "$app_path"
|
# ------------------------------------------------------
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -f "$launch_agent_path" ]; then
|
|
||||||
echo "Found launch agent, removing..."
|
# MARK: Variables
|
||||||
rm -f "$launch_agent_path"
|
# ---------------------------
|
||||||
fi
|
|
||||||
|
filesToRemove=(
|
||||||
|
"/Applications/OpenCore-Patcher.app"
|
||||||
|
"/Library/Application Support/Dortania/Update.plist"
|
||||||
|
"/Library/Application Support/Dortania/OpenCore-Patcher.app"
|
||||||
|
"/Library/LaunchAgents/com.dortania.opencore-legacy-patcher.auto-patch.plist"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# MARK: Functions
|
||||||
|
# ---------------------------
|
||||||
|
|
||||||
|
function _removeFile() {
|
||||||
|
local currentFile=$1
|
||||||
|
|
||||||
|
if [[ ! -e $currentFile ]]; then
|
||||||
|
# Check if file is a symbolic link
|
||||||
|
if [[ -L $currentFile ]]; then
|
||||||
|
/bin/rm -f $currentFile
|
||||||
|
fi
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if file is a directory
|
||||||
|
if [[ -d $currentFile ]]; then
|
||||||
|
/bin/rm -rf $currentFile
|
||||||
|
else
|
||||||
|
/bin/rm -f $currentFile
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function _createParentDirectory() {
|
||||||
|
local currentFile=$1
|
||||||
|
|
||||||
|
local parentDirectory=$(/usr/bin/dirname $currentFile)
|
||||||
|
|
||||||
|
# Check if parent directory exists
|
||||||
|
if [[ ! -d $parentDirectory ]]; then
|
||||||
|
/bin/mkdir -p $parentDirectory
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function _main() {
|
||||||
|
for file in $filesToRemove; do
|
||||||
|
_removeFile $file
|
||||||
|
_createParentDirectory $file
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# MARK: Main
|
||||||
|
# ---------------------------
|
||||||
|
|
||||||
|
_main
|
||||||
Reference in New Issue
Block a user