replace mautrix-whatsapp with mautrix-groupme

This commit is contained in:
Annie Elequin 2021-09-16 14:18:39 -04:00
parent 47962cafbc
commit 92498e2665
12 changed files with 42 additions and 78 deletions

View File

@ -37,14 +37,6 @@ build amd64:
<<: *build <<: *build
image: dock.mau.dev/tulir/gomuks-build-docker:linux-amd64 image: dock.mau.dev/tulir/gomuks-build-docker:linux-amd64
# build arm64:
# <<: *build
# image: dock.mau.dev/tulir/gomuks-build-docker:linux-arm64
# build arm:
# <<: *build
# image: dock.mau.dev/tulir/gomuks-build-docker:linux-arm
build docker amd64: build docker amd64:
<<: *build-docker <<: *build-docker
tags: tags:
@ -64,31 +56,3 @@ build docker amd64:
rm -rf /var/cache/apk/* rm -rf /var/cache/apk/*
curl "$NOVA_ADMIN_API_URL" -H "Content-Type: application/json" -d '{"password":"'"$NOVA_ADMIN_NIGHTLY_PASS"'","bridge":"'$NOVA_BRIDGE_TYPE'","image":"'$CI_REGISTRY_IMAGE':'$CI_COMMIT_SHA'-amd64"}' curl "$NOVA_ADMIN_API_URL" -H "Content-Type: application/json" -d '{"password":"'"$NOVA_ADMIN_NIGHTLY_PASS"'","bridge":"'$NOVA_BRIDGE_TYPE'","image":"'$CI_REGISTRY_IMAGE':'$CI_COMMIT_SHA'-amd64"}'
fi fi
# build docker arm64:
# <<: *build-docker
# tags:
# - arm64
# dependencies:
# - build arm64
# needs:
# - build arm64
# variables:
# DOCKER_ARCH: arm64
# manifest:
# stage: manifest
# variables:
# GIT_STRATEGY: none
# before_script:
# - "mkdir -p $HOME/.docker && echo '{\"experimental\": \"enabled\"}' > $HOME/.docker/config.json"
# - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
# needs:
# - build docker amd64
# - build docker arm64
# script:
# - docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-amd64
# - docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-arm64
# - if [ "$CI_COMMIT_BRANCH" = "master" ]; then docker manifest create $CI_REGISTRY_IMAGE:latest $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-amd64 $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-arm64 && docker manifest push $CI_REGISTRY_IMAGE:latest; fi
# - if [ "$CI_COMMIT_BRANCH" != "master" ]; then docker manifest create $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-amd64 $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-arm64 && docker manifest push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME; fi
# - docker rmi $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-amd64 $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-arm64

View File

@ -9,7 +9,7 @@ RUN apk add --no-cache git ca-certificates build-base su-exec olm-dev
COPY . /build COPY . /build
WORKDIR /build WORKDIR /build
RUN go build -o /usr/bin/mautrix-whatsapp RUN go build -o /usr/bin/mautrix-groupme
FROM alpine:3.12 FROM alpine:3.12
@ -23,8 +23,8 @@ ENV UID=1337 \
RUN apk add --no-cache ffmpeg su-exec ca-certificates olm bash jq yq@edge curl RUN apk add --no-cache ffmpeg su-exec ca-certificates olm bash jq yq@edge curl
COPY --from=builder /usr/bin/mautrix-whatsapp /usr/bin/mautrix-whatsapp COPY --from=builder /usr/bin/mautrix-groupme /usr/bin/mautrix-groupme
COPY --from=builder /build/example-config.yaml /opt/mautrix-whatsapp/example-config.yaml COPY --from=builder /build/example-config.yaml /opt/mautrix-groupme/example-config.yaml
COPY --from=builder /build/docker-run.sh /docker-run.sh COPY --from=builder /build/docker-run.sh /docker-run.sh
VOLUME /data VOLUME /data

View File

@ -10,9 +10,9 @@ ENV UID=1337 \
RUN apk add --no-cache ffmpeg su-exec ca-certificates bash jq curl yq@edge RUN apk add --no-cache ffmpeg su-exec ca-certificates bash jq curl yq@edge
ARG EXECUTABLE=./mautrix-whatsapp ARG EXECUTABLE=./mautrix-groupme
COPY $EXECUTABLE /usr/bin/mautrix-whatsapp COPY $EXECUTABLE /usr/bin/mautrix-groupme
COPY ./example-config.yaml /opt/mautrix-whatsapp/example-config.yaml COPY ./example-config.yaml /opt/mautrix-groupme/example-config.yaml
COPY ./docker-run.sh /docker-run.sh COPY ./docker-run.sh /docker-run.sh
VOLUME /data VOLUME /data

View File

@ -70,7 +70,7 @@ type Config struct {
WhatsApp struct { WhatsApp struct {
OSName string `yaml:"os_name"` OSName string `yaml:"os_name"`
BrowserName string `yaml:"browser_name"` BrowserName string `yaml:"browser_name"`
} `yaml:"whatsapp"` } `yaml:"groupme"`
Bridge BridgeConfig `yaml:"bridge"` Bridge BridgeConfig `yaml:"bridge"`
@ -80,8 +80,8 @@ type Config struct {
func (config *Config) setDefaults() { func (config *Config) setDefaults() {
config.AppService.Database.MaxOpenConns = 20 config.AppService.Database.MaxOpenConns = 20
config.AppService.Database.MaxIdleConns = 2 config.AppService.Database.MaxIdleConns = 2
config.WhatsApp.OSName = "Mautrix-WhatsApp bridge" config.GroupMe.OSName = "Mautrix-GroupMe bridge"
config.WhatsApp.BrowserName = "mx-wa" config.GroupMe.BrowserName = "mx-wa"
config.Bridge.setDefaults() config.Bridge.setDefaults()
} }

View File

@ -6,11 +6,11 @@ fi
# Define functions. # Define functions.
function fixperms { function fixperms {
chown -R $UID:$GID /data /opt/mautrix-whatsapp chown -R $UID:$GID /data /opt/mautrix-groupme
} }
if [[ ! -f /data/config.yaml ]]; then if [[ ! -f /data/config.yaml ]]; then
cp /opt/mautrix-whatsapp/example-config.yaml /data/config.yaml cp /opt/mautrix-groupme/example-config.yaml /data/config.yaml
echo "Didn't find a config file." echo "Didn't find a config file."
echo "Copied default config file to /data/config.yaml" echo "Copied default config file to /data/config.yaml"
echo "Modify that config file to your liking." echo "Modify that config file to your liking."
@ -19,7 +19,7 @@ if [[ ! -f /data/config.yaml ]]; then
fi fi
if [[ ! -f /data/registration.yaml ]]; then if [[ ! -f /data/registration.yaml ]]; then
/usr/bin/mautrix-whatsapp -g -c /data/config.yaml -r /data/registration.yaml /usr/bin/mautrix-groupme -g -c /data/config.yaml -r /data/registration.yaml
echo "Didn't find a registration file." echo "Didn't find a registration file."
echo "Generated one for you." echo "Generated one for you."
echo "Copy that over to synapses app service directory." echo "Copy that over to synapses app service directory."
@ -28,4 +28,4 @@ fi
cd /data cd /data
fixperms fixperms
exec su-exec $UID:$GID /usr/bin/mautrix-whatsapp exec su-exec $UID:$GID /usr/bin/mautrix-groupme

View File

@ -1,12 +1,12 @@
apiVersion: v1 apiVersion: v1
name: mautrix-whatsapp name: mautrix-groupme
version: 0.1.0 version: 0.1.0
appVersion: "0.1.0" appVersion: "0.1.0"
description: A Matrix-Whatsapp puppeting bridge. description: A Matrix-GroupMe puppeting bridge.
keywords: keywords:
- matrix - matrix
- bridge - bridge
- whatsapp - groupme
maintainers: maintainers:
- name: Tulir Asokan - name: Tulir Asokan
email: tulir@maunium.net email: tulir@maunium.net

View File

@ -1,7 +1,7 @@
{{/* {{/*
Expand the name of the chart. Expand the name of the chart.
*/}} */}}
{{- define "mautrix-whatsapp.name" -}} {{- define "mautrix-groupme.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}} {{- end -}}
@ -10,7 +10,7 @@ Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name. If release name contains chart name it will be used as a full name.
*/}} */}}
{{- define "mautrix-whatsapp.fullname" -}} {{- define "mautrix-groupme.fullname" -}}
{{- if .Values.fullnameOverride -}} {{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}} {{- else -}}
@ -26,16 +26,16 @@ If release name contains chart name it will be used as a full name.
{{/* {{/*
Create chart name and version as used by the chart label. Create chart name and version as used by the chart label.
*/}} */}}
{{- define "mautrix-whatsapp.chart" -}} {{- define "mautrix-groupme.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}} {{- end -}}
{{/* {{/*
Common labels Common labels
*/}} */}}
{{- define "mautrix-whatsapp.labels" -}} {{- define "mautrix-groupme.labels" -}}
app.kubernetes.io/name: {{ include "mautrix-whatsapp.name" . }} app.kubernetes.io/name: {{ include "mautrix-groupme.name" . }}
helm.sh/chart: {{ include "mautrix-whatsapp.chart" . }} helm.sh/chart: {{ include "mautrix-groupme.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }} app.kubernetes.io/instance: {{ .Release.Name }}
{{- if .Chart.AppVersion }} {{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
@ -46,9 +46,9 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
{{/* {{/*
Create the name of the service account to use Create the name of the service account to use
*/}} */}}
{{- define "mautrix-whatsapp.serviceAccountName" -}} {{- define "mautrix-groupme.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}} {{- if .Values.serviceAccount.create -}}
{{ default (include "mautrix-whatsapp.fullname" .) .Values.serviceAccount.name }} {{ default (include "mautrix-groupme.fullname" .) .Values.serviceAccount.name }}
{{- else -}} {{- else -}}
{{ default "default" .Values.serviceAccount.name }} {{ default "default" .Values.serviceAccount.name }}
{{- end -}} {{- end -}}

View File

@ -1,12 +1,12 @@
apiVersion: v1 apiVersion: v1
kind: ConfigMap kind: ConfigMap
metadata: metadata:
name: {{ template "mautrix-whatsapp.fullname" . }} name: {{ template "mautrix-groupme.fullname" . }}
labels: labels:
app.kubernetes.io/managed-by: {{ .Release.Service }} app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }} app.kubernetes.io/instance: {{ .Release.Name }}
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }}
app.kubernetes.io/name: {{ template "mautrix-whatsapp.name" . }} app.kubernetes.io/name: {{ template "mautrix-groupme.name" . }}
data: data:
config.yaml: | config.yaml: |
homeserver: homeserver:
@ -14,7 +14,7 @@ data:
domain: {{ .Values.homeserver.domain }} domain: {{ .Values.homeserver.domain }}
appservice: appservice:
address: http://{{ include "mautrix-whatsapp.fullname" . }}:{{ .Values.service.port }} address: http://{{ include "mautrix-groupme.fullname" . }}:{{ .Values.service.port }}
hostname: 0.0.0.0 hostname: 0.0.0.0
port: {{ .Values.service.port }} port: {{ .Values.service.port }}

