]>
git.ipfire.org Git - ipfire-2.x.git/blob - src/initscripts/system/apache
2 # Begin $rc_base/init.d/apache
4 # Based on sysklogd script from LFS-3.1 and earlier.
5 # Rewritten by Gerard Beekmans - gerard@linuxfromscratch.org
10 generate_certificates
() {
11 if [ ! -f "/etc/httpd/server.key" ]; then
12 boot_mesg
"Generating HTTPS RSA server key (this will take a moment)..."
13 openssl genrsa
-out /etc
/httpd
/server.key
4096 &>/dev
/null
14 chmod 600 /etc
/httpd
/server.key
18 if [ ! -f "/etc/httpd/server-ecdsa.key" ]; then
19 boot_mesg
"Generating HTTPS ECDSA server key..."
20 openssl ecparam
-genkey -name secp384r1
-noout \
21 -out /etc
/httpd
/server-ecdsa.key
&>/dev
/null
22 chmod 600 /etc
/httpd
/server-ecdsa.key
27 if [ ! -f "/etc/httpd/server.csr" ]; then
28 sed "s/HOSTNAME/`hostname -f`/" < /etc
/certparams | \
29 openssl req
-new -key /etc
/httpd
/server.key \
30 -out /etc
/httpd
/server.csr
&>/dev
/null
34 if [ ! -f "/etc/httpd/server-ecdsa.csr" ]; then
35 sed "s/HOSTNAME/`hostname -f`/" < /etc
/certparams | \
36 openssl req
-new -key /etc
/httpd
/server-ecdsa.key \
37 -out /etc
/httpd
/server-ecdsa.csr
&>/dev
/null
40 if [ ! -f "/etc/httpd/server.crt" ]; then
41 boot_mesg
"Signing RSA certificate..."
42 openssl x509
-req -days 999999 -sha256 \
43 -in /etc
/httpd
/server.csr \
44 -signkey /etc
/httpd
/server.key \
45 -out /etc
/httpd
/server.crt
&>/dev
/null
49 if [ ! -f "/etc/httpd/server-ecdsa.crt" ]; then
50 boot_mesg
"Signing ECDSA certificate..."
51 openssl x509
-req -days 999999 -sha256 \
52 -in /etc
/httpd
/server-ecdsa.csr \
53 -signkey /etc
/httpd
/server-ecdsa.key \
54 -out /etc
/httpd
/server-ecdsa.crt
&>/dev
/null
61 # Generate all required certificates
65 echo "ServerName ${HOSTNAME}" > /etc
/httpd
/conf
/hostname.conf
67 boot_mesg
"Starting Apache daemon..."
68 /usr
/sbin
/apachectl
-k start
73 boot_mesg
"Stopping Apache daemon..."
74 killproc
/usr
/sbin
/httpd
79 boot_mesg
"Restarting Apache daemon..."
80 /usr
/sbin
/apachectl
-k restart
85 boot_mesg
"Reloading Apache daemon..."
86 /usr
/sbin
/apachectl
-k graceful
91 statusproc
/usr
/sbin
/httpd
95 echo "Usage: $0 {start|stop|restart|status}"
100 # End $rc_base/init.d/apache