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')
# - - - - - - - - - - - - - - - - - - - -
#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 -s <<-EOT
cp rclone ${binTgtDir}/rclone.new
chmod 755 ${binTgtDir}/rclone.new
chown root:root ${binTgtDir}/rclone.new
mv ${binTgtDir}/rclone.new ${binTgtDir}/rclone
EOT
sudo -u root -- bash -c "\
mkdir -m 0755 ${binTgtDir} && \
cp rclone ${binTgtDir}/rclone.new && \
chmod 0755 ${binTgtDir}/rclone.new && \
chown root:root ${binTgtDir}/rclone.new && \
mv ${binTgtDir}/rclone.new ${binTgtDir}/rclone"
# - - - - - - - - - - - - - - - - - - - -
#manual
if ! [ -x "$(command -v mandb)" ]; then
echo 'mandb not found. The rclone man docs will not be installed.'
else
sudo -v
sudo -s <<-EOT
mkdir -p ${man1TgtDir}/man1
cp rclone.1 ${man1TgtDir}/man1/
mandb
EOT
# See sudo note above.
sudo -v
sudo -u root -- bash -c "\
mkdir -m 0755 -p ${man1TgtDir} && \
cp rclone.1 ${man1TgtDir} && \
chmod 0644 ${man1TgtDir}/rclone.1" && \
mandb --quiet --filename=${man1TgtDir}/rclone.1"
# - - - - - - - - - - - - - - - - - - - -
fi
;;