75 lines
1.8 KiB
Bash
75 lines
1.8 KiB
Bash
#!/bin/sh
|
|
#
|
|
# Startup script handle the initialisation of LVS
|
|
# chkconfig: - 08 92
|
|
# description: Initialise the Linux Virtual Server
|
|
# config: /etc/sysconfig/ipvsadm
|
|
#
|
|
### BEGIN INIT INFO
|
|
# Provides: ipvsadm
|
|
# Required-Start: $local_fs $network $named
|
|
# Required-Stop: $local_fs $remote_fs $network
|
|
# Short-Description: Initialise the Linux Virtual Server
|
|
# Description: The Linux Virtual Server is a highly scalable and highly
|
|
# available server built on a cluster of real servers, with the load
|
|
# balancer running on Linux.
|
|
### END INIT INFO
|
|
|
|
# set the configuration file
|
|
IPVSADM_CONFIG="/etc/sysconfig/ipvsadm"
|
|
|
|
# Source function library
|
|
. /etc/rc.d/init.d/functions
|
|
|
|
start() {
|
|
# If we don't clear these first, we might be adding to pre-existing rules.
|
|
action "Clearing the current IPVS table:" ipvsadm -C
|
|
echo -n "Applying IPVS configuration: "
|
|
ipvsadm-restore < ${IPVSADM_CONFIG} && \
|
|
success "Applying IPVS configuration" || \
|
|
failure "Applying IPVS configuration"
|
|
echo
|
|
touch /var/lock/subsys/ipvsadm
|
|
}
|
|
|
|
stop() {
|
|
action "Clearing the current IPVS table:" ipvsadm -C
|
|
rm -f /var/lock/subsys/ipvsadm
|
|
}
|
|
|
|
save() {
|
|
echo -n "Saving IPVS table to ${IPVSADM_CONFIG}: "
|
|
ipvsadm-save -n > ${IPVSADM_CONFIG} 2>/dev/null && \
|
|
success "Saving IPVS table to ${IPVSADM_CONFIG}" || \
|
|
failure "Saving IPVS table to ${IPVSADM_CONFIG}"
|
|
echo
|
|
}
|
|
|
|
# See how we were called.
|
|
case "$1" in
|
|
start)
|
|
# If we have no configuration, save the current one
|
|
[ -f ${IPVSADM_CONFIG} ] || save
|
|
start
|
|
;;
|
|
stop)
|
|
stop
|
|
;;
|
|
reload|force-reload|restart)
|
|
# Start will flush everything, so it counts as a restart
|
|
start
|
|
;;
|
|
status)
|
|
ipvsadm -L -n
|
|
;;
|
|
save)
|
|
save
|
|
;;
|
|
*)
|
|
echo "Usage: $0 {start|stop|restart|force-reload|status|save}"
|
|
exit 3
|
|
esac
|
|
|
|
exit 0
|
|
|