addon.d scripts to grow /system after installation (choose 1)
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
#!/sbin/sh | |
# | |
# /system/addon.d/10-resize-system.sh | |
# | |
. /tmp/backuptool.functions | |
case "$1" in | |
backup) | |
# Stub | |
;; | |
restore) | |
# Stub | |
;; | |
pre-backup) | |
# Stub | |
;; | |
post-backup) | |
# Stub | |
;; | |
pre-restore) | |
# exec > /tmp/grow_simple-${1}.out 2>&1 | |
# set -x | |
# set -e | |
sleep 5 | |
_syspart=/dev/block/platform/msm_sdcc.1/by-name/system | |
_syspart2="$(readlink -f "$_syspart")" | |
_parts=$(cat /proc/mounts | grep "^$_syspart\|^$_syspart2" | cut -d ' ' -f 2 | tr '\n' ' ') | |
for part in ${_parts}; do | |
umount $part || { fuser -m "$part"; echo "Failed to unmount $part" >&2; } | |
done | |
e2fsck -fy "$_syspart" || [ $? -lt 4 ] | |
/sbin/resize2fs "$_syspart" | |
e2fsck -fy "$_syspart" || [ $? -lt 4 ] | |
for part in ${_parts}; do | |
mount $_syspart $part | |
done | |
;; | |
post-restore) | |
# Stub | |
;; | |
esac |
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
#!/sbin/sh | |
# | |
# /system/addon.d/10-resize-system.sh | |
# | |
. /tmp/backuptool.functions | |
exec > /tmp/grow_simple.out 2>&1 | |
echo "Command and arguments: $@" | |
echo "Workdir: $(pwd)" | |
echo "Running from $(dirname $0)" | |
set -e | |
case "$1" in | |
backup) | |
# Stub | |
;; | |
restore) | |
# Stub | |
;; | |
pre-backup) | |
# Stub | |
;; | |
post-backup) | |
# Stub | |
;; | |
pre-restore) | |
/sbin/resize2fs /dev/block/platform/msm_sdcc.1/by-name/system | |
;; | |
post-restore) | |
# Stub | |
;; | |
esac |
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
#!/sbin/sh | |
# | |
# ADDOND_VERSION=2 | |
# | |
# /system/addon.d/00-grow_system.sh | |
# | |
# . /tmp/backuptool.functions | |
# | |
# if [ -z $backuptool_ab ]; then | |
# SYS=/system | |
# TMP=/temp | |
# else | |
# SYS=/postinstall/system | |
# TMP=/postinstall/temp | |
# fi | |
exec > /tmp/grow_system.out 2>&1 | |
echo "Command and arguments: $@" | |
echo "Workdir: $(pwd)" | |
echo "Running from $(dirname $0)" | |
_grow_exit() { | |
local _rv=$? | |
[ "$_rv" != "0" ] && { | |
echo "grow_system: Error occurred" | |
exit $_rv | |
} || { | |
echo "grow_system finished without issues" | |
} | |
} | |
trap '_grow_exit' EXIT | |
set -e | |
list_files() { | |
# nothing to daclare | |
echo | |
} | |
# false | |
# echo "should not echo" | |
# system partition block device (full path) | |
syspart=$(readlink -f /dev/block/bootdevice/by-name/system) | |
case "$1" in | |
backup) | |
# Stub | |
;; | |
restore) | |
# Stub | |
;; | |
pre-backup) | |
# Stub | |
;; | |
post-backup) | |
# Stub | |
;; | |
pre-restore) | |
{ | |
grep -q " /system " /proc/mounts | |
} && { | |
/sbin/umount /system || { | |
echo "grow_system: error unmounting /system - using lazy" | |
/sbin/umount -l /system | |
# exit 1 | |
} | |
} || { | |
echo "grow_system: /system wasn't mounted, proceeding" | |
} | |
{ | |
grep -q " /system_root " /proc/mounts | |
} && { | |
/sbin/umount /system_root || { | |
echo "grow_system: error unmounting /system_root - using lazy" | |
/sbin/umount -l /system_root | |
# exit 1 | |
} | |
} || { | |
echo "grow_system: /system wasn't mounted, proceeding" | |
} | |
{ /sbin/e2fsck -fy "$syspart" || [ "$?" -le "1" ]; } || { | |
echo "grow_system: unrecoverable error found on /system, refusing to resize" >&2 | |
exit 1 | |
} | |
resize2fs "$syspart" | |
{ e2fsck -fy "$syspart" || [ "$?" -le "1" ]; } || { | |
echo "grow_system: unrecoverable error found after resize, /system is damaged" >&2 | |
exit 1 | |
} | |
mount "$syspart" /system | |
;; | |
post-restore) | |
# Stub | |
;; | |
esac |
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
#!/sbin/sh | |
# | |
# ADDOND_VERSION=2 | |
# | |
# /system/addon.d/00-grow_system.sh | |
# | |
# . /tmp/backuptool.functions | |
# | |
# if [ -z $backuptool_ab ]; then | |
# SYS=/system | |
# TMP=/temp | |
# else | |
# SYS=/postinstall/system | |
# TMP=/postinstall/temp | |
# fi | |
# echo "Command and arguments: $0 $@" | |
# echo "Workdir: $(pwd)" | |
# echo "Running from $(dirname $0)" | |
list_files() { | |
# nothing to daclare | |
echo | |
} | |
case "$1" in | |
backup) | |
# Stub | |
;; | |
restore) | |
# Stub | |
;; | |
pre-backup) | |
# Stub | |
;; | |
post-backup) | |
# Stub | |
;; | |
pre-restore) | |
# exec > /tmp/grow_system_p.out 2>&1 | |
_payload_file="$(mktemp /tmp/growsys-XXXXXX)" | |
cat > "$_payload_file" <<-"EOF" | |
#!/sbin/sh | |
set -e | |
set -x | |
# system partition block device (full path) | |
_grow_exit() { | |
local _rv=$? | |
[ "$_rv" != "0" ] && { | |
echo "grow_system: Error occurred" | |
exit $_rv | |
} || { | |
echo "grow_system finished without issues" | |
} | |
} | |
_umount_path() { | |
{ | |
grep -q " $1 " /proc/mounts | |
} && { | |
/sbin/umount $1 || { | |
echo "grow_system: error unmounting $1" | |
exit 1 | |
} | |
} | |
} | |
trap '_grow_exit' EXIT ERR | |
# exec > /tmp/grow_system_pi.out 2>&1 | |
_syspart=$(readlink -f /dev/block/bootdevice/by-name/system) | |
_umount_path "/system" | |
_umount_path "/system_root" | |
{ /sbin/e2fsck -fy "$_syspart" || [ "$?" -le "1" ]; } || { | |
echo "grow_system: unrecoverable error found on /system, refusing to resize" >&2 | |
exit 1 | |
} | |
resize2fs "$_syspart" | |
{ e2fsck -fy "$_syspart" || [ "$?" -le "1" ]; } || { | |
echo "grow_system: unrecoverable error found after resize, /system is damaged" >&2 | |
exit 1 | |
} | |
mount "$_syspart" /system | |
EOF | |
/sbin/chmod a+x "$_payload_file" | |
exec "$_payload_file" | |
;; | |
post-restore) | |
# Stub | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment