b1fca0 | 1996-11-12 | Per Hedbor | | #!/bin/sh
|
82f519 | 1997-03-02 | Per Hedbor | | VERSION=201; BETA=.a;
|
b1fca0 | 1996-11-12 | Per Hedbor | |
# Can be set with '--config-dir=DIR'
DIR=../configurations/
LOGDIR=../logs/
FILES="default"
|
1c4818 | 1997-03-02 | Henrik Grubbström (Grubba) | | # Pike default Master-program
|
4fed40 | 1997-04-16 | Henrik Grubbström (Grubba) | | if [ -f lib/pike/master.pike ]; then
DEFINES="$DEFINES -m lib/pike/master.pike"
else
if [ -f ../pike/src/lib/master.pike ]; then
DEFINES="$DEFINES -m ../pike/src/lib/master.pike"
fi
|
d0ee18 | 1997-03-01 | Henrik Grubbström (Grubba) | | fi
|
1c4818 | 1997-03-02 | Henrik Grubbström (Grubba) | |
# Extra module-path
|
d0ee18 | 1997-03-01 | Henrik Grubbström (Grubba) | | if [ -d etc/modules ]; then
|
1c4818 | 1997-03-02 | Henrik Grubbström (Grubba) | | DEFINES="$DEFINES -M etc/modules"
fi
# Extra include-path
if [ -d etc/include ]; then
DEFINES="$DEFINES -I etc/include"
fi
# Extra include-path (2)
if [ -d base_server ]; then
DEFINES="$DEFINES -I base_server"
|
d0ee18 | 1997-03-01 | Henrik Grubbström (Grubba) | | fi
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
d0ee18 | 1997-03-01 | Henrik Grubbström (Grubba) | | pike=pike
if [ -x bin/pike ] ; then pike=bin/pike; fi
|
b1fca0 | 1996-11-12 | Per Hedbor | |
rotate () {
b=5;
for a in 4 3 2 1 ; do mv -f $1.$a $1.$b 2> /dev/null; b=$a; done
}
|
d0ee18 | 1997-03-01 | Henrik Grubbström (Grubba) | | start_roxen() {
|
fc2fcf | 1997-04-13 | Per Hedbor | | args="-DROXEN $DEBUG $DEFINES $pass base_server/roxenloader --config-dir=$DIR"
echo Executing $pike $args $@
$pike $args $@
|
d0ee18 | 1997-03-01 | Henrik Grubbström (Grubba) | | }
|
b1fca0 | 1996-11-12 | Per Hedbor | | ####### END PREAMBLE
## Parse all arguments.
|
82f519 | 1997-03-02 | Per Hedbor | | ## GNU-style, long options only, except for -D, simply passed on.
parse_args() {
while [ ! c"$1" = "c" ] ; do
|
b1fca0 | 1996-11-12 | Per Hedbor | | case $1 in
|
4019f8 | 1997-03-01 | Per Hedbor | | -D*)
DEFINES="$DEFINES $1"
;;
|
82f519 | 1997-03-02 | Per Hedbor | | # Used by the 'install' script
|
b1fca0 | 1996-11-12 | Per Hedbor | | --log-dir=*)
LOGDIR=`echo $1 | sed -e 's/--log-dir=//'`
;;
--config-dir=*)
DIR=`echo $1 | sed -e 's/--config-dir=//'`
|
6a8566 | 1997-04-10 | Henrik Grubbström (Grubba) | | FILES=`echo $1 | sed -e's/--config-dir=//' -e's/\.//g' -e's./..g' -e 's.-..g'`
|
b1fca0 | 1996-11-12 | Per Hedbor | | ;;
|
59f64b | 1997-01-27 | Per Hedbor | | '--debug')
debug=1
;;
|
a8135b | 1996-11-12 | Per Hedbor | | '--once')
once=1
;;
|
b1fca0 | 1996-11-12 | Per Hedbor | | '--version')
|
82f519 | 1997-03-02 | Per Hedbor | | echo 1.`expr $VERSION / 100`$BETA`expr $VERSION % 100`
|
b1fca0 | 1996-11-12 | Per Hedbor | | exit 0
;;
'--help'|'-?')
|
82f519 | 1997-03-02 | Per Hedbor | | tput 'bold' 2>/dev/null
cat << EOF
Syntax: $0 [--version] [--config-dir=DIR] [--log-dir=DIR] [-DDEFINE]
This command will start the Roxen server.
If the configuration dir is set, a different set of debuglogfiles
will be used.
The environment variable ROXEN_ARGS can be used to specify
the default arguments.
EOF
tput 'rmso' 2>/dev/null
|
b1fca0 | 1996-11-12 | Per Hedbor | | exit 0
;;
*)
pass="$pass $1"
|
5e87b4 | 1997-04-09 | Henrik Grubbström (Grubba) | | ;;
|
b1fca0 | 1996-11-12 | Per Hedbor | | esac
shift
|
82f519 | 1997-03-02 | Per Hedbor | | done
}
####### END PREAMBLE
parse_args $@
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
82f519 | 1997-03-02 | Per Hedbor | | if [ ! "X$ROXEN_ARGS" = "X" ]; then
echo $$: Using $ROXEN_ARGS from ROXEN_ARGS.
parse_args $ROXEN_ARGS
fi
if [ ! "X$pass" = "X" ] ; then set $pass ;fi
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
82f519 | 1997-03-02 | Per Hedbor | | echo $$: Starting the Roxen Challenger World Wide Web server.
|
b1fca0 | 1996-11-12 | Per Hedbor | |
./mkdir -p $LOGDIR/debug/
|
59f64b | 1997-01-27 | Per Hedbor | | if [ -z "$debug" ] ; then
|
fc2fcf | 1997-04-13 | Per Hedbor | | DEBUG="-DMODULE_DEBUG";
|
59f64b | 1997-01-27 | Per Hedbor | | else
DEBUG="-DDEBUG -DMODULE_DEBUG"
fi
|
a8135b | 1996-11-12 | Per Hedbor | | if [ -z "$once" ] ; then
(while : ; do
sdfile="/tmp/Roxen_Shutdown_$$"
rm $sdfile
if [ -f "$sdfile" ] ; then
cat << oo
|
82f519 | 1997-03-02 | Per Hedbor | | WARNING:
|
b1fca0 | 1996-11-12 | Per Hedbor | | A shutdown file '('$sdfile')' is present, and the file cannot be
removed by this script.
Please remove this file, or you might be unable to shut down Roxen in
the future.
The file:
oo
|
82f519 | 1997-03-02 | Per Hedbor | | ls -l $sdfile
|
b1fca0 | 1996-11-12 | Per Hedbor | | noshutdown="yes"
else
noshutdown=""
fi
|
82f519 | 1997-03-02 | Per Hedbor | | echo $$: "Server restart at `date`"
|
6a8566 | 1997-04-10 | Henrik Grubbström (Grubba) | | echo $$: "Debug log in $LOGDIR/debug/$FILES.1"
|
b1fca0 | 1996-11-12 | Per Hedbor | | rotate $LOGDIR/debug/$FILES
|
82f519 | 1997-03-02 | Per Hedbor | |
|
6c70be | 1997-03-03 | Henrik Grubbström (Grubba) | | start_roxen 2>>$LOGDIR/debug/$FILES.1 1>&2
|
82f519 | 1997-03-02 | Per Hedbor | |
|
b1fca0 | 1996-11-12 | Per Hedbor | | if [ -z "$noshutdown" ] ; then
if [ -f "$sdfile" ] ; then
# A shutdown file. This is only done if Roxen cannot kill this script
# for some reason, the most common beeing the lack of a seteuid()
# function, in which case Roxen will write this file.
#
# The contents of the file is the actual PID Roxen got when it was
# started. This could be used to verify that this was the correct
# shutdown file, but since it is extremely unlikely that two
# start-scripts get the same PID, this is not done.
|
82f519 | 1997-03-02 | Per Hedbor | | echo $$: Server shutdown file detected. Shutting down
|
b1fca0 | 1996-11-12 | Per Hedbor | | rm "$sdfile"
if [ -f "$sdfile" ] ; then
|
82f519 | 1997-03-02 | Per Hedbor | | echo $$: "Failed to remove '"$sdfile"'. This could be a problem"
|
b1fca0 | 1996-11-12 | Per Hedbor | | exit 0
else
exit 0
fi
fi
fi
done
|
fc2fcf | 1997-04-13 | Per Hedbor | | echo $$: Not Reached "famous last words"
|
b1fca0 | 1996-11-12 | Per Hedbor | |
) < /dev/null > $LOGDIR/debug/start_$FILES.output 2>&1&
cat << oo
Using configuration from $DIR, storing the debug log in $LOGDIR/debug/$FILES.1
You can use the configuration interface in the server to get debug info.
oo
|
82f519 | 1997-03-02 | Per Hedbor | |
|
a8135b | 1996-11-12 | Per Hedbor | | else
|
82f519 | 1997-03-02 | Per Hedbor | | echo $$: "Server restart at `date`"
|
4019f8 | 1997-03-01 | Per Hedbor | | start_roxen
|
a8135b | 1996-11-12 | Per Hedbor | | fi
|
fc2fcf | 1997-04-13 | Per Hedbor | |
|