postinst improvements

This commit is contained in:
Oscar Krause 2022-12-28 09:04:35 +01:00
parent 2340931a60
commit b22613c337

View File

@ -37,9 +37,10 @@ EOF
systemctl daemon-reload systemctl daemon-reload
echo "> Writing default config parameters ..." if [[ ! -f $CONFIG_DIR/env ]]; then
touch $CONFIG_DIR/env echo "> Writing initial config ..."
cat <<EOF >$CONFIG_DIR/env touch $CONFIG_DIR/env
cat <<EOF >$CONFIG_DIR/env
DLS_URL=127.0.0.1 DLS_URL=127.0.0.1
DLS_PORT=443 DLS_PORT=443
LEASE_EXPIRE_DAYS=90 LEASE_EXPIRE_DAYS=90
@ -48,6 +49,7 @@ INSTANCE_KEY_RSA=$CONFIG_DIR/instance.private.pem
INSTANCE_KEY_PUB=$CONFIG_DIR/instance.public.pem INSTANCE_KEY_PUB=$CONFIG_DIR/instance.public.pem
EOF EOF
fi
echo "> Create dls-instance keypair ..." echo "> Create dls-instance keypair ..."
openssl genrsa -out $CONFIG_DIR/instance.private.pem 2048 openssl genrsa -out $CONFIG_DIR/instance.private.pem 2048
@ -72,7 +74,8 @@ if [[ -f $CONFIG_DIR/webserver.key ]]; then
if [ -x "$(command -v curl)" ]; then if [ -x "$(command -v curl)" ]; then
echo "> Testing API ..." echo "> Testing API ..."
curl --insecure -X GET https://127.0.0.1/status source $CONFIG_DIR/env
curl --insecure -X GET https://$DLS_URL:$DLS_PORT/status
else else
echo "> Testing API failed, curl not available. Please test manually!" echo "> Testing API failed, curl not available. Please test manually!"
fi fi