90 lines
1.6 KiB
Bash
Executable file
90 lines
1.6 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
function unbox_outer_stage(){
|
|
echo "-----------FIRST STAGE-----------"
|
|
|
|
apt install git dialog
|
|
|
|
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
|
|
git pull
|
|
$0 unbox_outer_stage
|
|
fi
|
|
|
|
exit 0
|
|
|
|
|
|
|
|
type -t ls
|
|
echo $?
|
|
type -t echo
|
|
echo $?
|
|
type -t third_stage
|
|
echo $?
|
|
|
|
|