Skip to content

Commit

Permalink
Merge pull request #32 from LaurenceJJones/patch-1
Browse files Browse the repository at this point in the history
Potential fix for restart script
  • Loading branch information
kchristensen authored Mar 25, 2021
2 parents d758117 + 55dbebf commit 8e6dbc3
Showing 1 changed file with 3 additions and 20 deletions.
23 changes: 3 additions & 20 deletions udm-le.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,6 @@ deploy_cert() {
fi
}

restart_unifi_os() {
# Attempt to restart unifi-os, and retry a few times in the event it fails
unifi-os restart

RETRIES=1
until [ "$(podman inspect -f '{{.State.Running}}' "unifi-os" 2>&1)" = "true" ];
do
if [ "$RETRIES" -gt 5 ]; then
echo 'Unable to restart unifi-os after 5 attempts, exiting'
exit 1
fi
unifi-os restart
sleep 5
let "RETRIES=RETRIES+1"
done
}

# Support alternative DNS resolvers
if [ "${DNS_RESOLVERS}" != "" ]; then
LEGO_ARGS="${LEGO_ARGS} --dns.resolvers ${DNS_RESOLVERS}"
Expand Down Expand Up @@ -96,18 +79,18 @@ initial)
fi

echo 'Attempting initial certificate generation'
${PODMAN_CMD} ${LEGO_ARGS} --accept-tos run && deploy_cert && add_captive && restart_unifi_os
${PODMAN_CMD} ${LEGO_ARGS} --accept-tos run && deploy_cert && add_captive && unifi-os restart &>/dev/null &
;;
renew)
echo 'Attempting certificate renewal'
${PODMAN_CMD} ${LEGO_ARGS} renew --days 60 && deploy_cert
if [ "${NEW_CERT}" = "yes" ]; then
add_captive && restart_unifi_os
add_captive && unifi-os restart &>/dev/null &
fi
;;
bootrenew)
echo 'Attempting certificate renewal'
${PODMAN_CMD} ${LEGO_ARGS} renew --days 60 && deploy_cert && add_captive && restart_unifi_os
${PODMAN_CMD} ${LEGO_ARGS} renew --days 60 && deploy_cert && add_captive && unifi-os restart &>/dev/null &
;;
testdeploy)
echo 'Attempting to deploy certificate'
Expand Down

0 comments on commit 8e6dbc3

Please sign in to comment.