Make original setup backward compatible, do not require explicit path to

list of files.
This commit is contained in:
Petr Menšík 2018-07-31 20:14:21 +02:00
parent a38c250807
commit 3fdc82d222

View File

@ -1,22 +1,21 @@
#!/bin/bash
ROOTDIR="$1"
CONFIG_FILES="${3:-/etc/named-chroot.files}"
usage()
{
echo
echo 'This script setups chroot environment for BIND'
echo 'Usage: setup-named-chroot.sh ROOTDIR <on|off> <config.files>'
echo 'Usage: setup-named-chroot.sh ROOTDIR <on|off> [chroot.files]'
}
if ! [ "$#" -eq 3 ]; then
if ! [ "$#" -ge 2 -a "$#" -le 3 ]; then
echo 'Wrong number of arguments'
usage
exit 1
fi
ROOTDIR="$1"
CONFIG_FILES="$3"
# Exit if ROOTDIR doesn't exist
if ! [ -d "$ROOTDIR" ]; then
echo "Root directory $ROOTDIR doesn't exist"
@ -24,6 +23,12 @@ if ! [ -d "$ROOTDIR" ]; then
exit 1
fi
if ! [ -r "$CONFIG_FILES" ]; then
echo "Files list $CONFIG_FILES doesn't exist" 2>&1
usage
exit 1
fi
dev_create()
{
DEVNAME="$ROOTDIR/dev/$1"