#! /bin/bash

# Manual page header
echo $'
===============
 vserver-admin
===============

-------------------------------------
Administrate vServer virtual machines
-------------------------------------

:Author: Adrian Perez <aperez@igalia.com>
:Manual section: 1

SYNOPSIS
========

``vserver-admin action [arguments...]``

DESCRIPTION
===========

``vserver-admin`` allows to automate management of vServer virtual machines,
and is especially handy when storing each machine into a LVM logical volume
by itself, because it will happily handle the hassle of creating, resizing,
formatting and removing volumes by itself when needed.

USAGE
=====
'

for action in vserver-admin-*
do
	desc=$(sed -e '/^##-/p' -e d "${action}")
	usage=$(sed -e '/^##:/p' -e d "${action}")

	actionname=${action#vserver-admin-}

	echo "\`\`vserver-admin ${actionname}${usage#\#\#:}\`\`"
	while read -r line ; do
		echo "  ${line}"
	done <<< "${desc#\#\#-}"
	echo
	while read -r dummy argname argdesc ; do
		echo "  :${argname}: ${argdesc}"
	done < <( sed -e '/^##+/p' -e d "${action}" )
	echo
done


echo '
RETURN VALUE
============

``vserver-admin`` returns exit status 0 on success.

ENVIRONMENT
===========

The ``VSERVER_ADMIN_CONF`` environment variable may be defined to specify an
alternative configuration other than ``/etc/admintools/vserver-admin.conf``.

Debugging output can be achieved by defining ``VSERVER_ADMIN_DEBUG`` to
a non-zero, integer value. Debug levels are cumulative, in the sense that
a particular level includes features from the lower ones along with its
own debugging features. Currently, debugging levels do the following:

:``VSERVER_ADMIN_DEBUG=0``: No debugging output is ever produced.
:``VSERVER_ADMIN_DEBUG=1``: External commands and actions being taken are
	printed to standard output, prefixed with three stars (``***``). Prints
	out configuration values loaded from the configuration file. Disables the
	checks for a vServer-enabled kernel and the presence of the vServer
	utilities.
:``VSERVER_ADMIN_DEBUG=2``: Disables execution of commands and actions
	prefixed with three stars (``***``).
:``VSERVER_ADMIN_DEBUG=3``: Enables tracing in the shell with ``set -x``.

FILES
=====

The configuration file must be present at
``/etc/admintools/vserver-admin.conf``.
'


