Skip to content
Draft
Show file tree
Hide file tree
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
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ The addon.d script can not be copied into `system/addon.d` since system is mount
This module will overlay a copy of the addon.d script into `system/addon.d`.<br>
<i>So it can be found and run with other addon.d script(s) during a system OTA update.</i>

<b>Note: This module only works with addon.d-v2 (A/B slot devices).</b>
<b>Note: This module only works with addon.d-v2 (A/B slot devices).</b><br>
<b>Install Magisk before installing this module.</b>

## Warning
This module is only <i>systemless</i> before the first OTA update.<br>
Expand All @@ -30,13 +31,14 @@ After the first OTA update, this module is no longer needed and can be disabled
Available in the releases tab. [Link](https://github.com/mModule/mSurvival/releases)

### Install
- Copy the zip file to the device.
- Install Magisk first (boot patch or recovery zip).
- Copy the module zip file to the device.
- Open Magisk, select Modules and then Install from storage.
- Reboot device

### Recent changes
- Validate Magisk addon.d source before copy; fail install on copy errors.
- Initial release.
- Not planned for long-term support.

### Notes
- Feel free to use, change, improve, adapt.
Expand Down
60 changes: 28 additions & 32 deletions customize.sh
Original file line number Diff line number Diff line change
@@ -1,44 +1,40 @@
#!/system/bin/sh

## Magisk OTA Survival module.
## This module will overlay Magisk's addon.d script into the system/addon.d directory if it exists.
## ipdev @ xda-developers
## Overlays Magisk's addon.d script into system/addon.d when boot-patched installs skip it.

# __ Define variables. __

### Magisk variables
## MODPATH (path): the path where your module files should be installed.

# ADB Directory
ADB=/data/adb
MAGISK_ADDON="$ADB/magisk/addon.d.sh"
MODULE_ID=MagiskSurvival
TARGET="$MODPATH/system/addon.d/99-magisk.sh"

abort_install() {
echo "! $1" >&2
echo " This module will not be installed." >&2
rm -rf "$ADB/modules_update/$MODULE_ID"
exit 1
}

# __ Define functions. __

### Magisk functions
## set_perm <target> <owner> <group> <permission> [context]

# __ Here we go. __

if [ -d /system/addon.d ]; then
# Make the module addon.d directory if it does not exist.
if [ ! -d "$MODPATH"/system/addon.d ]; then
mkdir -p "$MODPATH"/system/addon.d
else
# Remove the previous addon.d script.
rm "$MODPATH"/system/addon.d/99-magisk.sh
fi
if [ ! -d /system/addon.d ]; then
abort_install "Survival (addon.d) scripts are not supported on this ROM."
fi

# Copy the current addon.d script from magisk to the module directory.
cp "$ADB"/magisk/addon.d.sh "$MODPATH"/system/addon.d/99-magisk.sh
if [ ! -f "$MAGISK_ADDON" ]; then
abort_install "Magisk addon.d.sh not found at $MAGISK_ADDON. Install Magisk first."
fi

# Set owner, group, permission and security.
set_perm "$MODPATH"/system/addon.d/99-magisk.sh 0 0 0755 u:object_r:system_file:s0
if [ ! -d "$MODPATH/system/addon.d" ]; then
mkdir -p "$MODPATH/system/addon.d"
else
echo "Survival (addon.d) scripts are not supported."
echo " This module will not be installed."
rm -rf "$ADB"/modules_update/MagiskSurvival
exit 1
rm -f "$TARGET"
fi

# __ Finish and Cleanup. __
if ! cp "$MAGISK_ADDON" "$TARGET"; then
abort_install "Failed to copy Magisk addon.d script into module overlay."
fi

if [ ! -f "$TARGET" ]; then
abort_install "addon.d overlay script missing after copy."
fi

set_perm "$TARGET" 0 0 0755 u:object_r:system_file:s0
8 changes: 4 additions & 4 deletions mSurvival.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"versionCode": "10",
"version": "Module (v1)",
"zipUrl": "https://github.com/mModule/mSurvival/releases/download/v1/MagiskSurvival-v1.zip",
"changelog": "https://github.com/mModule/mSurvival/releases/download/v1/v1.md"
"versionCode": "11",
"version": "Module (v1.1)",
"zipUrl": "https://github.com/mModule/mSurvival/releases/download/v1.1/MagiskSurvival-v1.1.zip",
"changelog": "https://github.com/mModule/mSurvival/releases/download/v1.1/v1.1.md"
}
6 changes: 3 additions & 3 deletions module.prop
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
id=MagiskSurvival
name=Magisk Survival Script
version=Module (v1)
versionCode=10
version=Module (v1.1)
versionCode=11
author=ip
description=Magisk Survival (addon.d) script.
description=Magisk Survival (addon.d) script for boot-patched installs.
updateJson=https://raw.githubusercontent.com/mModule/mSurvival/master/mSurvival.json