[Android Software/Hacking General [Developers Only]] Beakhole:
So that's a quote from your Odds and Ends thread from earlier today. I'm not actually a developer so please forgive my major ignorance. I'm just trying to create a flashable zip that places a script file to /su/su.d. You said that I didn't mount /su at all and you told me to use your /su mounting scripting in the second post on this thread. So I don't know if I implemented it right in the below update-binary.

#!/sbin/sh
# Shell Script EDIFY Replacement: Recovery Flashable Zip
# osm0sis @ xda-developers

OUTFD=/proc/self/fd/$2;
ZIPFILE="$3";
DIR=$(dirname "$ZIPFILE");

# ui_print "<message>" ["<message 2>" ...]
ui_print() {
until [ ! "$1" ]; do
echo -e "ui_print $1\nui_print" >> $OUTFD;
shift;
done;
}
# show_progress <amount> <time>
show_progress() { echo "progress $1 $2" >> $OUTFD; }
# set_progress <amount>
set_progress() { echo "set_progress $1" >> $OUTFD; }

# sleep <seconds> exists in shell

# is_substring <substring> <string>
is_substring() {
case "$2" in
*$1*) echo 1;;
*) echo 0;;
esac;
}
# less_than_int <x> <y>
less_than_int() { test $1 -lt $2 && echo 1 || echo 0; }
# greater_than_int <x> <y>
greater_than_int() { test $1 -gt $2 && echo 1 || echo 0; }

# format(fs_type, partition_type, device, fs_size, mountpoint) {} is unneeded since specific format/wipe commands may be run directly
# mount <partition> exists in shell
# unmount <partition>
unmount() { umount "$1"; }
# is_mounted <partition>
is_mounted() {
case `mount` in
*" $1 "*) echo 1;;
*) echo 0;;
esac;
}
# tune2fs(device[, arg, …]) {} should be done directly with the tune2fs command

# write_raw_image <file> <block>
write_raw_image() { dd if="$1" of="$2"; }
# write_firmware_image() {} is a manufacturer command to apply further OEM update zips with hboot/uboot functions, so can't be duplicated
# wipe_block_device(block_dev, len) {} should be done directly with dd or nanderase
# wipe_cache() {} should be done directly with format or rm -rf

# package_extract_file <file> <destination_file>
package_extract_file() { mkdir -p "$(dirname "$2")"; unzip -o "$ZIPFILE" "$1" -p > "$2"; }
# package_extract_dir <dir> <destination_dir>
package_extract_dir() {
for entry in $(unzip -l "$ZIPFILE" "$1/*" 2>/dev/null | tail -n+4 | grep -o " $1.*$" | cut -c2-); do
outfile="$(echo "$entry" | sed "s|${1}|${2}|")";
mkdir -p "$(dirname "$outfile")";
unzip -o "$ZIPFILE" "$entry" -p > "$outfile";
done;
}

# rename <file> <destination_file>
rename() { mv -f "$1" "$2"; }

# delete <file> [<file2> ...]
delete() { rm -f "$@"; }
# delete_recursive <dir> [<dir2> ...]
delete_recursive() { rm -rf "$@"; }

# symlink <file/dir> <link> [<link2> ...]
symlink() { ln -s "$@"; }

# set_metadata <file> <uid|gid|mode|capabilities|selabel> <value> [<uid|gid|mode|capabilities|selabel_2> <value2> ...]
set_metadata() {
file="$1";
shift;
until [ ! "$2" ]; do
case $1 in
uid) chown $2 "$file";;
gid) chown :$2 "$file";;
mode) chmod $2 "$file";;
capabilities) twrp setcap $2 "$file";;
selabel)
for i in /system/bin/toybox /system/toolbox /system/bin/toolbox; do
LD_LIBRARY_PATH=/system/lib $i chcon -h $2 "$file" || LD_LIBRARY_PATH=/system/lib $i chcon $2 "$file";
done || chcon -h $2 "$file" || chcon $2 "$file";
;;
*) ;;
esac;
shift 2;
done;
}
# set_metadata_recursive <dir> <uid|gid|dmode|fmode|capabilities|selabel> <value> [<uid|gid|dmode|fmode|capabilities|selabel_2> <value2> ...]
set_metadata_recursive() {
dir="$1";
shift;
until [ ! "$2" ]; do
case $1 in
uid) chown -R $2 "$dir";;
gid) chown -R :$2 "$dir";;
dmode) find "$dir" -type d -exec chmod $2 {} +;;
fmode) find "$dir" -type f -exec chmod $2 {} +;;
capabilities) find "$dir" -exec twrp setcap $2 {} +;;
selabel)
for i in /system/bin/toybox /system/toolbox /system/bin/toolbox; do
find "$dir" -exec LD_LIBRARY_PATH=/system/lib $i chcon -h $2 {} + || find "$dir" -exec LD_LIBRARY_PATH=/system/lib $i chcon $2 {} +;
done || find "$dir" -exec chcon -h $2 '{}' + || find "$dir" -exec chcon $2 '{}' +;
;;
*) ;;
esac;
shift 2;
done;
}

# set_perm <owner> <group> <mode> <file> [<file2> ...]
set_perm() {
uid=$1; gid=$2; mod=$3;
shift 3;
chown $uid:$gid "$@" || chown $uid.$gid "$@";
chmod $mod "$@";
}
# set_perm_recursive <owner> <group> <dir_mode> <file_mode> <dir> [<dir2> ...]
set_perm_recursive() {
uid=$1; gid=$2; dmod=$3; fmod=$4;
shift 4;
until [ ! "$1" ]; do
chown -R $uid:$gid "$1" || chown -R $uid.$gid "$1";
find "$1" -type d -exec chmod $dmod {} +;
find "$1" -type f -exec chmod $fmod {} +;
shift;
done;
}

