mirror of
https://github.com/unraid/webgui.git
synced 2026-01-09 02:59:52 -06:00
Merge pull request #1919 from ich777/patch-5
Make hook script compatible with busybox `date`
This commit is contained in:
@@ -249,11 +249,16 @@ fi
|
||||
KEY_EXPIRY=$(tailscale status --json | jq -r '.Self.KeyExpiry')
|
||||
if [ "${KEY_EXPIRY}" != "null" ]; then
|
||||
EXPIRY_EPOCH=$(date -d "${KEY_EXPIRY}" +"%s" 2>/dev/null)
|
||||
if [ -z "${EXPIRY_EPOCH}" ]; then
|
||||
EXPIRY_EPOCH=$(date -d "$(echo "${KEY_EXPIRY}" | sed 's/T/ /; s/Z//')" +"%s")
|
||||
fi
|
||||
CUR_EPOCH=$(date -u +%s)
|
||||
DIFF_EPOCH=$((EXPIRY_EPOCH - CUR_EPOCH))
|
||||
DIFF_DAYS=$((DIFF_EPOCH / 86400))
|
||||
HOST=$(tailscale status --json | jq -r '.Self.HostName')
|
||||
if [ -n "${DIFF_DAYS}" ] && echo "${DIFF_DAYS}" | grep -Eq '^[0-9]+$'; then
|
||||
if [ -z "${EXPIRY_EPOCH}" ]; then
|
||||
echo "WARNING: An error occurred while retrieving the Tailscale key expiry!"
|
||||
elif [ -n "${DIFF_DAYS}" ] && echo "${DIFF_DAYS}" | grep -Eq '^[0-9]+$'; then
|
||||
echo "WARNING: Tailscale Key will expire in ${DIFF_DAYS} days."
|
||||
echo " Navigate to https://login.tailscale.com/admin/machines and 'Disable Key Expiry' for ${HOST}"
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user