Skip to content

Commit

Permalink
dont use sudo by default, only add it when we're not the repo owner
Browse files Browse the repository at this point in the history
  • Loading branch information
bedroge committed Nov 27, 2023
1 parent 49f43e6 commit 09476bb
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion scripts/ingest-tarball.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 09476bb

Please sign in to comment.