For 'Linux' Force ownership and modes on file using sudo.

Avoid assuming certain things.
	Forcing creation of target dir with correct mode and ownership.
	Move files into place setting their modes too.
	These tasks done the same for binary and manpages.
This commit is contained in:
Michael C Tiernan - MIT-Research Computing Project 2022-05-19 07:43:22 -04:00
parent 64913d5346
commit 410684809b

View file

@ -156,24 +156,29 @@ case "$OS" in
'linux') 'linux')
# - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - -
#binary #binary
# First verify our sudo ability. If we pass that then execute the steps
# requested but make sure we're doing it as root and not as any other user.
# (If sudo was run before this, the user may be set to something *other*
# than 'root', this makes sure.
sudo -v sudo -v
sudo -s <<-EOT sudo -u root -- bash -c "\
cp rclone ${binTgtDir}/rclone.new mkdir -m 0755 ${binTgtDir} && \
chmod 755 ${binTgtDir}/rclone.new cp rclone ${binTgtDir}/rclone.new && \
chown root:root ${binTgtDir}/rclone.new chmod 0755 ${binTgtDir}/rclone.new && \
mv ${binTgtDir}/rclone.new ${binTgtDir}/rclone chown root:root ${binTgtDir}/rclone.new && \
EOT mv ${binTgtDir}/rclone.new ${binTgtDir}/rclone"
# - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - -
#manual #manual
if ! [ -x "$(command -v mandb)" ]; then if ! [ -x "$(command -v mandb)" ]; then
echo 'mandb not found. The rclone man docs will not be installed.' echo 'mandb not found. The rclone man docs will not be installed.'
else else
# See sudo note above.
sudo -v sudo -v
sudo -s <<-EOT sudo -u root -- bash -c "\
mkdir -p ${man1TgtDir}/man1 mkdir -m 0755 -p ${man1TgtDir} && \
cp rclone.1 ${man1TgtDir}/man1/ cp rclone.1 ${man1TgtDir} && \
mandb chmod 0644 ${man1TgtDir}/rclone.1" && \
EOT mandb --quiet --filename=${man1TgtDir}/rclone.1"
# - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - -
fi fi
;; ;;