2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-22 01:22:00 +00:00

Cleanup after script execution

Leave cleaner tmp directories when functions are ran.
This commit is contained in:
Jarrod Johnson 2021-10-15 12:16:48 -04:00
parent 04dd374bfb
commit f33ed9b4d9
7 changed files with 84 additions and 49 deletions

View File

@ -63,7 +63,7 @@ fetch_remote() {
}
source_remote_parts() {
confluentscripttmpdir=$(mktemp -d)
confluentscripttmpdir=$(mktemp -d confluentscripts.XXXXXXXXX)
apiclient=/opt/confluent/bin/apiclient
if [ -f /etc/confluent/apiclient ]; then
apiclient=/etc/confluent/apiclient
@ -72,11 +72,12 @@ source_remote_parts() {
for script in $scriptlist; do
source_remote $1/$script
done
rm -rf $confluentscripttmpdir
unset confluentscripttmpdir
}
run_remote_parts() {
confluentscripttmpdir=$(mktemp -d)
confluentscripttmpdir=$(mktemp -d confluentscripts.XXXXXXXXX)
apiclient=/opt/confluent/bin/apiclient
if [ -f /etc/confluent/apiclient ]; then
apiclient=/etc/confluent/apiclient
@ -85,6 +86,7 @@ run_remote_parts() {
for script in $scriptlist; do
run_remote $1/$script
done
rm -rf $confluentscripttmpdir
unset confluentscripttmpdir
}
@ -94,7 +96,7 @@ source_remote() {
echo '---------------------------------------------------------------------------'
echo Sourcing $1 from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/
if [ -z "$confluentscripttmpdir" ]; then
confluentscripttmpdir=$(mktemp -d)
confluentscripttmpdir=$(mktemp -d confluentscripts.XXXXXXXXX)
fi
echo Sourcing from $confluentscripttmpdir
cd $confluentscripttmpdir
@ -105,6 +107,7 @@ source_remote() {
shift
source ./$cmd
cd - > /dev/null
rm -rf $confluentscripttmpdir
return $retcode
}
@ -115,7 +118,7 @@ run_remote() {
echo '---------------------------------------------------------------------------'
echo Running $requestedcmd from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/
if [ -z "$confluentscripttmpdir" ]; then
confluentscripttmpdir=$(mktemp -d)
confluentscripttmpdir=$(mktemp -d confluentscripts.XXXXXXXXX)
fi
echo Executing in $confluentscripttmpdir
cd $confluentscripttmpdir
@ -133,6 +136,7 @@ run_remote() {
echo "$requestedcmd exited with code $retcode"
fi
cd - > /dev/null
rm -rf $confluentscripttmpdir
return $retcode
}
@ -144,9 +148,9 @@ run_remote_python() {
fi
echo '---------------------------------------------------------------------------'
echo Running python script "'$*'" from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/
tmpdir=$(mktemp -d)
echo Executing in $tmpdir
cd $tmpdir
confluentscripttmpdir=$(mktemp -d confluentscripts.XXXXXXXXX)
echo Executing in $confluentscripttmpdir
cd $confluentscripttmpdir
mkdir -p $(dirname $1)
curl -f -sS $curlargs https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/$1 > $1
if [ $? != 0 ]; then echo "'$*'" failed to download; return 1; fi
@ -154,6 +158,7 @@ run_remote_python() {
retcode=$?
echo "'$*' exited with code $retcode"
cd - > /dev/null
rm -rf $confluentscripttmpdir
return $retcode
}

View File

@ -63,7 +63,7 @@ fetch_remote() {
}
source_remote_parts() {
confluentscripttmpdir=$(mktemp -d)
confluentscripttmpdir=$(mktemp -d confluentscripts.XXXXXXXXX)
apiclient=/opt/confluent/bin/apiclient
if [ -f /etc/confluent/apiclient ]; then
apiclient=/etc/confluent/apiclient
@ -72,11 +72,12 @@ source_remote_parts() {
for script in $scriptlist; do
source_remote $1/$script
done
rm -rf $confluentscripttmpdir
unset confluentscripttmpdir
}
run_remote_parts() {
confluentscripttmpdir=$(mktemp -d)
confluentscripttmpdir=$(mktemp -d confluentscripts.XXXXXXXXX)
apiclient=/opt/confluent/bin/apiclient
if [ -f /etc/confluent/apiclient ]; then
apiclient=/etc/confluent/apiclient
@ -85,6 +86,7 @@ run_remote_parts() {
for script in $scriptlist; do
run_remote $1/$script
done
rm -rf $confluentscripttmpdir
unset confluentscripttmpdir
}
@ -94,7 +96,7 @@ source_remote() {
echo '---------------------------------------------------------------------------'
echo Sourcing $1 from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/
if [ -z "$confluentscripttmpdir" ]; then
confluentscripttmpdir=$(mktemp -d)
confluentscripttmpdir=$(mktemp -d confluentscripts.XXXXXXXXX)
fi
echo Sourcing from $confluentscripttmpdir
cd $confluentscripttmpdir
@ -105,6 +107,7 @@ source_remote() {
shift
source ./$cmd
cd - > /dev/null
rm -rf $confluentscripttmpdir
return $retcode
}
@ -115,7 +118,7 @@ run_remote() {
echo '---------------------------------------------------------------------------'
echo Running $requestedcmd from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/
if [ -z "$confluentscripttmpdir" ]; then
confluentscripttmpdir=$(mktemp -d)
confluentscripttmpdir=$(mktemp -d confluentscripts.XXXXXXXXX)
fi
echo Executing in $confluentscripttmpdir
cd $confluentscripttmpdir
@ -133,6 +136,7 @@ run_remote() {
echo "$requestedcmd exited with code $retcode"
fi
cd - > /dev/null
rm -rf $confluentscripttmpdir
return $retcode
}
@ -144,9 +148,9 @@ run_remote_python() {
fi
echo '---------------------------------------------------------------------------'
echo Running python script "'$*'" from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/
tmpdir=$(mktemp -d)
echo Executing in $tmpdir
cd $tmpdir
confluentscripttmpdir=$(mktemp -d confluentscripts.XXXXXXXXX)
echo Executing in $confluentscripttmpdir
cd $confluentscripttmpdir
mkdir -p $(dirname $1)
curl -f -sS $curlargs https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/$1 > $1
if [ $? != 0 ]; then echo "'$*'" failed to download; return 1; fi
@ -154,6 +158,7 @@ run_remote_python() {
retcode=$?
echo "'$*' exited with code $retcode"
cd - > /dev/null
rm -rf $confluentscripttmpdir
return $retcode
}

View File

@ -63,7 +63,7 @@ fetch_remote() {
}
source_remote_parts() {
confluentscripttmpdir=$(mktemp -d)
confluentscripttmpdir=$(mktemp -d confluentscripts.XXXXXXXXX)
apiclient=/opt/confluent/bin/apiclient
if [ -f /etc/confluent/apiclient ]; then
apiclient=/etc/confluent/apiclient
@ -72,11 +72,12 @@ source_remote_parts() {
for script in $scriptlist; do
source_remote $1/$script
done
rm -rf $confluentscripttmpdir
unset confluentscripttmpdir
}
run_remote_parts() {
confluentscripttmpdir=$(mktemp -d)
confluentscripttmpdir=$(mktemp -d confluentscripts.XXXXXXXXX)
apiclient=/opt/confluent/bin/apiclient
if [ -f /etc/confluent/apiclient ]; then
apiclient=/etc/confluent/apiclient
@ -85,6 +86,7 @@ run_remote_parts() {
for script in $scriptlist; do
run_remote $1/$script
done
rm -rf $confluentscripttmpdir
unset confluentscripttmpdir
}
@ -94,7 +96,7 @@ source_remote() {
echo '---------------------------------------------------------------------------'
echo Sourcing $1 from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/
if [ -z "$confluentscripttmpdir" ]; then
confluentscripttmpdir=$(mktemp -d)
confluentscripttmpdir=$(mktemp -d confluentscripts.XXXXXXXXX)
fi
echo Sourcing from $confluentscripttmpdir
cd $confluentscripttmpdir
@ -105,6 +107,7 @@ source_remote() {
shift
source ./$cmd
cd - > /dev/null
rm -rf $confluentscripttmpdir
return $retcode
}
@ -115,7 +118,7 @@ run_remote() {
echo '---------------------------------------------------------------------------'
echo Running $requestedcmd from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/
if [ -z "$confluentscripttmpdir" ]; then
confluentscripttmpdir=$(mktemp -d)
confluentscripttmpdir=$(mktemp -d confluentscripts.XXXXXXXXX)
fi
echo Executing in $confluentscripttmpdir
cd $confluentscripttmpdir
@ -133,6 +136,7 @@ run_remote() {
echo "$requestedcmd exited with code $retcode"
fi
cd - > /dev/null
rm -rf $confluentscripttmpdir
return $retcode
}
@ -144,9 +148,9 @@ run_remote_python() {
fi
echo '---------------------------------------------------------------------------'
echo Running python script "'$*'" from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/
tmpdir=$(mktemp -d)
echo Executing in $tmpdir
cd $tmpdir
confluentscripttmpdir=$(mktemp -d confluentscripts.XXXXXXXXX)
echo Executing in $confluentscripttmpdir
cd $confluentscripttmpdir
mkdir -p $(dirname $1)
curl -f -sS $curlargs https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/$1 > $1
if [ $? != 0 ]; then echo "'$*'" failed to download; return 1; fi
@ -154,6 +158,7 @@ run_remote_python() {
retcode=$?
echo "'$*' exited with code $retcode"
cd - > /dev/null
rm -rf $confluentscripttmpdir
return $retcode
}

View File

@ -63,7 +63,7 @@ fetch_remote() {
}
source_remote_parts() {
confluentscripttmpdir=$(mktemp -d)
confluentscripttmpdir=$(mktemp -d confluentscripts.XXXXXXXXX)
apiclient=/opt/confluent/bin/apiclient
if [ -f /etc/confluent/apiclient ]; then
apiclient=/etc/confluent/apiclient
@ -72,11 +72,12 @@ source_remote_parts() {
for script in $scriptlist; do
source_remote $1/$script
done
rm -rf $confluentscripttmpdir
unset confluentscripttmpdir
}
run_remote_parts() {
confluentscripttmpdir=$(mktemp -d)
confluentscripttmpdir=$(mktemp -d confluentscripts.XXXXXXXXX)
apiclient=/opt/confluent/bin/apiclient
if [ -f /etc/confluent/apiclient ]; then
apiclient=/etc/confluent/apiclient
@ -85,6 +86,7 @@ run_remote_parts() {
for script in $scriptlist; do
run_remote $1/$script
done
rm -rf $confluentscripttmpdir
unset confluentscripttmpdir
}
@ -94,7 +96,7 @@ source_remote() {
echo '---------------------------------------------------------------------------'
echo Sourcing $1 from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/
if [ -z "$confluentscripttmpdir" ]; then
confluentscripttmpdir=$(mktemp -d)
confluentscripttmpdir=$(mktemp -d confluentscripts.XXXXXXXXX)
fi
echo Sourcing from $confluentscripttmpdir
cd $confluentscripttmpdir
@ -105,6 +107,7 @@ source_remote() {
shift
source ./$cmd
cd - > /dev/null
rm -rf $confluentscripttmpdir
return $retcode
}
@ -115,7 +118,7 @@ run_remote() {
echo '---------------------------------------------------------------------------'
echo Running $requestedcmd from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/
if [ -z "$confluentscripttmpdir" ]; then
confluentscripttmpdir=$(mktemp -d)
confluentscripttmpdir=$(mktemp -d confluentscripts.XXXXXXXXX)
fi
echo Executing in $confluentscripttmpdir
cd $confluentscripttmpdir
@ -133,6 +136,7 @@ run_remote() {
echo "$requestedcmd exited with code $retcode"
fi
cd - > /dev/null
rm -rf $confluentscripttmpdir
return $retcode
}
@ -144,9 +148,9 @@ run_remote_python() {
fi
echo '---------------------------------------------------------------------------'
echo Running python script "'$*'" from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/
tmpdir=$(mktemp -d)
echo Executing in $tmpdir
cd $tmpdir
confluentscripttmpdir=$(mktemp -d confluentscripts.XXXXXXXXX)
echo Executing in $confluentscripttmpdir
cd $confluentscripttmpdir
mkdir -p $(dirname $1)
curl -f -sS $curlargs https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/$1 > $1
if [ $? != 0 ]; then echo "'$*'" failed to download; return 1; fi
@ -154,6 +158,7 @@ run_remote_python() {
retcode=$?
echo "'$*' exited with code $retcode"
cd - > /dev/null
rm -rf $confluentscripttmpdir
return $retcode
}

View File

@ -63,7 +63,7 @@ fetch_remote() {
}
source_remote_parts() {
confluentscripttmpdir=$(mktemp -d)
confluentscripttmpdir=$(mktemp -d confluentscripts.XXXXXXXXX)
apiclient=/opt/confluent/bin/apiclient
if [ -f /etc/confluent/apiclient ]; then
apiclient=/etc/confluent/apiclient
@ -72,11 +72,12 @@ source_remote_parts() {
for script in $scriptlist; do
source_remote $1/$script
done
rm -rf $confluentscripttmpdir
unset confluentscripttmpdir
}
run_remote_parts() {
confluentscripttmpdir=$(mktemp -d)
confluentscripttmpdir=$(mktemp -d confluentscripts.XXXXXXXXX)
apiclient=/opt/confluent/bin/apiclient
if [ -f /etc/confluent/apiclient ]; then
apiclient=/etc/confluent/apiclient
@ -85,6 +86,7 @@ run_remote_parts() {
for script in $scriptlist; do
run_remote $1/$script
done
rm -rf $confluentscripttmpdir
unset confluentscripttmpdir
}
@ -94,7 +96,7 @@ source_remote() {
echo '---------------------------------------------------------------------------'
echo Sourcing $1 from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/
if [ -z "$confluentscripttmpdir" ]; then
confluentscripttmpdir=$(mktemp -d)
confluentscripttmpdir=$(mktemp -d confluentscripts.XXXXXXXXX)
fi
echo Sourcing from $confluentscripttmpdir
cd $confluentscripttmpdir
@ -105,6 +107,7 @@ source_remote() {
shift
source ./$cmd
cd - > /dev/null
rm -rf $confluentscripttmpdir
return $retcode
}
@ -115,7 +118,7 @@ run_remote() {
echo '---------------------------------------------------------------------------'
echo Running $requestedcmd from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/
if [ -z "$confluentscripttmpdir" ]; then
confluentscripttmpdir=$(mktemp -d)
confluentscripttmpdir=$(mktemp -d confluentscripts.XXXXXXXXX)
fi
echo Executing in $confluentscripttmpdir
cd $confluentscripttmpdir
@ -133,6 +136,7 @@ run_remote() {
echo "$requestedcmd exited with code $retcode"
fi
cd - > /dev/null
rm -rf $confluentscripttmpdir
return $retcode
}
@ -144,9 +148,9 @@ run_remote_python() {
fi
echo '---------------------------------------------------------------------------'
echo Running python script "'$*'" from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/
tmpdir=$(mktemp -d)
echo Executing in $tmpdir
cd $tmpdir
confluentscripttmpdir=$(mktemp -d confluentscripts.XXXXXXXXX)
echo Executing in $confluentscripttmpdir
cd $confluentscripttmpdir
mkdir -p $(dirname $1)
curl -f -sS $curlargs https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/$1 > $1
if [ $? != 0 ]; then echo "'$*'" failed to download; return 1; fi
@ -154,6 +158,7 @@ run_remote_python() {
retcode=$?
echo "'$*' exited with code $retcode"
cd - > /dev/null
rm -rf $confluentscripttmpdir
return $retcode
}

View File

@ -63,7 +63,7 @@ fetch_remote() {
}
source_remote_parts() {
confluentscripttmpdir=$(mktemp -d)
confluentscripttmpdir=$(mktemp -d confluentscripts.XXXXXXXXX)
apiclient=/opt/confluent/bin/apiclient
if [ -f /etc/confluent/apiclient ]; then
apiclient=/etc/confluent/apiclient
@ -72,11 +72,12 @@ source_remote_parts() {
for script in $scriptlist; do
source_remote $1/$script
done
rm -rf $confluentscripttmpdir
unset confluentscripttmpdir
}
run_remote_parts() {
confluentscripttmpdir=$(mktemp -d)
confluentscripttmpdir=$(mktemp -d confluentscripts.XXXXXXXXX)
apiclient=/opt/confluent/bin/apiclient
if [ -f /etc/confluent/apiclient ]; then
apiclient=/etc/confluent/apiclient
@ -85,6 +86,7 @@ run_remote_parts() {
for script in $scriptlist; do
run_remote $1/$script
done
rm -rf $confluentscripttmpdir
unset confluentscripttmpdir
}
@ -94,7 +96,7 @@ source_remote() {
echo '---------------------------------------------------------------------------'
echo Sourcing $1 from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/
if [ -z "$confluentscripttmpdir" ]; then
confluentscripttmpdir=$(mktemp -d)
confluentscripttmpdir=$(mktemp -d confluentscripts.XXXXXXXXX)
fi
echo Sourcing from $confluentscripttmpdir
cd $confluentscripttmpdir
@ -105,6 +107,7 @@ source_remote() {
shift
source ./$cmd
cd - > /dev/null
rm -rf $confluentscripttmpdir
return $retcode
}
@ -115,7 +118,7 @@ run_remote() {
echo '---------------------------------------------------------------------------'
echo Running $requestedcmd from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/
if [ -z "$confluentscripttmpdir" ]; then
confluentscripttmpdir=$(mktemp -d)
confluentscripttmpdir=$(mktemp -d confluentscripts.XXXXXXXXX)
fi
echo Executing in $confluentscripttmpdir
cd $confluentscripttmpdir
@ -133,6 +136,7 @@ run_remote() {
echo "$requestedcmd exited with code $retcode"
fi
cd - > /dev/null
rm -rf $confluentscripttmpdir
return $retcode
}
@ -144,9 +148,9 @@ run_remote_python() {
fi
echo '---------------------------------------------------------------------------'
echo Running python script "'$*'" from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/
tmpdir=$(mktemp -d)
echo Executing in $tmpdir
cd $tmpdir
confluentscripttmpdir=$(mktemp -d confluentscripts.XXXXXXXXX)
echo Executing in $confluentscripttmpdir
cd $confluentscripttmpdir
mkdir -p $(dirname $1)
curl -f -sS $curlargs https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/$1 > $1
if [ $? != 0 ]; then echo "'$*'" failed to download; return 1; fi
@ -154,6 +158,7 @@ run_remote_python() {
retcode=$?
echo "'$*' exited with code $retcode"
cd - > /dev/null
rm -rf $confluentscripttmpdir
return $retcode
}

View File

@ -63,7 +63,7 @@ fetch_remote() {
}
source_remote_parts() {
confluentscripttmpdir=$(mktemp -d)
confluentscripttmpdir=$(mktemp -d confluentscripts.XXXXXXXXX)
apiclient=/opt/confluent/bin/apiclient
if [ -f /etc/confluent/apiclient ]; then
apiclient=/etc/confluent/apiclient
@ -72,11 +72,12 @@ source_remote_parts() {
for script in $scriptlist; do
source_remote $1/$script
done
rm -rf $confluentscripttmpdir
unset confluentscripttmpdir
}
run_remote_parts() {
confluentscripttmpdir=$(mktemp -d)
confluentscripttmpdir=$(mktemp -d confluentscripts.XXXXXXXXX)
apiclient=/opt/confluent/bin/apiclient
if [ -f /etc/confluent/apiclient ]; then
apiclient=/etc/confluent/apiclient
@ -85,6 +86,7 @@ run_remote_parts() {
for script in $scriptlist; do
run_remote $1/$script
done
rm -rf $confluentscripttmpdir
unset confluentscripttmpdir
}
@ -94,7 +96,7 @@ source_remote() {
echo '---------------------------------------------------------------------------'
echo Sourcing $1 from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/
if [ -z "$confluentscripttmpdir" ]; then
confluentscripttmpdir=$(mktemp -d)
confluentscripttmpdir=$(mktemp -d confluentscripts.XXXXXXXXX)
fi
echo Sourcing from $confluentscripttmpdir
cd $confluentscripttmpdir
@ -105,6 +107,7 @@ source_remote() {
shift
source ./$cmd
cd - > /dev/null
rm -rf $confluentscripttmpdir
return $retcode
}
@ -115,7 +118,7 @@ run_remote() {
echo '---------------------------------------------------------------------------'
echo Running $requestedcmd from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/
if [ -z "$confluentscripttmpdir" ]; then
confluentscripttmpdir=$(mktemp -d)
confluentscripttmpdir=$(mktemp -d confluentscripts.XXXXXXXXX)
fi
echo Executing in $confluentscripttmpdir
cd $confluentscripttmpdir
@ -133,6 +136,7 @@ run_remote() {
echo "$requestedcmd exited with code $retcode"
fi
cd - > /dev/null
rm -rf $confluentscripttmpdir
return $retcode
}
@ -144,9 +148,9 @@ run_remote_python() {
fi
echo '---------------------------------------------------------------------------'
echo Running python script "'$*'" from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/
tmpdir=$(mktemp -d)
echo Executing in $tmpdir
cd $tmpdir
confluentscripttmpdir=$(mktemp -d confluentscripts.XXXXXXXXX)
echo Executing in $confluentscripttmpdir
cd $confluentscripttmpdir
mkdir -p $(dirname $1)
curl -f -sS $curlargs https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/$1 > $1
if [ $? != 0 ]; then echo "'$*'" failed to download; return 1; fi
@ -154,6 +158,7 @@ run_remote_python() {
retcode=$?
echo "'$*' exited with code $retcode"
cd - > /dev/null
rm -rf $confluentscripttmpdir
return $retcode
}