diff --git a/install-and-chroot.sh b/install-and-chroot.sh index 7e4278d..3baf32f 100755 --- a/install-and-chroot.sh +++ b/install-and-chroot.sh @@ -3,6 +3,12 @@ alpine_install=${INSTALL:-'alpine-chroot-install'} alpine_directory=${DIR:-'/alpine'} +# Tests +DIR="${alpine_directory}" +if ! [[ $DIR == /* ]]; then + echo "DIR is not an absolute URL. It should start with a '/'" && exit 1 +fi + # DL alpine install script if ! test -f "$alpine_install"; then wget https://raw.githubusercontent.com/alpinelinux/alpine-chroot-install/v0.9.0/alpine-chroot-install -O "$alpine_install" \ @@ -12,12 +18,14 @@ if ! test -f "$alpine_install"; then fi # Install Alpine -if ! test -d "$alpine_directory"; then - sudo sh ./$alpine_install -d $alpine_directory -p build-base -p git -p zsh -p lua-filesystem -p luarocks5.1 -p lua-toml -p moonscript -p abuild -p lua-argparse || exit 1 +if ! test -d "$DIR"; then + sudo sh ./$alpine_install -d $DIR -p build-base -p git -p zsh -p lua-filesystem -p luarocks5.1 -p lua-toml -p moonscript -p abuild -p lua-argparse || exit 1 fi # Set rc_sys="prefix" to not disturb systemd on current system -sudo sed -e 's/#rc_sys=""/rc_sys="prefix"/g' -i "$alpine_directory/etc/rc.conf" +sudo sed -e 's/#rc_sys=""/rc_sys="prefix"/g' -i "$DIR/etc/rc.conf" # Launch chroot -sh $alpine_directory/enter-chroot ./build +sh $DIR/enter-chroot ./build + +exit 0