mirror of
https://github.com/bbernhard/signal-cli-rest-api.git
synced 2026-09-01 06:38:12 +00:00
Compare commits
5 Commits
86b7f3fc8f
...
a60c416291
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a60c416291 | ||
|
|
1129e5a7be | ||
|
|
8533043ba2 | ||
|
|
9a24992b94 | ||
|
|
a6b4392fd7 |
@ -1,9 +1,10 @@
|
||||
ARG SIGNAL_CLI_VERSION=0.13.24
|
||||
ARG LIBSIGNAL_CLIENT_VERSION=0.87.0
|
||||
ARG SIGNAL_CLI_NATIVE_PACKAGE_VERSION=0.13.24+morph027+1
|
||||
ARG SIGNAL_CLI_NATIVE_PACKAGE_VERSION=0.13.24+morph027+2
|
||||
|
||||
ARG SWAG_VERSION=1.16.4
|
||||
ARG GRAALVM_VERSION=25.0.2
|
||||
ARG GRAALVM_VERSION=21.0.0
|
||||
#ARG GRAALVM_VERSION=25.0.2
|
||||
|
||||
ARG BUILD_VERSION_ARG=unset
|
||||
|
||||
|
||||
@ -4,40 +4,57 @@ set -x
|
||||
set -e
|
||||
|
||||
[ -z "${SIGNAL_CLI_CONFIG_DIR}" ] && echo "SIGNAL_CLI_CONFIG_DIR environmental variable needs to be set! Aborting!" && exit 1;
|
||||
[ -z "${SIGNAL_CLI_UID}" ] && echo "SIGNAL_CLI_UID environmental variable needs to be set! Aborting!" && exit 1;
|
||||
[ -z "${SIGNAL_CLI_GID}" ] && echo "SIGNAL_CLI_GID environmental variable needs to be set! Aborting!" && exit 1;
|
||||
|
||||
usermod -u ${SIGNAL_CLI_UID} signal-api
|
||||
groupmod -o -g ${SIGNAL_CLI_GID} signal-api
|
||||
|
||||
# Fix permissions to ensure backward compatibility if SIGNAL_CLI_CHOWN_ON_STARTUP is not set to "false"
|
||||
if [ "$SIGNAL_CLI_CHOWN_ON_STARTUP" != "false" ]; then
|
||||
echo "Changing ownership of ${SIGNAL_CLI_CONFIG_DIR} to ${SIGNAL_CLI_UID}:${SIGNAL_CLI_GID}"
|
||||
chown ${SIGNAL_CLI_UID}:${SIGNAL_CLI_GID} -R ${SIGNAL_CLI_CONFIG_DIR}
|
||||
else
|
||||
echo "Skipping chown on startup since SIGNAL_CLI_CHOWN_ON_STARTUP is set to 'false'"
|
||||
# Check if we are already running as the target user and group
|
||||
RUNNING_AS_TARGET_USER=false
|
||||
if [ "$(id -u)" -eq "${SIGNAL_CLI_UID}" ] && [ "$(id -g)" -eq "${SIGNAL_CLI_GID}" ]; then
|
||||
RUNNING_AS_TARGET_USER=true
|
||||
fi
|
||||
|
||||
# Show warning on docker exec
|
||||
cat <<EOF >> /root/.bashrc
|
||||
if [ "$RUNNING_AS_TARGET_USER" = "true" ]; then
|
||||
echo "Already running as UID ${SIGNAL_CLI_UID} and GID ${SIGNAL_CLI_GID}. Skipping privileged operations."
|
||||
else
|
||||
echo "Adjusting user and group IDs to ${SIGNAL_CLI_UID}:${SIGNAL_CLI_GID}"
|
||||
usermod -u "${SIGNAL_CLI_UID}" signal-api
|
||||
groupmod -o -g "${SIGNAL_CLI_GID}" signal-api
|
||||
|
||||
# Fix permissions to ensure backward compatibility if SIGNAL_CLI_CHOWN_ON_STARTUP is not set to "false"
|
||||
if [ "$SIGNAL_CLI_CHOWN_ON_STARTUP" != "false" ]; then
|
||||
echo "Changing ownership of ${SIGNAL_CLI_CONFIG_DIR} to ${SIGNAL_CLI_UID}:${SIGNAL_CLI_GID}"
|
||||
chown "${SIGNAL_CLI_UID}":"${SIGNAL_CLI_GID}" -R "${SIGNAL_CLI_CONFIG_DIR}"
|
||||
else
|
||||
echo "Skipping chown on startup since SIGNAL_CLI_CHOWN_ON_STARTUP is set to 'false'"
|
||||
fi
|
||||
|
||||
# Show warning on docker exec
|
||||
cat <<EOF >> /root/.bashrc
|
||||
echo "WARNING: signal-cli-rest-api runs as signal-api (not as root!)"
|
||||
echo "Run 'su signal-api' before using signal-cli!"
|
||||
echo "If you want to use signal-cli directly, don't forget to specify the config directory. e.g: \"signal-cli --config ${SIGNAL_CLI_CONFIG_DIR}\""
|
||||
EOF
|
||||
|
||||
cap_prefix="-cap_"
|
||||
caps="$cap_prefix$(seq -s ",$cap_prefix" 0 $(cat /proc/sys/kernel/cap_last_cap))"
|
||||
fi
|
||||
|
||||
# TODO: check mode
|
||||
if [ "$MODE" = "json-rpc" ]
|
||||
then
|
||||
/usr/bin/jsonrpc2-helper
|
||||
if [ -n "$JAVA_OPTS" ] ; then
|
||||
echo "export JAVA_OPTS='$JAVA_OPTS'" >> /etc/default/supervisor
|
||||
fi
|
||||
service supervisor start
|
||||
supervisorctl start all
|
||||
if [ "$MODE" = "json-rpc" ]; then
|
||||
/usr/bin/jsonrpc2-helper
|
||||
if [ -n "$JAVA_OPTS" ]; then
|
||||
echo "export JAVA_OPTS='$JAVA_OPTS'" >> /etc/default/supervisor
|
||||
fi
|
||||
service supervisor start
|
||||
supervisorctl start all
|
||||
fi
|
||||
|
||||
export HOST_IP=$(hostname -I | awk '{print $1}')
|
||||
|
||||
# Start API as signal-api user
|
||||
exec setpriv --reuid=${SIGNAL_CLI_UID} --regid=${SIGNAL_CLI_GID} --init-groups --inh-caps=$caps signal-cli-rest-api -signal-cli-config=${SIGNAL_CLI_CONFIG_DIR}
|
||||
if [ "$RUNNING_AS_TARGET_USER" = "true" ]; then
|
||||
# Already running as the target user, start directly
|
||||
exec signal-cli-rest-api -signal-cli-config="${SIGNAL_CLI_CONFIG_DIR}"
|
||||
else
|
||||
# Use setpriv to switch to target user
|
||||
cap_prefix="-cap_"
|
||||
caps="$cap_prefix$(seq -s ",$cap_prefix" 0 $(cat /proc/sys/kernel/cap_last_cap))"
|
||||
exec setpriv --reuid="${SIGNAL_CLI_UID}" --regid="${SIGNAL_CLI_GID}" --init-groups --inh-caps="$caps" signal-cli-rest-api -signal-cli-config="${SIGNAL_CLI_CONFIG_DIR}"
|
||||
fi
|
||||
|
||||
@ -1231,8 +1231,6 @@ func (s *SignalClient) RemoveMembersFromGroup(number string, groupId string, mem
|
||||
}
|
||||
|
||||
func (s *SignalClient) updateGroupAdmins(number string, groupId string, admins []string, add bool) error {
|
||||
var err error
|
||||
|
||||
if len(admins) == 0 {
|
||||
return nil
|
||||
}
|
||||
@ -1270,6 +1268,7 @@ func (s *SignalClient) updateGroupAdmins(number string, groupId string, admins [
|
||||
return err
|
||||
}
|
||||
_, err = jsonRpc2Client.getRaw("updateGroup", &number, request)
|
||||
return err
|
||||
} else {
|
||||
cmd := []string{"--config", s.signalCliConfig, "-a", number, "updateGroup", "-g", internalGroupId}
|
||||
|
||||
@ -1281,8 +1280,8 @@ func (s *SignalClient) updateGroupAdmins(number string, groupId string, admins [
|
||||
cmd = append(cmd, admins...)
|
||||
|
||||
_, err = s.cliClient.Execute(true, cmd, "")
|
||||
return err
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *SignalClient) AddAdminsToGroup(number string, groupId string, admins []string) error {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user