# ch_con <context> <file> [<file2> ...]
ch_con() {
con=$1;
shift;
for i in /system/bin/toybox /system/toolbox /system/bin/toolbox; do
LD_LIBRARY_PATH=/system/lib $i chcon -h u:object_r:$con:s0 "$@" || LD_LIBRARY_PATH=/system/lib $i chcon u:object_r:$con:s0 "$@";
done || chcon -h u:object_r:$con:s0 "$@" || chcon u:object_r:$con:s0 "$@";
}
# ch_con_recursive <dir_context> <file_context> <dir> [<dir2> ...]
ch_con_recursive() {
dcon=$1; fcon=$2;
shift 2;
until [ ! "$1" ]; do
for i in /system/bin/toybox /system/toolbox /system/bin/toolbox; do
find "$1" -type d -exec LD_LIBRARY_PATH=/system/lib $i chcon -h u:object_r:$dcon:s0 {} + || find "$1" -type d -exec LD_LIBRARY_PATH=/system/lib $i chcon u:object_r:$dcon:s0 {} +;
find "$1" -type f -exec LD_LIBRARY_PATH=/system/lib $i chcon -h u:object_r:$fcon:s0 {} + || find "$1" -type f -exec LD_LIBRARY_PATH=/system/lib $i chcon u:object_r:$fcon:s0 {} +;
done || ( find "$1" -type d -exec chcon -h u:object_r:$dcon:s0 '{}' + || find "$1" -type d -exec chcon u:object_r:$dcon:s0 '{}' + ) || ( find "$1" -type f -exec chcon -h u:object_r:$fcon:s0 '{}' + || find "$1" -type f -exec chcon u:object_r:$fcon:s0 '{}' + );
shift;
done;
}
# restore_con <file/dir> [<file2/dir2> ...]
restore_con() {
for i in /system/bin/toybox /system/toolbox /system/bin/toolbox; do
LD_LIBRARY_PATH=/system/lib $i restorecon -R "$@";
done || restorecon -R "$@";
}

# read_file(filename) {} is unneeded since file contents can be read directly with the cat command
# concat(expr[, expr, ...]) {} is unneeded since string operations can be done directly
# stdout(expr[, expr, ...]) {} is unneeded since all output goes to stdout by default

# file_getprop <file> <property>
file_getprop() { grep "^$2" "$1" | head -n1 | cut -d= -f2; }
# getprop <property>
getprop() { test -e /sbin/getprop && /sbin/getprop $1 || grep "^$1" /default.prop | head -n1 | cut -d= -f2; }

# sha1_check <file> [<sha1_hex> [<sha1_hex2> ...]]
sha1_check() {
sum=$(sha1sum $1 | cut -d -f1);
if [ ! "$2" -o $(is_substring $sum "$*") == 1 ]; then
echo $sum;
fi;
}

# apply_patch <src_file> <tgt_file> <tgt_sha1> <tgt_size> [<src_sha1_1>:<patch1> [<src_sha1_2>:<patch2> ...]]
apply_patch() {
LD_LIBRARY_PATH=/system/lib applypatch "$@";
}
# apply_patch_check <file> [<sha1_hex> [<sha1_hex2> ...]]
apply_patch_check() {
LD_LIBRARY_PATH=/system/lib applypatch -c "$@";
}
# apply_patch_space <bytes>
apply_patch_space() {
LIBRARY_PATH=/system/lib applypatch -s $1;
}

# run_program(program) {} is unneeded since programs may be run directly

# abort [<message>]
abort() { ui_print "$*"; exit 1; }
# assert "<command>" ["<command2>"]
assert() {
until [ ! "$1" ]; do
$1;
test $? == 1 && abort 'assert failed('"$1"')';
shift;
done;
}

# backup_files <file> [<file2> ...]
backup_files() {
until [ ! "$1" ]; do
test ! -e "$1.bak" && cp -pf "$1" "$1.bak";
shift;
done;
}
# restore_files <file> [<file2> ...]
restore_files() {
until [ ! "$1" ]; do
mv -f "${1}.bak" "$1";
shift;
done;
}

mount /data;
mount /cache;
suimg=$(ls /cache/su.img /data/su.img 2>/dev/null);
if [ "$suimg" ]; then
umount /su;
test ! -e /su && mkdir /su;
mount -t ext4 -o rw,noatime $suimg /su;
for i in 0 1 2 3 4 5 6 7; do
case `mount` in
*" /su "*) break;;
esac;
loop=/dev/block/loop$i;
mknod $loop b 7 $i;
if [ ! -f "$loop" -o ! -b "$loop" ]; then
mknod $loop b 7 $i;
fi;
losetup $loop $suimg && mount -t ext4 -o loop $loop /su;
done;
test -d /su/xbin && target=/su/xbin || target=/su/bin;
else
mount -o rw,remount /system;
target=/system/xbin;
fi;

ui_print " Flashing kernel gestures... ";
package_extract_dir su;
set_perm 0 0 0755 /su/su.d/ZZZ-Kernel-Gestures;
ui_print " --- DONE!!! --- ";

Like I said I don't really know what I'm doing so please be nice to me.