Skip to content
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

Newer libtoxcore.so, expose settings through env vars, enhance docs #18

Open
wants to merge 43 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
3c68ca2
Bump moment from 2.29.1 to 2.29.4
dependabot[bot] Feb 5, 2023
32e7da3
Bump async from 3.2.0 to 3.2.4
dependabot[bot] Feb 5, 2023
46aa1ca
Bump qs from 6.5.2 to 6.5.3
dependabot[bot] Feb 5, 2023
f031c0e
Bump minimatch from 3.0.4 to 3.1.2
dependabot[bot] Feb 5, 2023
eca0cad
Bump minimist from 1.2.5 to 1.2.7
dependabot[bot] Feb 5, 2023
5667241
Bump got from 11.8.1 to 11.8.6
dependabot[bot] Feb 5, 2023
dfd6446
Merge pull request #6 from plantroon/dependabot/npm_and_yarn/got-11.8.6
plantroon Feb 5, 2023
b299829
Merge pull request #5 from plantroon/dependabot/npm_and_yarn/async-3.2.4
plantroon Feb 5, 2023
9a25f9f
Bump simple-get from 3.1.0 to 3.1.1
dependabot[bot] Feb 5, 2023
6403439
Merge pull request #3 from plantroon/dependabot/npm_and_yarn/qs-6.5.3
plantroon Feb 5, 2023
987206d
Merge pull request #2 from plantroon/dependabot/npm_and_yarn/minimatc…
plantroon Feb 5, 2023
cfdc9d2
Merge pull request #4 from plantroon/dependabot/npm_and_yarn/minimist…
plantroon Feb 5, 2023
424e113
Bump json-schema and jsprim
dependabot[bot] Feb 5, 2023
2b87179
Merge pull request #7 from plantroon/dependabot/npm_and_yarn/simple-g…
plantroon Feb 5, 2023
b6d9a44
Merge pull request #8 from plantroon/dependabot/npm_and_yarn/json-sch…
plantroon Feb 5, 2023
ee0b4d4
Bump path-parse from 1.0.6 to 1.0.7
dependabot[bot] Feb 5, 2023
9dc21b5
Merge pull request #1 from plantroon/dependabot/npm_and_yarn/moment-2…
plantroon Feb 5, 2023
9e469bf
Merge pull request #10 from plantroon/dependabot/npm_and_yarn/path-pa…
plantroon Feb 5, 2023
ffa99ec
Bump color-string from 1.5.4 to 1.9.1
dependabot[bot] Feb 5, 2023
aeb2c33
Bump tar and mx-puppet-bridge
dependabot[bot] Feb 5, 2023
77a16d0
Bump http-cache-semantics from 4.1.0 to 4.1.1
dependabot[bot] Feb 5, 2023
4ed1384
Bump postcss from 7.0.35 to 7.0.39
dependabot[bot] Feb 5, 2023
a0a8952
Merge pull request #13 from plantroon/dependabot/npm_and_yarn/postcss…
plantroon Feb 5, 2023
2553241
Merge pull request #11 from plantroon/dependabot/npm_and_yarn/color-s…
plantroon Feb 5, 2023
cb710ee
Merge pull request #12 from plantroon/dependabot/npm_and_yarn/http-ca…
plantroon Feb 5, 2023
73b23f1
Merge branch 'master' into dependabot/npm_and_yarn/tar-and-mx-puppet-…
plantroon Feb 5, 2023
4803573
Merge pull request #9 from plantroon/dependabot/npm_and_yarn/tar-and-…
plantroon Feb 5, 2023
414dedf
Bump lodash from 4.17.20 to 4.17.21
dependabot[bot] Feb 5, 2023
2f16134
Bump underscore from 1.11.0 to 1.13.6
dependabot[bot] Feb 5, 2023
661e8d0
Merge pull request #15 from plantroon/dependabot/npm_and_yarn/undersc…
plantroon Feb 5, 2023
1b88874
Merge pull request #14 from plantroon/dependabot/npm_and_yarn/lodash-…
plantroon Feb 5, 2023
c4236d6
Create docker-publish.yml
plantroon Feb 6, 2023
c089b4e
Updated some dependencies
plantroon Feb 6, 2023
b4a82f6
Updated paths to reflect new changes
plantroon Feb 6, 2023
01d6de9
Switched to node-bullseye base image, gosu instead of su-exec
plantroon Feb 6, 2023
8b118ce
Will use library from Debian repositories, this is not necessary anymore
plantroon Feb 6, 2023
57cea5b
Merge branch 'master' of https://github.com/plantroon/mx-puppet-tox
plantroon Feb 6, 2023
267baa1
Delete docker-publish.yml
plantroon Mar 18, 2023
70aba07
Create .github/workflows/docker-publish.yml
plantroon Mar 18, 2023
c313026
Update dependencies
plantroon Mar 27, 2023
24781f1
Satisfy shellcheck and hadolint Docker
plantroon Mar 27, 2023
fa3618d
Expose config through env vars
plantroon Mar 27, 2023
33af9b9
Add example config and basic documentation to README
plantroon Mar 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Docker

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

