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
2014-08-01 21:26:52 +04:00
# Required-Start: $local_fs $remote_fs $network $named
# Required-Stop: $local_fs $remote_fs $network
# Should-Start: distcache
2014-11-12 17:21:05 +03:00
# Should-Stop:
# Default-Start:
# Default-Stop:
2014-07-31 18:39:59 +04:00
# 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
2014-11-25 00:28:13 +03:00
# Default configured services
if [ -e /etc/debian_version ]; then
2014-11-25 17:22:02 +03:00
TOWER_CONFIG="/etc/default/ansible-tower"
2014-07-30 21:18:42 +04:00
else
2014-11-25 17:22:02 +03:00
TOWER_CONFIG="/etc/sysconfig/ansible-tower"
2014-07-30 21:18:42 +04:00
fi
2014-11-25 17:22:02 +03:00
# Load default configuration
2014-11-25 00:28:13 +03:00
[ -e "${TOWER_CONFIG}" ] && . "${TOWER_CONFIG}"
2014-07-30 21:18:42 +04:00
service_action() {
2014-11-25 17:22:02 +03:00
for svc in ${TOWER_SERVICES}; do
2014-11-17 21:25:33 +03:00
service ${svc} $1
this_return=$?
if [ $this_return -gt $worst_return ]; then
worst_return=$this_return
fi
# Allow supervisor time to cleanup child pids (ubuntu only)
if [[ ${svc} == supervisor* && ${1} == stop && -e /etc/debian_version ]]; then
echo "Waiting to allow supervisor time to cleanup ..."
sleep 5
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