2014-07-31 18:05:32 +04:00
#!/bin/bash
2014-07-31 18:39:59 +04:00
#
# ansible-tower
#
# chkconfig: - 20 80
# description: support init to manage tower and its related services
2014-07-30 21:18:42 +04:00
2014-07-31 18:39:59 +04:00
### BEGIN INIT INFO
# Provides:
# Required-Start:
# Required-Stop:
# Should-Start:
# Should-Stop:
# Default-Start:
# Default-Stop:
# Short-Description: support init to manage tower and its related services
# Description: Ansible Tower provides an easy-to-use UI and dashboard, role-based access control and more for your Ansible initiative
### END INIT INFO
2014-07-30 21:18:42 +04:00
if [ -e /etc/debian_version ]
then
2014-07-31 18:05:32 +04:00
SERVICES=(postgresql rabbitmq-server apache2 supervisor)
2014-07-30 21:18:42 +04:00
else
SERVICES=(postgresql rabbitmq-server httpd supervisord)
fi
service_action() {
for svc in ${SERVICES[@]}; do
2014-08-01 17:50:51 +04:00
service ${svc} $1
this_return=$?
if [ $this_return -gt $worst_return ]; then
worst_return=$this_return
fi
2014-07-30 21:18:42 +04:00
done
}
2014-08-01 17:50:51 +04:00
worst_return=0
2014-07-30 21:18:42 +04:00
case "$1" in
start)
echo "Starting Tower"
service_action start
;;
stop)
echo "Stopping Tower"
service_action stop
;;
restart)
echo "Restarting Tower"
2014-07-31 18:05:32 +04:00
service_action stop
service_action start
2014-07-30 21:18:42 +04:00
;;
status)
echo "Showing Tower Status"
service_action status
;;
*)
2014-07-31 18:39:59 +04:00
echo "Usage: $0 {start|stop|restart|status}"
2014-07-30 21:18:42 +04:00
esac
2014-08-01 17:50:51 +04:00
exit $worst_return