Store shell scripts for installing dependencies on Ubuntu.
These scripts will be able to run on Docker 🐳 servers or containers, so they need to be automatable;
- Try to keep the scripts working only when calling them, that is, avoiding interaction with the user;
- For
apt installscripts for example, the-yflag is usually added to the end so thatyesis answered automatically whenever it is requested, e.g.:
apt install reino-das-coxinhas -y # ok apt install good-script # wrong, add '-y'
- For scripts that accept arguments, assign values by default, e.g.:
ARG1=${1}if [ -z${ARG1} ] # checks if 'ARG1' is emptythen ARG1="some-default-value"# add a default valuefi
- It may be necessary to add the
DEBIAN_FRONTEND=noninteractiveenvironment variable to the script, e.g.:
DEBIAN_FRONTEND=noninteractive apt install keyboard-configuration -y # okDo not add the
sudokeyword at the beginning of the script, it is the responsibility of the command that calls it with that keyword, e.g.:
sudo apt install reino-das-coxinhas -y # wrong, remove 'sudo'
sudo apt install good-script # wrong, remove 'sudo, add '-y'
apt install g++ -y # ok- Pay attention to the permissions of the added files. Put
chownif necessary, e.g.:
CURRENT_USER=$(who | awk 'NR==1{print $1}')
chown "${CURRENT_USER}":"${CURRENT_USER}""${DIR}" -R- Remove temporary files downloaded with
wgetand similar during script execution, e.g.:
wget https://github.com/microsoft/vscode-cpptools/releases/download/1.2.1/cpptools-linux.vsix
code --install-extension cpptools-linux.vsix
rm cpptools-linux.vsix # << don't forget