Skip to content

Fix Alpine 3.15 not support grep -pP; Improve supporting ipv4|[ipv6]|domain:port; #141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

thohng
Copy link
Contributor

@thohng thohng commented Oct 11, 2022

Hi Eric Nemchik, I found that grep -qP is not support on Alpine 3.15. Also not work with domain:port or local [::1]:port (sidecar container)

grep: unrecognized option: P
BusyBox v1.34.1 (2022-07-19 20:11:24 UTC) multi-call binary.

Usage: grep [-HhnlLoqvsrRiwFE] [-m N] [-A|B|C N] { PATTERN | -e PATTERN... | -f FILE... } [FILE]...

Search for PATTERN in FILEs (or stdin)

        -H      Add 'filename:' prefix
...

I would improve the detection by 2 conditions:

  • DB_HOST contains a port
  • and DB_HOST is not a IPv6 without brackets [..], like 1:2:3::6:7:8
if echo "$DB_HOST" | grep -qE ':[0-9]+$' && ! echo "$DB_HOST" | grep -qE '^(:{0,2}[a-fA-F0-9]{1,4})+$'; then

This improvement also support

  • [::1]:port
  • domain:port
  • ipv4:port
  • [ipv6]:port

@LinuxServer-CI
Copy link
Collaborator

@thohng
Copy link
Contributor Author

thohng commented Oct 11, 2022

I going to merge these changes to my repos after merge PR to my repos

@thohng thohng closed this Oct 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants