wip
This commit is contained in:
parent
5a010aec09
commit
deb2c57e5a
1 changed files with 82 additions and 82 deletions
164
unbox.sh
164
unbox.sh
|
@ -4,10 +4,10 @@
|
|||
source $(dirname $0)/utils.sh
|
||||
|
||||
function unbox_outer_stage(){
|
||||
echo "-----------FIRST STAGE-----------"
|
||||
|
||||
apt install git util-linux
|
||||
|
||||
echo "-----------FIRST STAGE-----------"
|
||||
|
||||
apt install git util-linux
|
||||
|
||||
if [ -e .repo_cache ]; then
|
||||
select chosen_repo in other $(cat .repo_cache | sort | uniq); do
|
||||
if [ "${chosen_repo}" = "other" ]; then
|
||||
|
@ -22,100 +22,100 @@ function unbox_outer_stage(){
|
|||
echo -n "git repository url: "
|
||||
read REMOTE
|
||||
fi
|
||||
|
||||
|
||||
echo $REMOTE
|
||||
URL_CACHE=$( ( cat .repo_cache; echo $REMOTE;) | sort | uniq )
|
||||
echo $URL_CACHE > .repo_cache
|
||||
|
||||
if [ -e repo ]; then
|
||||
(cd repo; git pull)
|
||||
else
|
||||
git clone "$REMOTE" repo
|
||||
fi
|
||||
URL_CACHE=$( ( cat .repo_cache; echo $REMOTE;) )
|
||||
for LINE in $URL_CACHE; do echo $LINE; done | sort | uniq > .repo_cache
|
||||
|
||||
if [[ ! -e repo/entry.sh ]]; then
|
||||
echo no entry found;
|
||||
exit 1;
|
||||
fi
|
||||
if [ -e repo ]; then
|
||||
(cd repo; git pull)
|
||||
else
|
||||
git clone "$REMOTE" repo
|
||||
fi
|
||||
|
||||
source repo/entry.sh
|
||||
if [[ ! -e repo/entry.sh ]]; then
|
||||
echo no entry found;
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
mkdir -p target
|
||||
export TARGET=$(pwd)/target
|
||||
export UNBOX_ENV_FILE=$(pwd)/.env
|
||||
|
||||
if [ -e .env ]; then
|
||||
rm .env
|
||||
fi
|
||||
|
||||
source repo/entry.sh
|
||||
|
||||
if type -t first_stage > /dev/null; then
|
||||
first_stage
|
||||
else
|
||||
echo first stage not found
|
||||
fi
|
||||
mkdir -p target
|
||||
export TARGET=$(pwd)/target
|
||||
export UNBOX_ENV_FILE=$(pwd)/.env
|
||||
|
||||
if [ -e .env ]; then
|
||||
rm .env
|
||||
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
|
||||
if type -t first_stage > /dev/null; then
|
||||
first_stage
|
||||
else
|
||||
echo first stage not found
|
||||
fi
|
||||
|
||||
mkdir -p target/root/unbox
|
||||
mount -o bind . target/root/unbox
|
||||
$CHROOT target /root/unbox/unbox.sh unbox_inner_stage
|
||||
|
||||
if type -t post_install_stage > /dev/null; then
|
||||
post_install_stage
|
||||
else
|
||||
echo no post_install_stage found
|
||||
fi
|
||||
if [ -e ${UNBOX_ENV_FILE} ]; then
|
||||
rm ${UNBOX_ENV_FILE}
|
||||
fi
|
||||
exit 0
|
||||
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
|
||||
|
||||
if type -t post_install_stage > /dev/null; then
|
||||
post_install_stage
|
||||
else
|
||||
echo no post_install_stage found
|
||||
fi
|
||||
if [ -e ${UNBOX_ENV_FILE} ]; then
|
||||
rm ${UNBOX_ENV_FILE}
|
||||
fi
|
||||
exit 0
|
||||
}
|
||||
|
||||
function unbox_inner_stage(){
|
||||
echo "-----------SECOND STAGE-----------"
|
||||
export UNBOX_ENV_FILE=$(pwd)/.env
|
||||
if [ -e ${UNBOX_ENV_FILE} ]; then
|
||||
source ${UNBOX_ENV_FILE}
|
||||
fi
|
||||
if [ -e repo/entry.sh ]; then
|
||||
source repo/entry.sh
|
||||
else
|
||||
echo chosen repository does not contain entry.sh file
|
||||
fi
|
||||
if type -t second_stage > /dev/null; then
|
||||
second_stage
|
||||
else
|
||||
echo second stage not found
|
||||
fi
|
||||
if [ -e ${UNBOX_ENV_FILE} ]; then
|
||||
rm ${UNBOX_ENV_FILE}
|
||||
fi
|
||||
exit 0
|
||||
echo "-----------SECOND STAGE-----------"
|
||||
export UNBOX_ENV_FILE=$(pwd)/.env
|
||||
if [ -e ${UNBOX_ENV_FILE} ]; then
|
||||
source ${UNBOX_ENV_FILE}
|
||||
fi
|
||||
if [ -e repo/entry.sh ]; then
|
||||
source repo/entry.sh
|
||||
else
|
||||
echo chosen repository does not contain entry.sh file
|
||||
fi
|
||||
if type -t second_stage > /dev/null; then
|
||||
second_stage
|
||||
else
|
||||
echo second stage not found
|
||||
fi
|
||||
if [ -e ${UNBOX_ENV_FILE} ]; then
|
||||
rm ${UNBOX_ENV_FILE}
|
||||
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
|
||||
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
|
||||
$0 unbox_outer_stage
|
||||
fi
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue