+ # Create an empty configuration database if it doesn't exist.
+ if test ! -e $conf_file; then
+ # Create configuration database.
+ ovsdb-tool -vANY:console:emer create $conf_file $schema_file
+ elif test "X`ovsdb-tool needs-conversion $conf_file $schema_file`" != Xno; then
+ # Back up the old version.
+ version=`ovsdb-tool db-version "$conf_file"`
+ cksum=`ovsdb-tool db-cksum "$conf_file" | awk '{print $1}'`
+ cp "$conf_file" "$conf_file.backup$version-$cksum"
+
+ # Compact database. This is important if the old schema did not
+ # enable garbage collection (i.e. if it did not have any tables
+ # with "isRoot": true) but the new schema does. In that situation
+ # the old database may contain a transaction that creates a record
+ # followed by a transaction that creates the first use of the
+ # record. Replaying that series of transactions against the new
+ # database schema (as "convert" does) would cause the record to be
+ # dropped by the first transaction, then the second transaction
+ # would cause a referential integrity failure (for a strong
+ # reference).
+ ovsdb-tool -vANY:console:emer compact $conf_file
+
+ # Upgrade or downgrade schema and compact database.
+ ovsdb-tool -vANY:console:emer convert $conf_file $schema_file
+ fi
+
+ if test "$ENABLE_MONITOR" = y; then
+ monitor_opt=--monitor
+ else
+ monitor_opt=
+ fi
+
+ if [ ! -d /var/run/openvswitch ]; then
+ install -d -m 755 -o root -g root /var/run/openvswitch
+ fi
+
+ if [ ! -d /var/log/openvswitch ]; then
+ install -d -m 755 -o root -g root /var/log/openvswitch
+ fi
+
+ if [ ! -d /var/log/openvswitch/cores ]; then
+ install -d -m 755 -o root -g root /var/log/openvswitch/cores
+ fi
+