Add better error checking on nginx:import-ssl

This commit is contained in:
Adam Vigneaux
2015-07-26 22:21:32 -04:00
parent 3525f699f9
commit 14e72ea337

View File

@@ -161,12 +161,24 @@ EOF
TEMP_DIR=$(mktemp -d)
cd $TEMP_DIR
tar xvf - <&0
[[ ! -f "$TEMP_DIR/server.crt" ]] && echo "Tar archive missing server.crt" && exit 1
[[ ! -f "$TEMP_DIR/server.key" ]] && echo "Tar archive missing server.key" && exit 1
crt_count = $(ls -1 *.crt | wc -l)
if [[ $crt_count -lt 1 ]]; then
echo "Tar archive is missing .crt file" && exit 1
elif [[ $crt_count -gt 1 ]]; then
echo "Tar archive contains more than one .crt file" && exit 1
fi
key_count = $(ls -1 *.key | wc -l)
if [[ $key_count -lt 1 ]]; then
echo "Tar archive is missing .key file" && exit 1
elif [[ $key_count -gt 1 ]]; then
echo "Tar archive contains more than one .key file" && exit 1
fi
mkdir -p "$DOKKU_ROOT/$APP/tls"
mv "$TEMP_DIR/server.crt" "$DOKKU_ROOT/$APP/tls/server.crt"
mv "$TEMP_DIR/server.key" "$DOKKU_ROOT/$APP/tls/server.key"
mv "$TEMP_DIR/*.crt" "$DOKKU_ROOT/$APP/tls/server.crt"
mv "$TEMP_DIR/*.key" "$DOKKU_ROOT/$APP/tls/server.key"
cd $DOKKU_ROOT
rm -rf $TEMP_DIR
dokku nginx:build-config $APP