Check that DIR path is an absolute one (starts with '/')

master
Olivier DOSSMANN 2018-08-02 16:59:18 +02:00
parent c1218df6a8
commit e0e576ff0e
1 changed files with 12 additions and 4 deletions

View File

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