Use install(1) where possible
This eliminated a number of sudo calls by doing the copy/chown/chmod in
a single step and sets a common pattern.
Change-Id: I9c8f48854d5bc443cc187df0948c28b82c4d2838
diff --git a/lib/sahara b/lib/sahara
index 521b19a..f389326 100644
--- a/lib/sahara
+++ b/lib/sahara
@@ -101,11 +101,7 @@
# configure_sahara() - Set config files, create data dirs, etc
function configure_sahara {
-
- if [[ ! -d $SAHARA_CONF_DIR ]]; then
- sudo mkdir -p $SAHARA_CONF_DIR
- fi
- sudo chown $STACK_USER $SAHARA_CONF_DIR
+ sudo install -d -o $STACK_USER $SAHARA_CONF_DIR
if [[ -f $SAHARA_DIR/etc/sahara/policy.json ]]; then
cp -p $SAHARA_DIR/etc/sahara/policy.json $SAHARA_CONF_DIR
@@ -115,9 +111,7 @@
cp $SAHARA_DIR/etc/sahara/sahara.conf.sample $SAHARA_CONF_FILE
# Create auth cache dir
- sudo mkdir -p $SAHARA_AUTH_CACHE_DIR
- sudo chown $STACK_USER $SAHARA_AUTH_CACHE_DIR
- sudo chmod 700 $SAHARA_AUTH_CACHE_DIR
+ sudo install -d -o $STACK_USER -m 700 $SAHARA_AUTH_CACHE_DIR
rm -rf $SAHARA_AUTH_CACHE_DIR/*
configure_auth_token_middleware $SAHARA_CONF_FILE sahara $SAHARA_AUTH_CACHE_DIR