#!/bin/sh -e

LOCALBASE=$(cluster-localbase)
CONF_DIR=$LOCALBASE/etc/spcm

if ! fgrep -q lowest-uid $CONF_DIR/spcm.conf 2> /dev/null; then
    cat << EOM >> /dev/stderr

You must indicate the lowest UID for a regular cluster user on this
system.  This setting is used by the cluster-users script to identify
users who must exist on all nodes.

This UID should be higher than any UIDs used for system accounts such
as daemon, apache, www, etc., which are typically below 500.

If users already exist on this system, check /etc/password to determine
the lowest UID in use.

EOM
    printf "Lowest UID for regular users on this cluster? [2000] " >> `tty`
    read lowest_uid
    if [ 0$lowest_uid = 0 ]; then
	lowest_uid=2000
    fi
    printf "lowest-uid $lowest_uid\n" >> $CONF_DIR/spcm.conf
fi

awk '$1 == "lowest-uid" { print $2 }' $CONF_DIR/spcm.conf

