1
0
Fork 0
mirror of https://github.com/processone/ejabberd synced 2025-10-03 17:59:31 +02:00

Container: Copy support for CTL_OVER_HTTP

This commit is contained in:
Badlop 2025-01-07 12:12:08 +01:00
parent 9305232f8c
commit e887546c27
2 changed files with 50 additions and 10 deletions

View file

@ -191,6 +191,7 @@ RUN apk -U upgrade --available --no-cache \
$(cat /tmp/runDeps) \ $(cat /tmp/runDeps) \
so:libcap.so.2 \ so:libcap.so.2 \
so:libtdsodbc.so.0 \ so:libtdsodbc.so.0 \
curl \
tini \ tini \
&& rm /tmp/runDeps \ && rm /tmp/runDeps \
&& ln -fs /usr/lib/libtdsodbc.so.0 /usr/lib/libtdsodbc.so && ln -fs /usr/lib/libtdsodbc.so.0 /usr/lib/libtdsodbc.so

View file

@ -379,6 +379,54 @@ wait_status()
[ $timeout -gt 0 ] [ $timeout -gt 0 ]
} }
exec_other_command()
{
if [ -z "$CTL_OVER_HTTP" ] || [ ! -S "$CTL_OVER_HTTP" ] \
|| [ ! -x "$(command -v curl)" ] || [ -z "$1" ] || [ "$1" = "help" ] \
|| [ "$1" = "mnesia_info_ctl" ]|| [ "$1" = "print_sql_schema" ] ; then
run_erl "$(uid ctl)" -hidden -noinput \
-eval 'net_kernel:connect_node('"'$ERLANG_NODE'"')' \
-s ejabberd_ctl \
-extra "$ERLANG_NODE" $NO_TIMEOUT "$@"
result=$?
case $result in
3) help;;
*) :;;
esac
exit $result
else
exec_ctl_over_http_socket "$@"
fi
}
exec_ctl_over_http_socket()
{
COMMAND=${1}
CARGS=""
while [ $# -gt 0 ]; do
[ -z "$CARGS" ] && CARGS="[" || CARGS="${CARGS}, "
CARGS="${CARGS}\"$1\""
shift
done
CARGS="${CARGS}]"
TEMPHEADERS=temp-headers.log
curl \
--unix-socket ${CTL_OVER_HTTP} \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--data "${CARGS}" \
--dump-header ${TEMPHEADERS} \
--no-progress-meter \
"http://localhost/ctl/${COMMAND}"
result=$(sed -n 's/.*status-code: \([0-9]*\).*/\1/p' < $TEMPHEADERS)
rm ${TEMPHEADERS}
case $result in
2|3) exec_other_command help ${COMMAND};;
*) :;;
esac
exit $result
}
# ensure we can change current directory to SPOOL_DIR # ensure we can change current directory to SPOOL_DIR
[ -f "$SPOOL_DIR/schema.DAT" ] || FIRST_RUN=true [ -f "$SPOOL_DIR/schema.DAT" ] || FIRST_RUN=true
[ -d "$SPOOL_DIR" ] || run_cmd mkdir -p "$SPOOL_DIR" [ -d "$SPOOL_DIR" ] || run_cmd mkdir -p "$SPOOL_DIR"
@ -454,15 +502,6 @@ case $1 in
;; ;;
*) *)
set_dist_client set_dist_client
run_erl "$(uid ctl)" -hidden -noinput \ exec_other_command "$@"
-eval 'net_kernel:connect_node('"'$ERLANG_NODE'"')' \
-s ejabberd_ctl \
-extra "$ERLANG_NODE" $NO_TIMEOUT "$@"
result=$?
case $result in
2|3) help;;
*) :;;
esac
exit $result
;; ;;
esac esac