Follow

.sh

CONTAINER=/sdcard/luks.img
SH_PATH=$(dirname "$0")

set -e

# Check if root
if [ $(id -u) != 0 ]; then
echo "Aborting: This script needs root."
exit 1
fi

# Try to open container
if [ ! -b /dev/mapper/luks ]; then
echo "Opening luks container: $CONTAINER"
cryptsetup open $CONTAINER luks
else
echo "Container already open, skipped cryptsetup..."
fi

# Mounting
echo "Entering namespace of init process"
nsenter -t 1 -m bash < $SH_PATH/mounts.sh

echo "DONE"

#--------------------------------------------------------------------------

.sh

MOUNT=/mnt/runtime/write/emulated/0/luks
BIND=('a' 'aa')

set -e

echo "Mounting to: $MOUNT"
mkdir -p $MOUNT
mount -t exfat -o context=u:object_r:sdcardfs:s0,uid=0,gid=1015,fmask=0000,dmask=0000 /dev/mapper/luks $MOUNT
echo "Mount done!"

cd /mnt/runtime/write/emulated/0/
for dir in ${BIND[@]}; do
echo "Bind mounting to: $dir"
mkdir -p $dir
mount -o bind $MOUNT/$dir $dir
done

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.