From 3fdc82d2224b1c935a611dba27a093dda50a64a5 Mon Sep 17 00:00:00 2001 From: Petr Menšík Date: Jul 31 2018 18:14:21 +0000 Subject: Make original setup backward compatible, do not require explicit path to list of files. --- diff --git a/setup-named-chroot.sh b/setup-named-chroot.sh index 2704966..28134f5 100755 --- a/setup-named-chroot.sh +++ b/setup-named-chroot.sh @@ -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 ' + echo 'Usage: setup-named-chroot.sh ROOTDIR [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"