Last active
December 5, 2024 13:41
-
-
Save Mez0/68213e5297cc43d3ce602fafd319721a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Define the path to the config file | |
CONFIG_FILE="/opt/nezha/agent/config.yml" | |
# Check if the config file exists | |
if [[ -f "$CONFIG_FILE" ]]; then | |
# Use sed to change disable_command_execute from false to true | |
sed -i 's/disable_command_execute: false/disable_command_execute: true/' "$CONFIG_FILE" | |
# Check if the sed command was successful | |
if [[ $? -eq 0 ]]; then | |
echo "Configuration updated successfully." | |
# Restart the nezha-agent service | |
sudo systemctl restart nezha-agent.service | |
# Check if the service restarted successfully | |
if [[ $? -eq 0 ]]; then | |
echo "Service nezha-agent restarted successfully." | |
else | |
echo "Failed to restart nezha-agent service." | |
fi | |
else | |
echo "Failed to update the configuration file." | |
fi | |
else | |
echo "Configuration file not found: $CONFIG_FILE" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment