Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
@mchaudhary @mostlyjason In this PR, I have added a new systemctl command that will check whether any service is installed or not. The output of the command systemctl list-unit-files httpd.service is below(if installed):
If not installed then the output is as below:
So I used
grepto extract the installed service name from the command output. I also used$(which systemctl)because on CentOS 6, systemctl command doesn't work and if user has not installed the httpd and run our script then it will first evaluate the conditionif [ -f /etc/init.d/$SERVICE ]; thenand it will not find the httpd service at that path then script will try to execute the next conditon in which systemctl command is used which doesn't work on CentOS 6 and give the message like below:I had to remove
configure-apache.sh: line 118: systemctl: command not foundthat's why I used$(which systemctl), it will check if system is systemctl supported then this conditon will be executed otherwise not.I have tested on
(a) CentOS 6
(b) CentOS 7
(c) Ubuntu 14
(d) Ubuntu 16
And the changes looked fine to me. Currently, I need to test on some other distributions as well.
Please review