Change variable to something more readable and more short

This commit is contained in:
Olivier DOSSMANN 2018-08-02 17:08:41 +02:00
parent e0e576ff0e
commit 6d93d48059
2 changed files with 11 additions and 10 deletions

View File

@ -22,7 +22,7 @@ But you can change destination directory if needed:
```bash
chmod +x ./install-and-chroot.sh
DIR="/my_alpine_chroot" ./install-and-chroot.sh
DIRPATH="/my_alpine_chroot" ./install-and-chroot.sh
```
and then:
@ -31,6 +31,8 @@ and then:
/my_alpine_chroot/enter-chroot
```
Pay attention: DIRPATH should be an absolute path.
# TODO
* adapt script to install yunoconfig dependencies (alpine-chroot-install -p)

View File

@ -1,25 +1,24 @@
#!/usr/bin/env sh
alpine_install=${INSTALL:-'alpine-chroot-install'}
alpine_directory=${DIR:-'/alpine'}
SCRIPT=${SCRIPTNAME:-'alpine-chroot-install'}
DIR=${DIRPATH:-'/alpine'}
# Tests
DIR="${alpine_directory}"
if ! [[ $DIR == /* ]]; then
echo "DIR is not an absolute URL. It should start with a '/'" && exit 1
echo "DIRPATH 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" \
&& echo 'e5dfbbdc0c4b3363b99334510976c86bfa6cb251 alpine-chroot-install' | sha1sum -c \
if ! test -f "$SCRIPT"; then
wget https://raw.githubusercontent.com/alpinelinux/alpine-chroot-install/v0.9.0/alpine-chroot-install -O "$SCRIPT" \
&& echo "e5dfbbdc0c4b3363b99334510976c86bfa6cb251 ${SCRIPT}" | sha1sum -c \
|| exit 1
chmod +x "$alpine_install"
chmod +x "$SCRIPT"
fi
# Install Alpine
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
sudo sh ./$SCRIPT -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