Updated setup-sysvm-tmplt script, to run cmds accessing destdir with sudo (#10263)

This commit is contained in:
Suresh Kumar Anaparti 2025-03-27 18:54:04 +05:30 committed by GitHub
parent 6f334eb187
commit 3afab9a703
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 6 deletions

View File

@ -99,7 +99,7 @@ if [[ -f $destdir/template.properties ]]; then
failed 2 "Data already exists at destination $destdir"
fi
destfiles=$(find $destdir -name \*.$ext)
destfiles=$(sudo find $destdir -name \*.$ext)
if [[ "$destfiles" != "" ]]; then
failed 2 "Data already exists at destination $destdir"
fi
@ -108,12 +108,12 @@ tmpfolder=/tmp/cloud/templates/
mkdir -p $tmpfolder
tmplfile=$tmpfolder/$localfile
sudo touch $tmplfile
touch $tmplfile
if [[ $? -ne 0 ]]; then
failed 2 "Failed to create temporary file in directory $tmpfolder -- is it read-only or full?\n"
fi
destcap=$(df -P $destdir | awk '{print $4}' | tail -1 )
destcap=$(sudo df -P $destdir | awk '{print $4}' | tail -1 )
[ $destcap -lt $DISKSPACE ] && echo "Insufficient free disk space for target folder $destdir: avail=${destcap}k req=${DISKSPACE}k" && failed 4
localcap=$(df -P $tmpfolder | awk '{print $4}' | tail -1 )
@ -146,9 +146,9 @@ fi
tmpltfile=$destdir/$localfile
tmpltsize=$(ls -l $tmpltfile | awk -F" " '{print $5}')
tmpltsize=$(sudo ls -l $tmpltfile | awk -F" " '{print $5}')
if [[ "$ext" == "qcow2" ]]; then
vrtmpltsize=$($qemuimgcmd info $tmpltfile | grep -i 'virtual size' | sed -ne 's/.*(\([0-9]*\).*/\1/p' | xargs)
vrtmpltsize=$(sudo $qemuimgcmd info $tmpltfile | grep -i 'virtual size' | sed -ne 's/.*(\([0-9]*\).*/\1/p' | xargs)
else
vrtmpltsize=$tmpltsize
fi

View File

@ -18,7 +18,7 @@
# The CloudStack management server needs sudo permissions
# without a password.
Cmnd_Alias CLOUDSTACK = /bin/mkdir, /bin/mount, /bin/umount, /bin/cp, /bin/chmod, /usr/bin/keytool, /bin/keytool, /bin/touch
Cmnd_Alias CLOUDSTACK = /bin/mkdir, /bin/mount, /bin/umount, /bin/cp, /bin/chmod, /usr/bin/keytool, /bin/keytool, /bin/touch, /bin/find, /bin/df, /bin/ls, /bin/qemu-img
Defaults:@MSUSER@ !requiretty