mirror of
https://github.com/billz/raspap-webgui.git
synced 2023-10-10 13:37:24 +02:00
Added configure_lighttpd()
This commit is contained in:
parent
23d1ab83c7
commit
7914110a77
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
certname=$HOSTNAME."local"
|
certname=$HOSTNAME."local"
|
||||||
lighttpd_ssl="/etc/lighttpd/ssl"
|
lighttpd_ssl="/etc/lighttpd/ssl"
|
||||||
|
lighttpd_conf="/etc/lighttpd/lighttpd.conf"
|
||||||
webroot_dir="/var/www/html"
|
webroot_dir="/var/www/html"
|
||||||
|
|
||||||
### NOTE: all the below functions are overloadable for system-specific installs
|
### NOTE: all the below functions are overloadable for system-specific installs
|
||||||
@ -72,9 +73,10 @@ function generate_certificate() {
|
|||||||
|
|
||||||
# Create a directory for the combined .pem file in lighttpd
|
# Create a directory for the combined .pem file in lighttpd
|
||||||
function create_lighttpd_dir() {
|
function create_lighttpd_dir() {
|
||||||
#todo: check for existence
|
|
||||||
install_log "Create SLL directory for lighttpd"
|
install_log "Create SLL directory for lighttpd"
|
||||||
|
if [ ! -d "$lighttpd_ssl" ]; then
|
||||||
sudo mkdir -p "$lighttpd_ssl" || install_error "Failed to create lighttpd directory"
|
sudo mkdir -p "$lighttpd_ssl" || install_error "Failed to create lighttpd directory"
|
||||||
|
fi
|
||||||
echo "OK"
|
echo "OK"
|
||||||
|
|
||||||
install_log "Setting permissions and moving .pem file"
|
install_log "Setting permissions and moving .pem file"
|
||||||
@ -86,7 +88,25 @@ function create_lighttpd_dir() {
|
|||||||
# Edit the lighttpd configuration
|
# Edit the lighttpd configuration
|
||||||
function configure_lighttpd() {
|
function configure_lighttpd() {
|
||||||
install_log "Configuring lighttpd for SSL"
|
install_log "Configuring lighttpd for SSL"
|
||||||
|
# Generate config to enable SSL in lighttpd
|
||||||
|
lines=(
|
||||||
|
'server.modules += ("mod_openssl")'
|
||||||
|
'$SERVER["socket"] == ":443" {'
|
||||||
|
'ssl.engine = "enable"'
|
||||||
|
'ssl.pemfile = "'$lighttpd_ssl/$certname'.pem"'
|
||||||
|
'ssl.ca-file = "/home/pi/.local/share/mkcert/rootCA.pem"'
|
||||||
|
'server.name = "'$certname'"'
|
||||||
|
'server.document-root = "'${webroot_dir}'"}'
|
||||||
|
)
|
||||||
|
for line in "${lines[@]}"; do
|
||||||
|
if grep -Fxq "${line}" "${lighttpd_conf}" > /dev/null; then
|
||||||
|
echo "$line: Line already added"
|
||||||
|
else
|
||||||
|
sudo sed -i "$ a $line" $lighttpd_conf
|
||||||
|
echo "Adding line $line"
|
||||||
|
fi
|
||||||
|
#echo $line
|
||||||
|
done
|
||||||
echo "OK"
|
echo "OK"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user