fix: suppress sudo Telegram during SAC agent update (v0.5.3)
This commit is contained in:
@@ -9,6 +9,7 @@ from dataclasses import dataclass
|
||||
from app.config import get_settings
|
||||
from app.models import Host
|
||||
|
||||
SSH_MONITOR_UPDATE_STATE_FILE = "/var/lib/ssh-monitor/agent-update-in-progress"
|
||||
SSH_MONITOR_UPDATE_LOG_PATH = "/var/log/update_script.log"
|
||||
SSH_MONITOR_UPDATE_SCRIPT = "/opt/scripts/update_ssh_monitor.sh"
|
||||
SSH_MONITOR_UPDATE_DIR = "/opt/scripts/update"
|
||||
@@ -454,6 +455,15 @@ def _ssh_monitor_bootstrap_command(repo_url: str, *, git_branch: str = "main") -
|
||||
)
|
||||
|
||||
|
||||
def _ssh_monitor_mark_update_begin_prefix() -> str:
|
||||
"""State-file до updater: lifecycle/sudo на агенте глушатся раньше bootstrap."""
|
||||
return (
|
||||
f"mkdir -p /var/lib/ssh-monitor && "
|
||||
f"date +%s > {SSH_MONITOR_UPDATE_STATE_FILE} && "
|
||||
f"chmod 600 {SSH_MONITOR_UPDATE_STATE_FILE} 2>/dev/null; "
|
||||
)
|
||||
|
||||
|
||||
def run_ssh_monitor_update(
|
||||
*,
|
||||
target: str,
|
||||
@@ -498,7 +508,7 @@ def run_ssh_monitor_update(
|
||||
target=target,
|
||||
user=user,
|
||||
password=password,
|
||||
remote_cmd=bootstrap_cmd,
|
||||
remote_cmd=_ssh_monitor_mark_update_begin_prefix() + bootstrap_cmd,
|
||||
command_timeout_sec=900,
|
||||
need_root=True,
|
||||
login_shell=False,
|
||||
@@ -509,7 +519,7 @@ def run_ssh_monitor_update(
|
||||
target=target,
|
||||
user=user,
|
||||
password=password,
|
||||
remote_cmd=update_cmd,
|
||||
remote_cmd=_ssh_monitor_mark_update_begin_prefix() + update_cmd,
|
||||
command_timeout_sec=900,
|
||||
need_root=True,
|
||||
login_shell=False,
|
||||
|
||||
Reference in New Issue
Block a user