summaryrefslogtreecommitdiff
path: root/contrib/dropnroll-launcher
blob: f0569f39a2cb4b95392547676bf45c4640a7dc0c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#! /bin/sh

if [ -z "$1" ]; then
    echo "Usage: $0 <instance name>"
    exit 1
fi

INST="$1"
NAME=dropnroll
CONFIG_DIR="/etc/$NAME"
VARRUN_DIR=/var/run/$NAME

if [ -d "$CONFIG_DIR/$INST/" ] && [ -e "$CONFIG_DIR/$INST/config" ]; then
    NEWFILE=''
    test -f $CONFIG_DIR/$INST/newfile.sh && NEWFILE="-x $CONFIG_DIR/$INST/newfile.sh"
    CHROOTDIR=`grep '^chroot' < $CONFIG_DIR/$INST/config | sed 's/chroot\s*//'`
    if [ -n "$CHROOTDIR" ] ; then
        test -d $CHROOTDIR || mkdir -p $CHROOTDIR
    fi
    test -d $VARRUN_DIR || mkdir -p $VARRUN_DIR
    DAEMONARG=`sed 's/#.*//' < $CONFIG_DIR/$INST/config | grep -e '\w' | sed  's/^/--/' | tr '\n' ' '`
    exec dropnroll -D --write-pid $VARRUN_DIR/$INST.pid $NEWFILE $DAEMONARG
else
    echo "Instance config directory does not exist or does not contain a config file"
    exit 1
fi

exit 1 # should not be reached unless exec returns because of an error