on:
schedule:
- cron: '34 15 * * *'
push:
branches: [ "master" ]
# Publish semver tags as releases.
tags: [ 'v*.*.*' ]
pull_request:
branches: [ "master" ]

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}


jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@f3c664df7af409cb4873aa5068053ba9d61a57b6 #v2.6.0
with:
cosign-release: 'v1.13.1'


# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max


# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
# repository is public to avoid leaking data. If you would like to publish
# transparency data even for private images, pass --force to cosign below.
# https://github.com/sigstore/cosign
- name: Sign the published Docker image
if: ${{ github.event_name != 'pull_request' }}
env:
COSIGN_EXPERIMENTAL: "true"
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign {}@${{ steps.build-and-push.outputs.digest }}
13 changes: 9 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:latest AS builder
FROM node:12-bullseye AS builder

WORKDIR /opt/mx-puppet-tox

Expand All @@ -15,15 +15,20 @@ COPY src/ ./src/
RUN npm run build


FROM node:alpine
FROM node:12-bullseye

VOLUME /data

ENV CONFIG_PATH=/data/config.yaml \
REGISTRATION_PATH=/data/tox-registration.yaml

# su-exec is used by docker-run.sh to drop privileges
RUN apk add --no-cache su-exec
# gosu is used by docker-run.sh to drop privileges
RUN set -ex; \
sed -i s/bullseye/bookworm/g /etc/apt/sources.list; \
apt-get update; \
apt-get install -y --no-install-recommends libtoxcore2 libtoxcore-dev gosu; \
apt-get purge -y --auto-remove; \
rm -rf /var/lib/apt/lists/*

WORKDIR /opt/mx-puppet-tox
COPY docker-run.sh ./
Expand Down
68 changes: 68 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,71 @@

# mx-puppet-tox
This is a tox puppeting bridge for matrix. It basically acts like a tox client for matrix. It is based on [mx-puppet-bridge](https://github.com/Sorunome/mx-puppet-bridge).

## Setup

You need at least node 12 to be able to run this!

Clone the repo and install the dependencies:

```
git clone https://github.com/Sorunome/mx-puppet-tox
cd mx-puppet-tox
npm install
```

Copy and edit the configuration file to your liking:

```
cp sample.config.yaml config.yaml
... edit config.yaml ...
```

Generate an appservice registration file. Optional parameters are shown in
brackets with default values:

```
npm run start -- -r [-c config.yaml] [-f tox-registration.yaml]
```

Then add the path to the registration file to your synapse `homeserver.yaml`
under `app_service_config_files`, and restart synapse.

Finally, run the bridge:

```
npm run start
```

### Docker

If you prefer to use a docker based setup an image is available at ghcr.io/sorunome/mx-puppet-tox:master

docker-compose:
```
mx-puppet-tox:
container_name: mx-puppet-tox
image: ghcr.io/sorunome/mx-puppet-tox:master
restart: unless-stopped
volumes:
- ./mx-puppet-tox:/data
environment:
- SAVES_FOLDER=toxsaves
- USE_TIMESTAMP=false
```

## Linking

Start a chat with `@_toxpuppet_bot:yourserver.com`

```
link <username>
```

This creates a new Tox identity.

If you wish to use your existing one, export it from your Tox client and overwrite the link you just created and restart the bridge.

All available commands can be viewed with `help` command.


26 changes: 17 additions & 9 deletions docker-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,42 @@ if [ ! -f "$CONFIG_PATH" ]; then
exit 1
fi

args="$@"
args="$*"

if [ ! -f "$REGISTRATION_PATH" ]; then
echo 'No registration found, generating now'
args="-r"
fi

if [ ! -d "/data/$SAVES_FOLDER" ]; then
echo "No saves folder found, creating $SAVES_FOLDER"
mkdir "/data/$SAVES_FOLDER"
fi


# if no --uid is supplied, prepare files to drop privileges
if [ "$(id -u)" = 0 ]; then
chown node:node /data
chown node:node "/data/$SAVES_FOLDER"

if find *.db > /dev/null 2>&1; then
if find ./*.db > /dev/null 2>&1; then
# make sure sqlite files are writeable
chown node:node *.db
chown node:node ./*.db
fi
if find *.log.* > /dev/null 2>&1; then
if find ./*.log.* > /dev/null 2>&1; then
# make sure log files are writeable
chown node:node *.log.*
chown node:node ./*.log.*
fi

su_exec='su-exec node:node'
gosu='gosu node:node'
else
su_exec=''
gosu=''
fi

# $su_exec is used in case we have to drop the privileges
exec $su_exec /usr/local/bin/node '/opt/mx-puppet-tox/build/index.js' \
# $gosu is used in case we have to drop the privileges
# SC2086: Double quote to prevent globbing and word splitting.
# shellcheck disable=2086
exec $gosu /usr/local/bin/node '/opt/mx-puppet-tox/build/index.js' \
-c "$CONFIG_PATH" \
-f "$REGISTRATION_PATH" \
$args
Binary file removed lib/libtoxcore.so
Binary file not shown.
Loading