Improve system detection robustness
- Enhanced detect-system.sh with better SSH options - Added BatchMode and StrictHostKeyChecking=no for automation - Increased timeout from 5 to 10 seconds - Explicit exit codes for clarity - Improved cert-manager.py detection function: - Checks if detect script exists before running - Validates return code - Checks for empty output - Better timeout handling (15 seconds) - More detailed error messages - Handles TimeoutExpired exception separately
This commit is contained in:
@@ -5,19 +5,27 @@
|
||||
TARGET_HOST="$1"
|
||||
|
||||
if [ -z "$TARGET_HOST" ]; then
|
||||
echo "Usage: $0 <hostname>"
|
||||
echo "Usage: $0 <hostname>" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# SSH options for faster connection
|
||||
SSH_OPTS="-o ConnectTimeout=10 -o BatchMode=yes -o StrictHostKeyChecking=no"
|
||||
|
||||
# Try to detect system type
|
||||
if ssh -o ConnectTimeout=5 root@${TARGET_HOST} "test -f /usr/bin/pvesh" 2>/dev/null; then
|
||||
if ssh $SSH_OPTS root@${TARGET_HOST} "test -f /usr/bin/pvesh" 2>/dev/null; then
|
||||
echo "proxmox"
|
||||
elif ssh -o ConnectTimeout=5 root@${TARGET_HOST} "test -f /usr/local/bin/freenas-version || test -f /usr/local/bin/truenas-version" 2>/dev/null; then
|
||||
exit 0
|
||||
elif ssh $SSH_OPTS root@${TARGET_HOST} "test -f /usr/local/bin/freenas-version || test -f /usr/local/bin/truenas-version" 2>/dev/null; then
|
||||
echo "truenas"
|
||||
elif ssh -o ConnectTimeout=5 root@${TARGET_HOST} "test -f /usr/local/sbin/pfSsh.php" 2>/dev/null; then
|
||||
exit 0
|
||||
elif ssh $SSH_OPTS root@${TARGET_HOST} "test -f /usr/local/sbin/pfSsh.php" 2>/dev/null; then
|
||||
echo "pfsense"
|
||||
elif ssh -o ConnectTimeout=5 root@${TARGET_HOST} "test -f /usr/sbin/univention-config-registry" 2>/dev/null; then
|
||||
exit 0
|
||||
elif ssh $SSH_OPTS root@${TARGET_HOST} "test -f /usr/sbin/univention-config-registry" 2>/dev/null; then
|
||||
echo "ucs"
|
||||
exit 0
|
||||
else
|
||||
echo "unknown"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user