initial commit

This commit is contained in:
j3d1 2020-01-28 14:40:30 +01:00
commit ffdfeb2f29
3 changed files with 98 additions and 0 deletions

86
unbox/unbox.sh Executable file
View file

@ -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 $?

3
unbox/update_mode.sh Executable file
View file

@ -0,0 +1,3 @@
#!/bin/bash
mount -o remount,rw /
mount -o bind /opt/root /root

9
unbox/work_mode.sh Executable file
View file

@ -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