forked from ComplianceAsCode/content
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate_BASH_service_disabled
34 lines (30 loc) · 1.27 KB
/
template_BASH_service_disabled
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# platform = multi_platform_rhel,multi_platform_fedora,multi_platform_ol,multi_platform_rhv,multi_platform_sle
# reboot = false
# strategy = disable
# complexity = low
# disruption = low
{{%- if init_system == "systemd" %}}
SYSTEMCTL_EXEC='/usr/bin/systemctl'
"$SYSTEMCTL_EXEC" stop '{{{ DAEMONNAME }}}.service'
"$SYSTEMCTL_EXEC" disable '{{{ DAEMONNAME }}}.service'
{{%- if MASK_SERVICE %}}
"$SYSTEMCTL_EXEC" mask '{{{ DAEMONNAME }}}.service'
{{%- endif %}}
# Disable socket activation if we have a unit file for it
if "$SYSTEMCTL_EXEC" list-unit-files | grep -q '^{{{ DAEMONNAME }}}.socket'; then
"$SYSTEMCTL_EXEC" stop '{{{ DAEMONNAME }}}.socket'
"$SYSTEMCTL_EXEC" disable '{{{ DAEMONNAME }}}.socket'
{{%- if MASK_SERVICE %}}
"$SYSTEMCTL_EXEC" mask '{{{ DAEMONNAME }}}.socket'
{{%- endif %}}
fi
# The service may not be running because it has been started and failed,
# so let's reset the state so OVAL checks pass.
# Service should be 'inactive', not 'failed' after reboot though.
"$SYSTEMCTL_EXEC" reset-failed '{{{ DAEMONNAME }}}.service' || true
{{% elif init_system == "upstart" %}}
/sbin/service '{{{ DAEMONNAME }}}' stop
/sbin/chkconfig --level 0123456 '{{{ DAEMONNAME }}}' off
{{%- else %}}
JINJA TEMPLATE ERROR: Unknown init system '{{{ init_system }}}'
{{%- endif %}}