1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-02 09:51:09 +03:00
awx/tools/scripts/ansible-tower

67 lines
1.6 KiB
Plaintext
Raw Normal View History

2014-07-31 18:05:32 +04:00
#!/bin/bash
#
# ansible-tower
#
# chkconfig: - 20 80
# description: support init to manage tower and its related services
2014-07-30 21:18:42 +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
# 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
# Default configured services
if [ -e /etc/debian_version ]; then
TOWER_CONFIG="/etc/default/ansible-tower"
2014-07-30 21:18:42 +04:00
else
TOWER_CONFIG="/etc/sysconfig/ansible-tower"
2014-07-30 21:18:42 +04:00
fi
# Load default configuration
[ -e "${TOWER_CONFIG}" ] && . "${TOWER_CONFIG}"
2014-07-30 21:18:42 +04:00
service_action() {
for svc in ${TOWER_SERVICES}; do
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
}
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
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
2014-07-30 21:18:42 +04:00
esac
exit $worst_return