#!/usr/bin/env bash install_self_update_support() { local sudoers_file="/etc/sudoers.d/roverd-self-update" local update_env="/etc/roverd-update.env" local quoted_repo_root # The self-update helper must know which checkout should receive the git # pull. Recording the repository root during the normal installer run keeps # the runtime websocket command simple and prevents the rover from accepting # a caller-controlled path. printf -v quoted_repo_root '%q' "$REPO_ROOT" install -D -o root -g root -m 0644 /dev/null "$update_env" cat > "$update_env" < "$sudoers_file" <<'SUDOERS' # Managed by pi/install_roverd.sh. # Allow only the roverd service account to run the fixed self-update helper. roverd ALL=(root) NOPASSWD: /usr/local/sbin/roverd-self-update SUDOERS chown root:root "$sudoers_file" chmod 0440 "$sudoers_file" if command -v visudo >/dev/null 2>&1; then visudo -cf "$sudoers_file" >/dev/null fi log "Installed roverd self-update helper and sudoers rule" }