blob: 982cbdcc8174258bc957970c22ead1a330625999 (
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
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
|
#!/bin/sh
#
# $FreeBSD$
# PROVIDE: apache
# REQUIRE: DAEMON
# KEYWORD: FreeBSD shutdown
#
# NOTE for FreeBSD 5.0+:
# If you want this script to start with the base rc scripts
# move apache.sh to /etc/rc.d/apache
# Define the following apache_* variables in one of the following:
# /etc/rc.conf
# /etc/rc.conf.d/apache
# ${prefix}/etc/rc.conf.d/apache
#
# apache_enable - Set to YES to enable apache
#
# apache_program - Path to apache program
# Default: ${prefix}/sbin/httpd
#
# apache_start - Subcommand sent to apachectl to control how
# httpd is started.
# Default: start_FP
prefix=%%PREFIX%%
apache_doit ()
{
case $1 in
start) action=${apache_start} ;;
reload) action=graceful ;;
*) action=$1 ;;
esac
${ctl_command} ${action}
}
# Create New FrontPage suidkey
new_key() {
CUR_UMASK=`umask`
skdir=${prefix}/frontpage/version%%FP_VER%%/apache-fp
PERL=%%PERL5%%
if [ -x ${prefix}/libexec/apache/mod_frontpage.so ]
then
#NOTE: We need Perl 5, to generate a new key
if [ -x ${PERL} ]
then
umask 077
${PERL} -e '@a=(split(//, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*-=_+")); print((map {$a[rand(scalar @a)]} (1..128)), "\n");' > $skdir/suidkey
umask ${CUR_UMASK}
fi
fi
}
if [ -f /etc/rc.subr ]; then
. /etc/rc.subr
name="apache"
rcvar=`set_rcvar`
command="${prefix}/sbin/httpd"
ctl_command="${prefix}/sbin/apachectl"
# pidfile=/var/run/httpd.pid
required_files="${prefix}/etc/apache/httpd.conf"
extra_commands="reload"
start_precmd="new_key"
start_cmd="apache_doit start"
stop_cmd="apache_doit stop"
restart_cmd="apache_doit restart"
reload_cmd="apache_doit reload"
# The below may be removed when load_local_rc_config is added to rc.subr
if [ -f ${prefix}/etc/rc.conf.d/"$name" ]; then
debug "Sourcing ${prefix}/etc/rc.conf.d/${name}"
. ${prefix}/etc/rc.conf.d/"$name"
fi
load_rc_config $name
if [ -z "${apache_enable}" ] ; then
apache_enable=yes
fi
# The above may be removed when load_local_rc_config is added to rc.subr
#
# load_local_rc_config $name
if [ -z "${apache_start}" ]; then
apache_start="start_FP"
fi
run_rc_command "$1"
else
if [ -f ${prefix}/etc/rc.conf.d/apache ]; then
. ${prefix}/etc/rc.conf.d/apache
fi
if [ -z '${apache_start}" ]; then
apache_start="start_FP"
fi
case "$1" in
start)
if [ -x ${prefix}/sbin/apachectl ]; then
new_key
${prefix}/sbin/apachectl ${apache_start} && echo -n ' httpd'
fi
;;
stop)
if [ -r /var/run/httpd.pid ]; then
${prefix}/sbin/apachectl stop && echo -n ' httpd'
fi
;;
*)
echo "usage: $0 {start|stop}" 1>&2
exit 64
;;
esac
fi
|