BugFix: Check if ZK data dir is writable
- Fix for a bug, where
./onos.sh setup failed when ZK data dir already exists,
but user did not have the write permission.
Change-Id: Ib0c303fdd5fc5e4d4eddaab80a95e3aa5fdbda9b
diff --git a/onos.sh b/onos.sh
index 8bbae2c..67c1070 100755
--- a/onos.sh
+++ b/onos.sh
@@ -254,11 +254,11 @@
echo -n "Creating ${ZK_CONF} ... "
# Create the ZooKeeper lib directory
- if [ ! -d ${ZK_LIB_DIR} ]; then
+ if [[ ! ( -w ${ZK_LIB_DIR} && -d ${ZK_LIB_DIR} ) ]]; then
local SUDO=${SUDO:-sudo}
local whoami=`whoami`
{
- ${SUDO} mkdir ${ZK_LIB_DIR}
+ ${SUDO} mkdir -p ${ZK_LIB_DIR}
${SUDO} chown ${whoami} ${ZK_LIB_DIR}
} || {
echo "FAILED"