]> git.ipfire.org Git - ipfire-2.x.git/blame - src/initscripts/system/apache
Merge remote-tracking branch 'origin/next' into kernel-4.14
[ipfire-2.x.git] / src / initscripts / system / apache
CommitLineData
23104841
MT
1#!/bin/sh
2# Begin $rc_base/init.d/apache
3
4# Based on sysklogd script from LFS-3.1 and earlier.
5# Rewritten by Gerard Beekmans - gerard@linuxfromscratch.org
6
23104841
MT
7. /etc/sysconfig/rc
8. $rc_functions
9
9064ba72
AF
10generate_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
d4092860 14 chmod 600 /etc/httpd/server.key
9064ba72
AF
15 evaluate_retval
16 fi
17
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
d4092860 22 chmod 600 /etc/httpd/server-ecdsa.key
9064ba72
AF
23 evaluate_retval
24 fi
25
26 # Generate RSA CSR
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
31 fi
32
33 # Generate ECDSA CSR
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
38 fi
39
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
46 evaluate_retval
47 fi
48
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
55 evaluate_retval
56 fi
57}
58
23104841
MT
59case "$1" in
60 start)
9064ba72
AF
61 # Generate all required certificates
62 generate_certificates
63
75474c3c 64 boot_mesg "Starting Apache daemon..."
23104841
MT
65 /usr/sbin/apachectl -k start
66 evaluate_retval
67 ;;
68
69 stop)
70 boot_mesg "Stopping Apache daemon..."
11e900e0 71 killproc /usr/sbin/httpd
23104841
MT
72 evaluate_retval
73 ;;
74
75 restart)
76 boot_mesg "Restarting Apache daemon..."
77 /usr/sbin/apachectl -k restart
78 evaluate_retval
79 ;;
256575b3
CS
80
81 reload)
82 boot_mesg "Reloading Apache daemon..."
83 /usr/sbin/apachectl -k graceful
84 evaluate_retval
85 ;;
23104841
MT
86
87 status)
88 statusproc /usr/sbin/httpd
89 ;;
90
91 *)
92 echo "Usage: $0 {start|stop|restart|status}"
93 exit 1
94 ;;
95esac
96
97# End $rc_base/init.d/apache