I am currently updating a few scripts, and am planning on releasing some useful ones so others can use them (so they need to work across a wide range of machines without crashing, and without breaking anything).
One of these adds the chromium pepperflash plugin and some other stuff on Fedora machines - I made the script originally as the russianfedora thing to do it seemed unreliable at the time, needed a annoying bunch of dependencies, and is sometimes out of date. My script should do what I think the script for ubuntu does - use a chrome package and extract the plug-ins, hence is legally re-distributable.
Once it has worked out what it is doing, it needs to copy stuff to chromium installation etc, using copy commands similar to this (which works happily on my Fedora 21 boxes):
sudo cp -riv ${tmpdir}/* ${location}/
Where ${tmpdir}
can be /tmp/tmp.IOfylQBAHT
etc, and ${location}
can be /usr/lib64/chromium-browser/
- both vary based on what setup the script is run on and what options are used. Often two or three copy commands need to be used.
My problem is I think not all systems use sudo
(some you have to use su
as sudo
is not installed or setup, and on some systems perhaps the user has not root privileges at all, etc), so I am wondering what I should - e.g.
- Use
sudo
and hope all goes well - Use something weird like
timeout 2 sudo -v > /dev/null 2>&1
and check$?
to see if the user can do stuff as root with sudo - if they cannot exit with a message likeTo finish installation, please run 'cp -riv ${tmpdir}/* ${location}/' as root
- if they can, continue. (The test command may cause trouble on some systems with infamous 'this incident will be reported' if the user tries using sudo - it also might extend the user's timeout or something .... source) - Just exit with the latter point's message (N.B. It will be
echo
ed, so it will replace the${tmpdir}
etc with the appropriate locations) Make sure the user runs the script as root - e.g. with:
if [ "$(whoami)" != "root" ]; then echo -e "\e[31mERROR: This needs to be run as root\e[0m"; exit 1 ; fi
- Something else :)