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
  
29
  
30
  
31
  
32
  
33
  
34
  
35
  
36
  
37
  
38
  
39
  
40
  
41
  
42
  
43
  
44
  
45
  
46
  
47
  
48
  
49
  
50
  
51
  
52
  
53
  
54
  
55
  
56
  
57
  
58
  
59
  
60
  
61
  
62
  
63
  
64
  
65
  
66
  
67
  
68
  
69
  
70
  
71
  
72
  
73
  
74
  
75
  
76
  
77
  
78
  
79
  
80
  
81
  
82
  
83
  
84
  
85
  
86
  
87
  
88
  
89
  
90
  
91
  
92
  
93
  
94
  
95
  
96
  
97
  
98
  
99
  
100
  
101
  
102
  
103
  
104
  
105
  
106
  
107
  
108
  
109
  
110
  
111
  
112
  
113
  
114
  
115
  
116
  
117
  
118
  
119
  
120
  
121
  
122
  
123
  
124
  
125
  
126
  
127
  
128
  
129
  
130
  
131
  
132
  
133
  
134
  
135
  
136
  
137
  
138
  
139
  
140
  
141
  
142
  
143
  
144
  
145
  
146
  
147
  
148
  
149
  
150
  
151
  
152
  
153
  
154
  
155
  
156
  
157
  
158
  
159
  
160
  
161
  
162
  
163
  
164
  
165
  
166
  
167
  
168
  
169
  
170
  
171
  
172
  
173
  
174
  
175
  
176
  
177
  
178
  
179
  
180
  
181
  
182
  
183
  
184
  
185
  
186
  
187
  
188
  
189
  
190
  
191
  
192
  
193
  
194
  
195
  
196
  
197
  
198
  
199
  
200
  
201
  
202
  
203
  
204
  
205
  
206
  
207
  
208
  
209
  
210
  
#!/bin/sh 
# 
# $Id: start,v 1.22 1997/10/11 19:50:44 grubba Exp $ 
 
VERSION=201; BETA=.a; 
 
# Can be set with '--config-dir=DIR' 
DIR=../configurations/ 
LOGDIR=../logs/ 
FILES="default" 
 
# Roxen will create files as the initial user, 
# which it expects to be able to read as the run-time user. 
umask 022 
 
# Pike default Master-program 
if [ -f lib/pike/master.pike ]; then 
  DEFINES="$DEFINES -mlib/pike/master.pike" 
else 
  # This is used with localinstall 
  if [ -f ../pike/src/lib/master.pike ]; then 
    DEFINES="$DEFINES -m../pike/src/lib/master.pike" 
  fi 
fi 
 
# Extra module-path 
if [ -d etc/modules ]; then 
  DEFINES="$DEFINES -Metc/modules" 
fi 
 
# Extra include-path 
if [ -d etc/include ]; then 
  DEFINES="$DEFINES -Ietc/include" 
fi 
 
# Extra include-path (2) 
if [ -d base_server ]; then 
  DEFINES="$DEFINES -Ibase_server" 
fi 
 
# Extra kludge for HPUX 
# HPUX doesn't like group 60001(nobody) 
if uname | grep 'HP-UX' >/dev/null 2>&1; then 
  echo 'WARNING: Applying kludge for HPUX. (see base_server/privs.pike)' 
  DEFINES="$DEFINES -DHPUX_KLUDGE" 
fi 
 
# Enable threads (if available) on Solaris. 
# Most other OS's have thread bugs that cause them or Roxen to crash. 
if uname | grep 'SunOS' >/dev/null 2>&1; then 
  if uname -r | grep '5\.' >/dev/null 2>&1; then 
    echo 'Solaris detected. Enabling threads (if available).' 
    DEFINES="$DEFINES -DENABLE_THREADS" 
  fi 
fi 
 
pike=pike 
if [ -x bin/pike ] ; then pike=bin/pike; fi 
if [ -x bin/roxen ] ; then pike=bin/roxen; fi 
 
rotate () { 
  b=5; 
  for a in 4 3 2 1 ; do mv -f $1.$a $1.$b 2> /dev/null;  b=$a; done 
} 
 
start_roxen() { 
 args="-DROXEN $DEBUG $DEFINES $pass base_server/roxenloader --config-dir=$DIR" 
 echo Executing $pike $args $@ 
 $pike $args $@ 
} 
####### END PREAMBLE 
 
## Parse all arguments. 
## GNU-style, long options only, except for -D, simply passed on. 
parse_args() { 
 while [ ! c"$1" = "c" ] ; do 
  case $1 in 
  -D*) 
   DEFINES="$DEFINES $1" 
  ;; 
# Used by the 'install' script 
  --log-dir=*) 
   LOGDIR=`echo $1 | sed -e 's/--log-dir=//'` 
  ;; 
  --config-dir=*) 
   DIR=`echo $1 | sed -e 's/--config-dir=//'` 
   FILES=`echo $1 | sed -e's/--config-dir=//' -e's/\.//g' -e's./..g' -e 's.-..g'` 
  ;; 
  '--debug') 
    debug=1 
  ;; 
  '--once') 
    once=1 
  ;; 
  '--version') 
    echo Roxen Challenger 1.`expr $VERSION / 100`$BETA`expr $VERSION % 100` 
    exit 0 
  ;; 
  '--help'|'-?') 
  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 
    exit 0 
   ;; 
  *) 
    pass="$pass $1" 
   ;; 
  esac 
  shift 
 done 
} 
 
####### END PREAMBLE 
 
parse_args $@ 
 
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 
 
 
echo $$: Starting the Roxen Challenger World Wide Web server. 
 
./mkdir -p $LOGDIR/debug/ 
 
if [ -z "$debug" ] ; then 
  DEBUG="-DMODULE_DEBUG"; 
else 
  DEBUG="-DDEBUG -DMODULE_DEBUG" 
fi 
 
if [ -z "$once" ] ; then 
  (while : ; do 
    sdfile="/tmp/Roxen_Shutdown_$$" 
    rm $sdfile 
    if [ -f "$sdfile" ] ; then 
      cat << oo 
WARNING: 
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 
      ls -l $sdfile 
      noshutdown="yes" 
    else 
      noshutdown="" 
    fi 
   
    echo $$: "Server restart at `date`" 
    echo $$: "Debug log in $LOGDIR/debug/$FILES.1" 
    rotate $LOGDIR/debug/$FILES 
 
    start_roxen 2>>$LOGDIR/debug/$FILES.1 1>&2 
 
    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. 
 
        echo $$: Server shutdown file detected. Shutting down 
        rm "$sdfile" 
        if [ -f "$sdfile" ] ; then 
          echo $$: "Failed to remove '"$sdfile"'. This could be a problem" 
          exit 0 
        else 
          exit 0 
        fi 
      fi 
    fi 
    echo $$: Roxen died. Restarting in 5 seconds... 
    # Don't take all available CPU if Roxen keeps dieing.  
    sleep 5 
  done 
     
  echo $$: Not Reached "famous last words" 
 
  ) < /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 
 
else 
  echo $$: "Server restart at `date`" 
  start_roxen 
fi