Add some scripts to convert a legacy config to the new tree.
[util-vserver.git] / scripts / convert-vserver-configs
diff --git a/scripts/convert-vserver-configs b/scripts/convert-vserver-configs
new file mode 100644 (file)
index 0000000..786fa10
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/bash
+#
+# $Id$
+# Copyright (C) 2007 The Trustees of Princeton University
+#
+
+: ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars}
+test -e "$UTIL_VSERVER_VARS" || {
+    echo $"Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2
+    exit 1
+}
+. "$UTIL_VSERVER_VARS"
+
+for i in $__CONFDIR/*.conf; do
+    if test -r "$i"; then
+       vserver=`echo "$i" | sed "s@$__CONFDIR/@@;s@\.conf@@"`
+       echo "Processing '$vserver'"
+       if ! $_VSERVER "$vserver" convert; then
+           echo "ERROR: '$vserver' could not be converted" >&2
+       fi
+    fi
+done
+
+exit 0