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