View File

@ -1,14 +1,14 @@
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
name: {{ include "mautrix-whatsapp.fullname" . }} name: {{ include "mautrix-groupme.fullname" . }}
labels: labels:
{{- include "mautrix-whatsapp.labels" . | nindent 4 }} {{- include "mautrix-groupme.labels" . | nindent 4 }}
spec: spec:
replicas: 1 replicas: 1
selector: selector:
matchLabels: matchLabels:
app.kubernetes.io/name: {{ include "mautrix-whatsapp.name" . }} app.kubernetes.io/name: {{ include "mautrix-groupme.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }} app.kubernetes.io/instance: {{ .Release.Name }}
template: template:
{{- if .Values.podAnnotations }} {{- if .Values.podAnnotations }}
@ -17,10 +17,10 @@ spec:
{{- end }} {{- end }}
metadata: metadata:
labels: labels:
app.kubernetes.io/name: {{ include "mautrix-whatsapp.name" . }} app.kubernetes.io/name: {{ include "mautrix-groupme.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }} app.kubernetes.io/instance: {{ .Release.Name }}
spec: spec:
serviceAccountName: {{ template "mautrix-whatsapp.serviceAccountName" . }} serviceAccountName: {{ template "mautrix-groupme.serviceAccountName" . }}
containers: containers:
- name: {{ .Chart.Name }} - name: {{ .Chart.Name }}
securityContext: securityContext:
@ -51,7 +51,7 @@ spec:
volumes: volumes:
- name: config-volume - name: config-volume
configMap: configMap:
name: {{ template "mautrix-whatsapp.fullname" . }} name: {{ template "mautrix-groupme.fullname" . }}
securityContext: securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }} {{- toYaml .Values.podSecurityContext | nindent 8 }}

View File

@ -1,9 +1,9 @@
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
name: {{ include "mautrix-whatsapp.fullname" . }} name: {{ include "mautrix-groupme.fullname" . }}
labels: labels:
{{ include "mautrix-whatsapp.labels" . | indent 4 }} {{ include "mautrix-groupme.labels" . | indent 4 }}
spec: spec:
type: {{ .Values.service.type }} type: {{ .Values.service.type }}
ports: ports:
@ -12,5 +12,5 @@ spec:
protocol: TCP protocol: TCP
name: http name: http
selector: selector:
app.kubernetes.io/name: {{ include "mautrix-whatsapp.name" . }} app.kubernetes.io/name: {{ include "mautrix-groupme.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }} app.kubernetes.io/instance: {{ .Release.Name }}

View File

@ -2,7 +2,7 @@
apiVersion: v1 apiVersion: v1
kind: ServiceAccount kind: ServiceAccount
metadata: metadata:
name: {{ template "mautrix-whatsapp.serviceAccountName" . }} name: {{ template "mautrix-groupme.serviceAccountName" . }}
labels: labels:
{{ include "mautrix-whatsapp.labels" . | indent 4 }} {{ include "mautrix-groupme.labels" . | indent 4 }}
{{- end -}} {{- end -}}

View File

@ -42,7 +42,7 @@ import (
var ( var (
// These are static // These are static
Name = "mautrix-whatsapp" Name = "mautrix-groupme"
URL = "https://github.com/tulir/mautrix-whatsapp" URL = "https://github.com/tulir/mautrix-whatsapp"
// This is changed when making a release // This is changed when making a release
Version = "0.1.5" Version = "0.1.5"
@ -438,8 +438,8 @@ func (bridge *Bridge) Main() {
func main() { func main() {
flag.SetHelpTitles( flag.SetHelpTitles(
"mautrix-whatsapp - A Matrix-WhatsApp puppeting bridge.", "mautrix-groupme - A Matrix-GroupMe puppeting bridge.",
"mautrix-whatsapp [-h] [-c <path>] [-r <path>] [-g] [--migrate-db <source type> <source uri>]") "mautrix-groupme [-h] [-c <path>] [-r <path>] [-g] [--migrate-db <source type> <source uri>]")
err := flag.Parse() err := flag.Parse()
if err != nil { if err != nil {
_, _ = fmt.Fprintln(os.Stderr, err) _, _ = fmt.Fprintln(os.Stderr, err)