#!/bin/sh

# $Id: update-lyxrc,v 1.2 2004/03/04 11:51:20 dexter Exp $

# pod2man --section=1 --release="Debian" --center=" " --date="26 Feb 2004"

error () {
    echo "$@" 1>&2
    exit 1
}


help () {
    echo "Usage: update-lyxrc [ --system | --user ]"
    exit 1
}


configure () {
    test -d "$1" || error "Can't find directory $1"
    touch "$1/lyxrc.defaults" || exit 1
    cd "$1" || exit 1
    /usr/share/lyx/configure
}


system () {
    configure /usr/share/lyx
}


user () {
    configure "$HOME/.lyx"
}


if [ "$#" -gt 1 ]; then
    help
else
    if [ -n "$1" ]; then
        case "$1" in
            --system) system;;
            --user) user;;
            *) help;;
        esac
    else
        if [ "$(id -u)" = "0" ]; then
            system
        else
            user
        fi
    fi
fi

exit 0

cat << END

=head1 NAME

update-lyxrc - Update LyX default configuration

=head1 SYNOPSIS

B<update-lyxrc> S<[B<--system>|B<--user>]>

=head1 DESCRIPTION

B<update-lyxrc> is a tool for updating system or user's LyX
configuration file. This is the same as running Edit->Reconfigure from
LyX's menu.

=head1 OPTIONS

=over 8

=item B<--system>

Update system configuration. This is default for root.

=item B<--user>

Update user's configuration. This is default for non-root.

=back

=head1 SEE ALSO

B<lyx>(1)

=head1 AUTHOR

(c) 2004 Piotr Roszatycki E<lt>dexter@debian.orgE<gt>.
