Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add systemctl command to check for apache service #100

Merged
merged 1 commit into from Sep 5, 2017

Conversation

@Shwetajain148
Copy link
Contributor

@Shwetajain148 Shwetajain148 commented Aug 21, 2017

@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):

UNIT FILE     STATE
httpd.service disabled

1 unit files listed.

If not installed then the output is as below:

UNIT FILE STATE

0 unit files listed.

So I used grep to 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 condition if [ -f /etc/init.d/$SERVICE ]; then and 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:

INFO: rsyslog is present as service.
INFO: Modified $MaxMessageSize to 64k in rsyslog.conf
configure-apache.sh: line 118: systemctl: command not found
ERROR: Apache is not configured as a service
Manual instructions to configure Apache2 is available at https://www.loggly.com/docs/sending-apache-logs/. Rsyslog troubleshooting instructions are available at https://www.loggly.com/docs/troubleshooting-rsyslog/

I had to remove configure-apache.sh: line 118: systemctl: command not found that'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

@mostlyjason mostlyjason merged commit 8a202b2 into loggly:master Sep 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.