mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-03 12:43:56 +08:00
🎉 Sync 2026-10-24 00:22:39
This commit is contained in:
1 parent
6fa3534628
commit
c3de2c6cdf
97 files changed
+7985
-3245
No files matched your search
@@ -59,6 +59,26 @@ usage() {
|
||||
echo " port DPanel port"
|
||||
}
|
||||
|
||||
# Read the exact container TCP binding, never another application's port.
|
||||
# Empty success means no LAN-visible publication; failures stay failures.
|
||||
do_entry_port() {
|
||||
local bindings address candidate extra port=''
|
||||
bindings=$(docker inspect --format '{{range (index .NetworkSettings.Ports "8080/tcp")}}{{printf "%s %s\n" .HostIp .HostPort}}{{end}}' dpanel) || return 1
|
||||
while read -r address candidate extra; do
|
||||
[ -n "$address$candidate$extra" ] || continue
|
||||
[ -z "$extra" ] || return 1
|
||||
case "$candidate" in ''|*[!0-9]*) return 1 ;; esac
|
||||
[ "${#candidate}" -le 5 ] && [ "$candidate" -ge 1 ] && [ "$candidate" -le 65535 ] || return 1
|
||||
case "$address" in 127.*|::1|'[::1]') continue ;; esac
|
||||
[ -z "$port" ] || [ "$port" = "$candidate" ] || return 1
|
||||
port=$candidate
|
||||
done <<EOF
|
||||
$bindings
|
||||
EOF
|
||||
[ -z "$port" ] || printf '%s\n' "$port"
|
||||
return 0
|
||||
}
|
||||
|
||||
case ${ACTION} in
|
||||
"install")
|
||||
do_install
|
||||
@@ -76,7 +96,7 @@ case ${ACTION} in
|
||||
docker ps --all -f 'name=^/dpanel$' --format '{{.State}}'
|
||||
;;
|
||||
"port")
|
||||
docker ps --all -f 'name=^/dpanel$' --format '{{.Ports}}' | grep -om1 '0.0.0.0:[0-9]*->8080/tcp' | sed 's/0.0.0.0:\([0-9]*\)->.*/\1/'
|
||||
do_entry_port
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
|
||||
Reference in new issue
Block a user