#!/bin/sh # # Launcher for 'portable' Iron browser # HERE="$(dirname "$(readlink -f "$0")")" IRON_DIR="${HERE}/iron32" SFS_Target=/initrd/mnt/tmpfs/Iron-portable32.sfs if [ ls -A iron32 ]; then echo "Directory iron32 already mounted" >&2 else if [ ! -d /initrd/mnt/tmpfs/iron32-profile/PROFILE ]; then mkdir -p /initrd/mnt/tmpfs/iron32-profile/PROFILE/ cp -rf iron32-dir/PROFILE/ /initrd/mnt/tmpfs/iron32-profile/ fi if [ ! -e /initrd/mnt/tmpfs/Iron-portable32.sfs ]; then cp Iron-portable32.sfs "$SFS_Target" fi append_mnt_id_awk=' function get_mnt_id(mnt_pt,loop){ if (length(mnt_pt) > 0 && length(loop)>0){ cmd="cat /proc/self/mountinfo | sort | grep '" loop "' | grep " mnt_pt " | head -n 1" } else if (length(mnt_pt) > 0){ cmd="cat /proc/self/mountinfo | sort | grep '" mnt_pt "' | head -n 1" } else if (length(loop)>0){ cmd="cat /proc/self/mountinfo | sort | grep '" loop "' | head -n 1" } while ((cmd | getline )){ mnt_id=$1 break } close(cmd) return mnt_id } { mnt_pt=$1 loop=$2 mnt_id=get_mnt_id(mnt_pt,loop) print mnt_id "|" mnt_pt "|" loop }' loop=$(losetup -a | grep /initrd/mnt/tmpfs/Iron-portable32.sfs | sed "s/:.*$//" ) if [ ! -z "$loop" ]; then # sfs_MP="$(findmnt -o TARGET,SOURCE -D -n | grep $loop\$ | awk "$append_mnt_id_awk" | sort -t '|' -k1 | cut -d'|' -f2 | head -n 1)" fi if [ -z "$sfs_MP" ]; then mkdir -p /initrd/mnt/tmpfs/Iron-portable32 sfs_MP=/initrd/mnt/tmpfs/Iron-portable32 fi mkdir -p "$sfs_MP" if [ ! "`ls -A "$sfs_MP"`" ]; then mount -r -t squashfs "$SFS_Target" "$sfs_MP" fi BRANCHES=/initrd/mnt/tmpfs/iron32-profile:"$sfs_MP" mkdir -p "$IRON_DIR" mount -t aufs -o br="$BRANCHES" aufs "$IRON_DIR" fi # "$IRON_DIR/iron-pup" "$@"