Skip to content

Instantly share code, notes, and snippets.

@n0ts
Created April 25, 2012 01:54
Show Gist options
  • Save n0ts/2485450 to your computer and use it in GitHub Desktop.
Save n0ts/2485450 to your computer and use it in GitHub Desktop.
disable service for CentOS 5
#!/bin/sh
disable_service() {
service=$1
/sbin/chkconfig --list $service 2> /dev/null
if [ $? -ne 0 ]; then
return 1
fi
prompt=$2
if [ -n "$prompt" ]; then
echo -n "disable $service ? [y/N] "
read answer
case $answer in
Y|y)
;;
*)
return 1
;;
esac
fi
/sbin/chkconfig $service off
}
SERVICE_LIST="
acpid
apmd
auditd
autofs
avahi-daemon
bluetooth
cups
firstboot
gpm
hidd
ip6tables
isdn
iscsi
iscsid
mcstrans
microcode_ctl
netfs
nfs
nfslock
pcmcia
pcscd
portmap
rawdevices
readahead
readahead_early
restorecond
rpcgssd
rpcidmapd
sendmail
xfs
"
for service in $SERVICE_LIST; do
disable_service $service
done
SERVICE_LIST_PROMPT="
mdmonitor
smartd
yum-updatesd
"
for service in $SERVICE_LIST_PROMPT; do
disable_service $service 1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment