#!/bin/sh
set -e

if [ -n $2 ]; then
    if [ "$(cat /proc/1/comm)" = "init" ]; then
        /sbin/restart amazon-efs-mount-watchdog &> /dev/null || true
    elif [ "$(cat /proc/1/comm)" = "systemd" ]; then
        if systemctl is-active --quiet amazon-efs-mount-watchdog; then
            systemctl try-restart amazon-efs-mount-watchdog.service &> /dev/null || true
        fi
    fi
fi