1
0
mirror of https://github.com/billz/raspap-webgui.git synced 2023-10-10 13:37:24 +02:00

Cleanup + error handling

This commit is contained in:
billz 2019-11-07 18:04:41 +00:00
parent c5c283b2e3
commit a66bb13703

View File

@ -67,13 +67,13 @@ function generate_certificate() {
mkcert $certname "*.${certname}.local" $certname || install_error "Failed to generate certificate for $certname" mkcert $certname "*.${certname}.local" $certname || install_error "Failed to generate certificate for $certname"
install_log "Combining private key and certificate" install_log "Combining private key and certificate"
cat $certname+2-key.pem $certname+2.pem > $certname.pem || install_error "Failed to combine key and certificate"a cat $certname+2-key.pem $certname+2.pem > $certname.pem || install_error "Failed to combine key and certificate"
echo "OK" echo "OK"
} }
# 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() {
install_log "Create SLL directory for lighttpd" install_log "Creating SLL directory for lighttpd"
if [ ! -d "$lighttpd_ssl" ]; then 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 fi
@ -81,14 +81,13 @@ function create_lighttpd_dir() {
install_log "Setting permissions and moving .pem file" install_log "Setting permissions and moving .pem file"
chmod 400 /home/pi/"$certname".pem || install_error "Unable to set permissions for .pem file" chmod 400 /home/pi/"$certname".pem || install_error "Unable to set permissions for .pem file"
sudo mv /home/pi/"$certname".pem /etc/lighttpd/ssl sudo mv /home/pi/"$certname".pem /etc/lighttpd/ssl || install_error "Unable to move .pem file"
echo "OK" echo "OK"
} }
# Edit the lighttpd configuration # Generate config to enable SSL in lighttpd
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=( lines=(
'server.modules += ("mod_openssl")' 'server.modules += ("mod_openssl")'
'$SERVER["socket"] == ":443" {' '$SERVER["socket"] == ":443" {'
@ -105,15 +104,14 @@ function configure_lighttpd() {
sudo sed -i "$ a $line" $lighttpd_conf sudo sed -i "$ a $line" $lighttpd_conf
echo "Adding line $line" echo "Adding line $line"
fi fi
#echo $line
done done
echo "OK" echo "OK"
} }
# Copy rootCA.pem to RaspAP web root # Copy rootCA.pem to RaspAP web root
function copy_rootca() { function copy_rootca() {
install_log "Copying rootCA.pem to RaspAP web root" || install_error "Unable to copy rootCA.pem to ${webroot_dir}" install_log "Copying rootCA.pem to RaspAP web root"
sudo cp /home/pi/.local/share/mkcert/rootCA.pem ${webroot_dir} sudo cp /home/pi/.local/share/mkcert/rootCA.pem ${webroot_dir} || install_error "Unable to copy rootCA.pem to ${webroot_dir}"
echo "OK" echo "OK"
} }