service.bash
1 # A wrapper around service in order to allow taking actions on multiple services 2 # e.g 3 # service celeryd* status 4 # service redis* restart 5 6 service(){ 7 if [[ -n "$1" && -n "$2" ]] ; then 8 local _command="$2" 9 local _services=(`find /etc/init.d/ -name "$1" -printf '%f\n'`) 10 shift 2 11 echo -e "Executing ${_command} on ${_services[*]}\n" 12 for s in "${_services[@]}" ; do 13 sudo service $s $_command $* 14 done 15 else 16 sudo service $* 17 fi 18 }