forked from dortania/OpenCore-Legacy-Patcher
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AutoPkg: Modularize pre/postinstall scripts
- Loading branch information
1 parent
23146d7
commit f7bcb26
Showing
3 changed files
with
132 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,64 @@ | ||
#!/bin/sh | ||
|
||
# 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 | ||
#!/bin/zsh --no-rcs | ||
# ------------------------------------------------------ | ||
# AutoPkg Assets Postinstall Script | ||
# ------------------------------------------------------ | ||
# Create alias for app, start patching and 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,64 @@ | ||
#!/bin/sh | ||
app_path="/Library/Application Support/Dortania/OpenCore-Patcher.app" | ||
launch_agent_path="/Library/LaunchAgents/com.dortania.opencore-legacy-patcher.auto-patch.plist" | ||
if [ -d "$app_path" ]; then | ||
echo "Found OpenCore-Patcher.app, removing..." | ||
rm -rf "$app_path" | ||
fi | ||
|
||
if [ -f "$launch_agent_path" ]; then | ||
echo "Found launch agent, removing..." | ||
rm -f "$launch_agent_path" | ||
fi | ||
#!/bin/zsh --no-rcs | ||
# ------------------------------------------------------ | ||
# AutoPkg Assets Preinstall Script | ||
# ------------------------------------------------------ | ||
# Remove old files, and prepare directories. | ||
# ------------------------------------------------------ | ||
|
||
|
||
# MARK: Variables | ||
# --------------------------- | ||
|
||
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 |