-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
ARG VERSION | ||
FROM docker.io/library/alpine:3.20 | ||
|
||
ARG TARGETPLATFORM | ||
ARG VERSION | ||
ARG CHANNEL | ||
|
||
ENV CHARSET="UTF-8" \ | ||
LANG="en_US.UTF-8" \ | ||
UMASK="0002" \ | ||
TZ="Etc/UTC" | ||
|
||
USER root | ||
|
||
RUN \ | ||
apk add --no-cache \ | ||
bash \ | ||
ca-certificates \ | ||
catatonit \ | ||
curl | ||
|
||
COPY ./apps/usbip/entrypoint.sh /entrypoint.sh | ||
|
||
WORKDIR /config | ||
|
||
ENTRYPOINT ["/usr/bin/catatonit", "--"] | ||
CMD ["/entrypoint.sh"] | ||
|
||
LABEL org.opencontainers.image.source="https://github.com/torvalds/linux/blob/master/tools/usb/usbip/README" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# EMQX Init | ||
|
||
EMQX Authentication: | ||
* https://docs.emqx.com/en/emqx/latest/access-control/authn/authn.html | ||
* https://github.com/emqx/emqx/discussions/9142#discussioncomment-3862923 | ||
|
||
EMQX Authorization: | ||
* https://docs.emqx.com/en/emqx/latest/access-control/authz/authz.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
# yaml-language-server: $schema=https://raw.githubusercontent.com/goss-org/goss/master/docs/schema.yaml | ||
file: | ||
/entrypoint.sh: | ||
exists: true | ||
mode: "0755" | ||
/usr/bbin/curl: | ||
exists: true | ||
mode: "0755" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env bash | ||
version="1.0.0" | ||
printf "%s" "${version}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/bin/bash | ||
|
||
: "${INIT_EMQX_HOST:=localhost}" | ||
: "${INIT_EMQX_PORT:=18083}" | ||
: "${INIT_EMQX_SUPER_USER}" | ||
: "${INIT_EMQX_SUPER_PASS}" | ||
: "${INIT_EMQX_ACCESS_KEY}" | ||
: "${INIT_EMQX_SECRET_KEY}" | ||
: "${INIT_EMQX_IS_SUPERUSER:=false}" | ||
: "${INIT_EMQX_TOPIC:=${INIT_EMQX_ACCESS_KEY}/*}" | ||
|
||
INIT_EMQX_BASE_API_URL="http://${INIT_EMQX_SUPER_USER}:${INIT_EMQX_SUPER_PASS}@${INIT_EMQX_HOST}:${INIT_EMQX_PORT}/api/v5" | ||
INIT_EMQX_AUTHN_API_URL="${INIT_EMQX_BASE_API_URL}/authentication/password_based:built_in_database/users" | ||
INIT_EMQX_AUTHZ_API_URL="${INIT_EMQX_BASE_API_URL}/authorization/sources/built_in_database/username" | ||
|
||
while ! curl -s "${INIT_EMQX_AUTHN_API_URL}"; do | ||
echo 'Waiting for EMQX to start...' | ||
sleep 5 | ||
done | ||
|
||
echo 'EMQX started, ready to initialize...'; | ||
|
||
# Authentication | ||
curl -s "${INIT_EMQX_AUTHN_API_URL}" \ | ||
-H 'Content-Type: application/json' \ | ||
-d "$(cat <<EOF | ||
{ | ||
"user_id": "${INIT_EMQX_ACCESS_KEY}", | ||
"password": "${INIT_EMQX_SECRET_KEY}", | ||
"is_superuser": "${INIT_EMQX_IS_SUPERUSER}" | ||
} | ||
EOF | ||
)" | ||
echo 'EMQX access key created!' | ||
|
||
# Superuser does not need authorization | ||
if [ "${INIT_EMQX_IS_SUPERUSER}" -eq "true" ]; then | ||
return | ||
fi | ||
|
||
# Authorization | ||
curl -s "${INIT_EMQX_AUTHZ_API_URL}" \ | ||
-H 'Content-Type: application/json' \ | ||
-d "$(cat <<EOF | ||
[ | ||
{ | ||
"username": "${INIT_EMQX_ACCESS_KEY}", | ||
"rules": [ | ||
{ | ||
"action": "all", | ||
"permission": "allow", | ||
"topic": "${INIT_EMQX_TOPIC}" | ||
} | ||
] | ||
} | ||
] | ||
EOF | ||
)" | ||
echo 'EMQX authorization created!' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
app: emqx-init | ||
semver: true | ||
channels: | ||
- name: stable | ||
platforms: ["linux/amd64"] | ||
stable: true | ||
tests: | ||
enabled: true | ||
type: cli |