不要なサービスを停止するBシェルスクリプト

こんな感じかな。


#!/bin/bash
#あるサービス
services=(`ls -1 /etc/init.d/`)
#停止したいサービス
stop_services=("apmd" "bluetooth" "cups" "hidd")
#サービス停止&ブート時のランレベル2345でoff
for stop_service in "${stop_services[@]}"
do
for service in ${services[@]}
do
if [ $service = $stop_service ]; then
service $stop_service stop
chkconfig --level 2345 $stop_service off
fi
done
done
#状態を確認(エラーはファイルに流す)
for stop_service in "${stop_services[@]}"
do
chkconfig --list $stop_service
done 2>service_stop_error
exit 0