Introduction
Please see the article “Build a Linux-based Infrastructure Solution Demonstration Series” (https://blogs.czapski.id.au/2016/10/build-a-linux-based-infrastructure-solution-demonstration-series) for rationale, introduction and links to articles in this series.
In this article I am creating and executing a script which will disable unneeded services.
Pre-Requisites
This article assumes that
- The work is done in the Virtual Box Machine Image created in accordance with the instructions in the blog article to be found at https://blogs.czapski.id.au/2016/10/configure-virtual-box-virtual-machine-and-install-centos-6-8-base-image.
- The user “demo” has sudo access without a password. If this is not the case use the command “su -” and provide the password instead of saying “sudo -i” in the set of commands below
The instructions should work in other RedHat 6-like OS’ and OS versions.
Disable unneeded Services
Create and execute a script which will disable some unneeded services.
Remember that all this can be done manually but my objective is to create configuration scripts which I can execute and have the demo image configured without having to tediously manipulate various UIs.
mkdir -p /media/sf_distros/scripts cat <<-'EODECK' > /media/sf_distros/scripts/004_disable_unneeded_services.sh # disable unneeded services sudo chkconfig postfix off sudo chkconfig pcscd off sudo chkconfig openct off sudo chkconfig bluetooth off sudo service postfix stop sudo service pcscd stop sudo service openct stop sudo service bluetooth stop EODECK chmod ug+x /media/sf_distros/scripts/004_disable_unneeded_services.sh
Execute the commands
/bin/bash -v /media/sf_distros/scripts/004_disable_unneeded_services.sh
Append “disable unneeded services” script execution commands to the initial bulk configuration script. This script is intended to collect all automated configuration commands and scripts so that they can be all executed in one go on a brand new image if one gets to do this the second and subsequent times.
Don’t actually execute this script while you are building the first image.
cat <<-'EODECK' >> /media/sf_distros/scripts/000_initial_bulk_configuration.sh # disable unneeded services /bin/bash -v /media/sf_distros/scripts/004_disable_unneeded_services.sh EODECK chmod ug+x /media/sf_distros/scripts/000_initial_bulk_configuration.sh