audit echo vs log across all scripts — outcomes always visible, verbose for per-item loops

This commit is contained in:
Gmer4Lfe
2026-06-14 12:40:15 -04:00
parent 4c37ab16fd
commit 3964f6fb46
1010 changed files with 377767 additions and 132 deletions
+17 -17
View File
@@ -357,7 +357,7 @@ push_state_to_remote() {
fi
timeout "$SSH_TIMEOUT" scp -i "$ssh_key" -o ConnectTimeout="$SSH_TIMEOUT" \
"$local_file" "root@${remote_ip}:${local_file}" 2>/dev/null && \
log "State file pushed to remote ✅" || \
echo "State file pushed to remote ✅" || \
warn "Could not push state file to remote — will propagate on next sync"
}
@@ -466,7 +466,7 @@ do_ssh_key_revocation() {
> /root/.ssh/authorized_keys.tmp 2>/dev/null \
&& mv /root/.ssh/authorized_keys.tmp /root/.ssh/authorized_keys \
&& echo removed" 2>/dev/null | grep -q removed; then
log "Our pubkey revoked from $REMOTE_SERVER_NAME"
echo "Our pubkey revoked from $REMOTE_SERVER_NAME"
SSH_REVOKE_REMOTE_OK=true
else
warn "Remote revocation failed — revoke manually on $REMOTE_SERVER_NAME:"
@@ -491,7 +491,7 @@ do_ssh_key_revocation() {
if grep -v "@${REMOTE_SERVER_NAME}" /root/.ssh/authorized_keys \
> /root/.ssh/authorized_keys.tmp 2>/dev/null && \
mv /root/.ssh/authorized_keys.tmp /root/.ssh/authorized_keys; then
log "$REMOTE_SERVER_NAME pubkey revoked locally ✅"
echo "$REMOTE_SERVER_NAME pubkey revoked locally ✅"
SSH_REVOKE_LOCAL_OK=true
else
warn "Failed to update local authorized_keys — remove @${REMOTE_SERVER_NAME} entry manually"
@@ -568,7 +568,7 @@ start_own_stack() {
continue
fi
if timeout "${DOCKER_TIMEOUT:-30}" docker start "$container" >/dev/null 2>&1; then
log "$container started ✅"
echo "$container started ✅"
else
warn "$container failed to start — check manually"
fi
@@ -610,7 +610,7 @@ cleanup_partner_containers() {
timeout "${DOCKER_TIMEOUT:-30}" docker stop "$container" >/dev/null 2>&1 || true
_PM_TRAP_STOPPED+=("$container")
timeout "${DOCKER_TIMEOUT:-30}" docker rm "$container" >/dev/null 2>&1 && \
log "$container removed ✅" || warn "$container rm failed"
echo "$container removed ✅" || warn "$container rm failed"
else
log "$container not found — skipping"
fi
@@ -623,7 +623,7 @@ cleanup_partner_containers() {
warn " DRY RUN — would rm -rf $path"
continue
fi
rm -rf "$path" && log " Appdata removed: $path" || warn " Failed to remove: $path"
rm -rf "$path" && echo " Appdata removed: $path" || warn " Failed to remove: $path"
done <<< "$all_appdata_paths"
}
@@ -667,7 +667,7 @@ cleanup_owner_containers_on_mirror() {
"docker stop '$container' >/dev/null 2>&1
docker rm '$container' >/dev/null 2>&1 && echo removed" 2>/dev/null | \
grep -q removed && \
log "$container removed from $MIRROR" || \
echo "$container removed from $MIRROR" || \
warn "Failed to remove $container from $MIRROR"
# Delete appdata on remote after container removal
@@ -676,7 +676,7 @@ cleanup_owner_containers_on_mirror() {
timeout "$SSH_TIMEOUT" ssh -i "$SSH_KEY" \
-o ConnectTimeout="$SSH_TIMEOUT" root@"$mirror_ip" \
"rm -rf '$path' && echo removed" 2>/dev/null | grep -q removed && \
log " Appdata removed on $MIRROR: $path" || \
echo " Appdata removed on $MIRROR: $path" || \
warn " Failed to remove appdata on $MIRROR: $path"
done <<< "$appdata_paths"
done <<< "$container_list"
@@ -710,7 +710,7 @@ start_mirror_own_stack() {
-o ConnectTimeout="$SSH_TIMEOUT" root@"$mirror_ip" \
"docker start '$container' >/dev/null 2>&1 && echo started" 2>/dev/null | \
grep -q started && \
log "$container started on $MIRROR" || \
echo "$container started on $MIRROR" || \
warn "$container failed to start on $MIRROR — check manually"
done
}
@@ -801,7 +801,7 @@ provision_emby_admin() {
"${emby_url}/Users/${user_id}/Password" 2>/dev/null)
if [[ "$pw_code" == "200" ]] || [[ "$pw_code" == "204" ]]; then
log "Emby admin '$username' created (id: $user_id) ✅"
echo "Emby admin '$username' created (id: $user_id) ✅"
else
warn "User created but password set failed (HTTP $pw_code) — set password manually"
fi
@@ -812,7 +812,7 @@ provision_emby_admin() {
-H "Content-Type: application/json" \
-d '{"IsAdministrator": true, "IsDisabled": false}' \
"${emby_url}/Users/${user_id}/Policy" 2>/dev/null && \
log "$username granted admin policy ✅" || \
echo "$username granted admin policy ✅" || \
warn "Could not set admin policy — grant manually in Emby dashboard"
}
@@ -867,7 +867,7 @@ revoke_emby_admin() {
"${emby_url}/Users/${user_id}" 2>/dev/null)
if [[ "$del_code" == "200" ]] || [[ "$del_code" == "204" ]] || [[ "$del_code" == "404" ]]; then
log "Emby admin '$username' removed ✅"
echo "Emby admin '$username' removed ✅"
else
warn "Failed to delete Emby user '$username' (HTTP $del_code) — remove manually"
fi
@@ -922,7 +922,7 @@ update_master_conf() {
return 1
fi
if sed -i "s|^[[:space:]]*${key}=.*| ${key}=${value}|" "$conf" 2>/dev/null; then
log "master.conf updated: ${key}=${value}"
echo "master.conf updated: ${key}=${value}"
return 0
else
error "Failed to update master.conf: ${key}=${value}"
@@ -1168,7 +1168,7 @@ if [[ "$MODE" == "onboard" ]]; then
else
echo "PARTNERSHIP_ENABLED=true" >> "$_master_conf"
fi
log "PARTNERSHIP_ENABLED=true in master.conf ✅"
echo "PARTNERSHIP_ENABLED=true in master.conf ✅"
platform_push_conf | while IFS= read -r line; do log "$line"; done
else
warn "DRY RUN — would set PARTNERSHIP_ENABLED=true in master.conf and push"
@@ -1184,7 +1184,7 @@ if [[ "$MODE" == "onboard" ]]; then
echo "${flag_key}=true" >> "$local_state_file"
fi
platform_push_setup_state
log "${MY_ID}_LOCAL_DONE=true written to setup.db ✅"
echo "${MY_ID}_LOCAL_DONE=true written to setup.db ✅"
else
warn "DRY RUN — would write ${MY_ID}_LOCAL_DONE=true"
fi
@@ -1259,7 +1259,7 @@ if [[ "$MODE" == "onboard" ]]; then
container="${entry%%|*}"
port="${entry##*|}"
if curl -sf --max-time 10 "http://${OWNER_IP}:${port}/" >/dev/null 2>&1; then
log "$container reachable at http://${OWNER_IP}:${port}/ ✅"
echo "$container reachable at http://${OWNER_IP}:${port}/ ✅"
else
warn "$container not reachable at http://${OWNER_IP}:${port}/ — may not be running"
fi
@@ -1438,7 +1438,7 @@ if false; then
-o ConnectTimeout="$SSH_TIMEOUT" root@"$NEW_MIRROR_IP" \
"sed -i 's|^[[:space:]]*PARTNERSHIP_OWNER_HOST=.*| PARTNERSHIP_OWNER_HOST=\"$NEW_OWNER_ID\"|' \
'$SCRIPT_DIR/../master.conf'" 2>/dev/null && \
log "Remote master.conf updated ✅" || \
echo "Remote master.conf updated ✅" || \
error "Failed to update remote master.conf — update manually"
else
warn "DRY RUN — would set PARTNERSHIP_OWNER_HOST=$NEW_OWNER_ID on both servers"