commit ffdfeb2f29640f567f77e541fb4e44d50d77d56d Author: jedi Date: Tue Jan 28 14:40:30 2020 +0100 initial commit diff --git a/unbox/unbox.sh b/unbox/unbox.sh new file mode 100755 index 0000000..fbf2020 --- /dev/null +++ b/unbox/unbox.sh @@ -0,0 +1,86 @@ +#!/bin/bash + +function unbox_outer_stage(){ + echo "-----------FIRST STAGE-----------" + if [ -e repo ]; then + (cd repo; git pull) + else + #git clone https://github.com/jed1/laptop-scripts.git + git clone https://github.com/busti/pt-surface.git repo + fi + + if [[ ! -e repo/entry.sh ]]; then + echo no entry found; + exit 1; + fi + + source repo/entry.sh + + mkdir -p target + + if type -t first_stage > /dev/null; then + export TARGET=$(pwd)/target + first_stage + else + echo first stage not found + fi + + if type -t chroot > /dev/null; then + #if type -t arch-chroot > /dev/null; then + # CHROOT=arch-chroot + #else + CHROOT=chroot + #fi + else + echo ERROR: no chroot found 1>&2 + exit 1 + fi + + mkdir -p target/root/unbox + mount -o bind . target/root/unbox + $CHROOT target /root/unbox/unbox.sh unbox_inner_stage + sleep 0.5 + mount | grep target | awk '{print $3}'| sort -r | while read LINE; do + umount -l $LINE; + done + exit 0 +} + +function unbox_inner_stage(){ + echo "-----------SECOND STAGE-----------" + #echo $@ + source repo/entry.sh + if type -t second_stage > /dev/null; then + second_stage + else + echo second stage not found + fi + exit 0 +} + +cd $(dirname $0) +if [[ $# -ge 1 ]]; then + CMD=$1 + shift + if type -t $CMD > /dev/null; then + $CMD $@ + else + echo command $CMD found + exit 1 + fi +else + unbox_outer_stage +fi + +exit 0 + + + +type -t ls +echo $? +type -t echo +echo $? +type -t third_stage +echo $? + + diff --git a/unbox/update_mode.sh b/unbox/update_mode.sh new file mode 100755 index 0000000..e84bb7a --- /dev/null +++ b/unbox/update_mode.sh @@ -0,0 +1,3 @@ +#!/bin/bash +mount -o remount,rw / +mount -o bind /opt/root /root diff --git a/unbox/work_mode.sh b/unbox/work_mode.sh new file mode 100755 index 0000000..d76950c --- /dev/null +++ b/unbox/work_mode.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -e +cd / +mkdir -p /mnt/tmp +mount -t tmpfs none /mnt/tmp +mkdir -p /mnt/tmp/upper +mkdir -p /mnt/tmp/work +mount -t overlay overlay -o lowerdir=/opt/root,upperdir=/mnt/tmp/upper,workdir=/mnt/tmp/work /root +cd /root