|
81 | 81 | ;; |
82 | 82 | esac |
83 | 83 |
|
| 84 | + # FTP_SERVER is a bare host -- an IP or a hostname -- and nothing |
| 85 | + # else. hPanel displays it as ftp://1.2.3.4, and pasting that whole |
| 86 | + # string makes the FTP client look up a *hostname* of "ftp://1.2.3.4", |
| 87 | + # which fails as ENOTFOUND: an error that reads like the server is |
| 88 | + # missing rather than like the value has a prefix on it. |
| 89 | + # |
| 90 | + # Nothing below prints the value. This repository is public, so the |
| 91 | + # logs are public; only derived facts are reported, never the secret |
| 92 | + # or anything that reconstructs it. |
| 93 | + bad=0 |
| 94 | + case "$FTP_SERVER" in |
| 95 | + *://*) echo "::error::FTP_SERVER contains '://'. Remove the ftp:// prefix -- just the host."; bad=1 ;; |
| 96 | + esac |
| 97 | + case "$FTP_SERVER" in |
| 98 | + */*) echo "::error::FTP_SERVER contains '/'. It is a host, not a URL or a path."; bad=1 ;; |
| 99 | + esac |
| 100 | + case "$FTP_SERVER" in |
| 101 | + *:*) echo "::error::FTP_SERVER contains ':'. Drop the port -- 21 is the default."; bad=1 ;; |
| 102 | + esac |
| 103 | + case "$FTP_SERVER" in |
| 104 | + *[[:space:]]*) echo "::error::FTP_SERVER contains a space. A trailing space survives a paste and breaks the lookup."; bad=1 ;; |
| 105 | + esac |
| 106 | +
|
| 107 | + echo "FTP_SERVER length: ${#FTP_SERVER} characters" |
| 108 | + echo "(a bare IPv4 address is 7 to 15 characters)" |
| 109 | +
|
| 110 | + # Only hostnames get the lookup. An IP literal needs no DNS, and |
| 111 | + # checking one with getent is a reverse lookup that fails whenever |
| 112 | + # the address has no PTR record -- which is normal for shared |
| 113 | + # hosting, so it would reject the correct value. |
| 114 | + if [ "$bad" -eq 0 ]; then |
| 115 | + if echo "$FTP_SERVER" | grep -Eq '^[0-9]{1,3}(\.[0-9]{1,3}){3}$'; then |
| 116 | + echo "FTP_SERVER is an IP address; no lookup needed." |
| 117 | + elif getent hosts "$FTP_SERVER" >/dev/null 2>&1; then |
| 118 | + echo "FTP_SERVER resolves." |
| 119 | + else |
| 120 | + echo "::error::FTP_SERVER is neither an IP address nor a hostname DNS knows about." |
| 121 | + echo "Check it against hPanel -> Files -> FTP Accounts." |
| 122 | + bad=1 |
| 123 | + fi |
| 124 | + fi |
| 125 | +
|
| 126 | + [ "$bad" -eq 0 ] || exit 1 |
| 127 | +
|
84 | 128 | - name: Deploy over FTPS |
85 | 129 | uses: SamKirkland/FTP-Deploy-Action@v4.3.5 |
86 | 130 | with: |
|
0 commit comments