#!/bin/sh /etc/rc.common
# Copyright (C) 2013 Julius Schulz-Zander <julius@net.t-labs.tu-berlin.de>
# Copyright (C) 2014 OpenWrt.org

START=15
USE_PROCD=1

start_service() {
	[ -x /var/run/openvswitch ] || mkdir -p /var/run/openvswitch
	[ -e /etc/openvswitch/conf.db ] || {
		/usr/bin/ovsdb-tool create /etc/openvswitch/conf.db /usr/share/openvswitch/vswitch.ovsschema
	}

	# ovsdb-server
	procd_open_instance
	procd_set_param command /usr/sbin/ovsdb-server
	procd_append_param command --remote=punix:/var/run/db.sock
	procd_append_param command --remote=db:Open_vSwitch,Open_vSwitch,manager_options
	procd_append_param command --pidfile=/var/run/ovsdb-server.pid
	procd_set_param respawn
	procd_append_param respawn 3600
	procd_append_param respawn 5
	procd_append_param respawn -1
	procd_set_param nice
	procd_append_param nice -10
	procd_close_instance

	# ovs-vswitchd
	procd_open_instance
	procd_set_param command /usr/sbin/ovs-vswitchd
	procd_append_param command --pidfile=/var/run/ovs-vswitchd.pid
	procd_set_param respawn
	procd_append_param respawn 3600
	procd_append_param respawn 5
	procd_append_param respawn -1
	procd_set_param nice
	procd_append_param nice -10
	procd_close_instance

}

