#!/bin/bash

# Path to the script to restrict
TARGET_SCRIPT="/home/app/start.sh"
# Path to the log file
LOG_FILE="/home/app/status.txt"

while true; do
    # Restrict access
    chmod 000 "$TARGET_SCRIPT"
    echo "$(date '+%Y-%m-%d %H:%M:%S') - Status: OFF (Access restricted)" >> "$LOG_FILE"

    # Sleep for 1 minute (60 seconds)
    sleep 60

    # Restore original permissions
    chmod 755 "$TARGET_SCRIPT"
    echo "$(date '+%Y-%m-%d %H:%M:%S') - Status: ON (Access restored)" >> "$LOG_FILE"

    # Sleep for another 1 minute before restricting again
    sleep 60
done
