vpn 세팅 스크립트 수정 5

This commit is contained in:
2026-07-13 13:03:52 +09:00
parent bfd426a77f
commit 50e6e90122
+15 -4
View File
@@ -142,12 +142,18 @@ runs:
OTP=$(oathtool --totp "$SEED") OTP=$(oathtool --totp "$SEED")
;; ;;
base64) base64)
# base64 키를 디코딩 → raw 바이트를 hex로 변환 → oathtool에 hex로 전달 # base64가 raw secret을 감싼 경우와 base32 문자열을 감싼 경우를 모두 지원
SEED_HEX=$(printf '%s' "$SEED" | base64 -d 2>/dev/null | od -An -v -tx1 | tr -d ' \n') DECODED_SEED=$(printf '%s' "$SEED" | base64 -d 2>/dev/null || true)
if [ -z "$SEED_HEX" ]; then if [ -z "$DECODED_SEED" ]; then
echo "base64 디코딩 실패: 시드가 올바른 base64인지 확인"; exit 1 echo "base64 디코딩 실패: 시드가 올바른 base64인지 확인"; exit 1
fi fi
DECODED_BASE32=$(printf '%s' "$DECODED_SEED" | tr -d '[:space:]' | tr 'a-z' 'A-Z')
if printf '%s' "$DECODED_BASE32" | grep -Eq '^[A-Z2-7]+=*$'; then
OTP=$(oathtool --totp -b "$DECODED_BASE32")
else
SEED_HEX=$(printf '%s' "$SEED" | base64 -d 2>/dev/null | od -An -v -tx1 | tr -d ' \n')
OTP=$(oathtool --totp "$SEED_HEX") OTP=$(oathtool --totp "$SEED_HEX")
fi
;; ;;
*) *)
echo "잘못된 otp-seed-format: $OTP_SEED_FORMAT (base32|hex|base64)"; exit 1 echo "잘못된 otp-seed-format: $OTP_SEED_FORMAT (base32|hex|base64)"; exit 1
@@ -177,7 +183,7 @@ runs:
# 연결은 백그라운드 데몬에서 비동기로 진행 → --info를 폴링해 완료 대기 # 연결은 백그라운드 데몬에서 비동기로 진행 → --info를 폴링해 완료 대기
echo "연결 완료 대기 중 (최대 ${TIMEOUT}초)..." echo "연결 완료 대기 중 (최대 ${TIMEOUT}초)..."
DISCONNECTED_PATTERN="not connected|Client not connected|Please login|Unable to open message queue|disconnected|로그인" DISCONNECTED_PATTERN="not connected|Client not connected|Please login|Unable to open message queue|disconnected|logon failed|로그인"
for i in $(seq 1 "$TIMEOUT"); do for i in $(seq 1 "$TIMEOUT"); do
INFO=$($SUDO f5fpc --info 2>&1 || true) INFO=$($SUDO f5fpc --info 2>&1 || true)
if [ "$i" -eq 1 ] || [ $((i % 5)) -eq 0 ]; then if [ "$i" -eq 1 ] || [ $((i % 5)) -eq 0 ]; then
@@ -188,6 +194,11 @@ runs:
echo "(f5fpc --info 출력 없음)" echo "(f5fpc --info 출력 없음)"
fi fi
fi fi
if echo "$INFO" | grep -Eqi "logon failed"; then
echo "VPN 로그인 실패:"
echo "$INFO"
exit 1
fi
if echo "$INFO" | grep -Eqi "$DISCONNECTED_PATTERN"; then if echo "$INFO" | grep -Eqi "$DISCONNECTED_PATTERN"; then
sleep 1 sleep 1
continue continue