Skip to content

Commit 11a7485

Browse files
committed
add fallback for missing lsof -2
1 parent 730262c commit 11a7485

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

splunkconf-backup/bin/splunkconf-backup.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1934,11 +1934,11 @@ if [[ "$MODE" == "0" ]] || [[ "$MODE" == "pg" ]]; then
19341934
if command -v ss &>/dev/null; then
19351935
debug_log "using ss to detect PG API Port"
19361936
PG_API_PORT=$(ss -tlnp | awk '/postgres/ && $4 !~ /:5432$/ {split($4, a, ":"); print a[length(a)]; exit}')
1937-
elif ! command -v lsof &>/dev/null; then
1937+
elif command -v lsof &>/dev/null; then
19381938
debug_log "using lsof to detect PG API Port"
19391939
PG_API_PORT=$(lsof -i -P | awk '/postgres/ && /LISTEN/ && $9 ~ /localhost/ && $9 !~ /5432/ {split($9, a, ":"); ports[++count] = a[2]} END {if (count >= 2) print ports[2]}')
19401940
elif command -v netstat &>/dev/null; then
1941-
debug_log "WARNING: i'ss' and 'lsof' not found, falling back to 'netstat'"
1941+
debug_log "WARNING: 'ss' and 'lsof' not found, falling back to 'netstat'"
19421942
PG_API_PORT=$(netstat -tlnp 2>/dev/null | awk '/postgres/ && $4 !~ /:5432$/ {split($4, a, ":"); print a[length(a)]; exit}')
19431943
else
19441944
warn_log "ERROR: None of 'lsof', 'ss', or 'netstat' are available"

0 commit comments

Comments
 (0)