#!/sbin/runscript
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-cluster/ipvsadm/files/ipvsadm-init,v 1.5 2011/12/04 10:40:20 swegener Exp $

extra_commands="save"

depend() {
        need net
}

checkconfig() {

	checkpath --directory /var/lib/ipvsadm

	if [ ! -f /var/lib/ipvsadm/rules-save ] ; then
		eerror "Not starting ipvsadm. First create some rules then run"
		eerror "/etc/init.d/ipvsadm save"
		return 1
	fi
}

start() {
	checkconfig || return 1
	ebegin "Starting ipvsadm"
	einfo "Clearing previous rules"
	ipvsadm -C
	ipvsadm-restore < /var/lib/ipvsadm/rules-save
	eend $?
}

stop() {
	ebegin "Stopping ipvsadm"
	eend $?
}

save() {
	ebegin "Saving ipvsadm state"
	ipvsadm-save > /var/lib/ipvsadm/rules-save
	eend $?
}

