From 09476bb99a181f0a0089545ed54a1393ac5524b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bob=20Dr=C3=B6ge?= Date: Mon, 27 Nov 2023 16:31:45 +0100 Subject: [PATCH] dont use sudo by default, only add it when we're not the repo owner --- scripts/ingest-tarball.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/ingest-tarball.sh b/scripts/ingest-tarball.sh index 9985bea7..d71ff733 100755 --- a/scripts/ingest-tarball.sh +++ b/scripts/ingest-tarball.sh @@ -15,7 +15,7 @@ repo=software.eessi.io basedir=versions decompress="gunzip -c" -cvmfs_server="sudo cvmfs_server" +cvmfs_server="cvmfs_server" # list of supported architectures for compat and software layers declare -A archs=(["aarch64"]= ["ppc64le"]= ["riscv64"]= ["x86_64"]=) # list of supported operating systems for compat and software layers @@ -41,6 +41,14 @@ function error() { exit 1 } +function is_repo_owner() { + if [ -f "/etc/cvmfs/repositories.d/${repo}/server.conf" ] + then + . "/etc/cvmfs/repositories.d/${repo}/server.conf" + [ x"$(whoami)" = x"$CVMFS_USER" ] + fi +} + function check_repo_vars() { if [ -z "${repo}" ] then @@ -225,6 +233,9 @@ tar_first_file=$(tar tf "${tar_file}" | head -n 1) tar_top_level_dir=$(echo "${tar_first_file}" | cut -d/ -f1) tar_contents_type_dir=$(tar tf "${tar_file}" | head -n 2 | tail -n 1 | cut -d/ -f2) +# Check if we are running as the CVMFS repo owner, otherwise run cvmfs_server with sudo +is_repo_owner || cvmfs_server="sudo cvmfs_server" + # Do some checks, and ingest the tarball check_repo_vars check_version