- $DAEMON --configtest >/dev/null 2>&1
- if [ $? -ne 0 ]; then
- echo "Configuration of $NAME is not valide, won't (re)start!"
- echo "Please run \"$DAEMON --configtest\" manually and fix it up ..."
- exit 1
+ # Make sure that the configuration of ngIRCd is valid:
+ $DAEMON $PARAMS --configtest >/dev/null 2>&1
+ [ $? -eq 0 ] && return 0
+ log_end_msg 1
+ log_failure_msg "Configuration of $NAME is not valid, won't (re)start!"
+ log_failure_msg "Run \"$DAEMON --configtest\" and fix it up ..."
+ exit 6
+}
+
+Prepare() {
+ # Make sure the PID file directory exists and is writable:
+ user=`$DAEMON $PARAMS -t|tr -d ' '|grep "^ServerUID="|cut -d'=' -f2`
+ group=`$DAEMON $PARAMS -t|tr -d ' '|grep "^ServerGID="|cut -d'=' -f2`
+ piddir=`dirname "$PIDFILE"`
+ [ -d "$piddir" ] || mkdir -p "$piddir" 2>/dev/null
+ chown "$user:$group" "$piddir" 2>/dev/null
+ [ $? -eq 0 ] && return 0
+ log_end_msg 1
+ log_failure_msg "Failed to prepare '$piddir' for user '$user'!"
+ exit 1
+}
+
+Do_Start() {
+ if Do_Status; then
+ log_end_msg 0
+ log_warning_msg "$NAME seems to be already running, nothing to do."
+ exit 0