mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 01:32:18 +02:00
Updated setup-sysvm-tmplt script, to run cmds accessing destdir with sudo (#10263)
This commit is contained in:
parent
6f334eb187
commit
3afab9a703
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user