From 5cce0eeb5e6654a4134c77076c0bcb7411d71bd8 Mon Sep 17 00:00:00 2001 From: Trevor Batley Date: Thu, 28 Sep 2023 21:17:09 +1000 Subject: [PATCH] fix cleanup func --- koji-setup/koji-add-user.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/koji-setup/koji-add-user.sh b/koji-setup/koji-add-user.sh index bc7e443..e42202a 100644 --- a/koji-setup/koji-add-user.sh +++ b/koji-setup/koji-add-user.sh @@ -38,6 +38,7 @@ KOJI_HUB_FQDN="$(hostname -f)" if [ ! -d $SCRIPT_DIR ] ; then mkdir -p $SCRIPT_DIR ; fi if [ ! -f $SCRIPT_DIR/koji-gencert.sh ] ; then curl $SILENT $SCRIPT_GIT/koji-gencert.sh > $SCRIPT_DIR/koji-gencert.sh + chmod o+x $SCRIPT_DIR/koji-gencert.sh fi # Add the new user into the database @@ -55,12 +56,18 @@ if [[ ! -d $KOJI_PKI_DIR/bundle ]] ; then mkdir -p $KOJI_PKI_DIR/bundle fi -WORK_DIR=`mktemp -d $NEW_USER-XXXXXXXX` +WORK_DIR=`mktemp -p /tmp -d $NEW_USER-XXXXXXXX` # check if tmp dir was created if [[ ! "$WORK_DIR" || ! -d "$WORK_DIR" ]]; then echo "Could not create temp dir" exit 1 fi + +# function to delete the temp directory +function cleanup { + rm -rf "$WORK_DIR" +} + # register the cleanup function to be called on the EXIT signal trap cleanup EXIT @@ -85,8 +92,3 @@ cp koji-"$NEW_USER"-bundle.tgz $KOJI_PKI_DIR/bundle/. popd echo "The Koji CLI and Web key bundle for $NEW_USER is $KOJI_PKI_DIR/bundle/koij-$NEW_USER-bundle.tgz" - -# function to delete the temp directory -function cleanup { - rm -rf "$WORK_DIR" -}