feat(bridge): Add telegram
This commit is contained in:
parent
75e42d8c56
commit
03a167a13f
@ -3,6 +3,7 @@ kind: Kustomization
|
||||
|
||||
resources:
|
||||
- ./signal
|
||||
- ./telegram
|
||||
- ./messenger
|
||||
- ./instagram
|
||||
- ./whatsapp
|
||||
|
14
manifests/bridges/telegram/create_db.sh
Normal file
14
manifests/bridges/telegram/create_db.sh
Normal file
@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "Checking if $TELEGRAM_DB database exists..."
|
||||
|
||||
if psql -lqt | cut -d \| -f 1 | grep -qw $TELEGRAM_DB; then
|
||||
echo "Database exists, skipping creation"
|
||||
else
|
||||
echo "Database does not exist, creating..."
|
||||
createdb $TELEGRAM_DB
|
||||
createuser $TELEGRAM_USER
|
||||
psql -c "ALTER USER $TELEGRAM_USER WITH ENCRYPTED PASSWORD '$TELEGRAM_PASSWORD';"
|
||||
psql -c "GRANT ALL PRIVILEGES ON DATABASE $TELEGRAM_DB TO $TELEGRAM_USER;"
|
||||
psql -c "ALTER DATABASE $TELEGRAM_DB OWNER TO $TELEGRAM_USER;"
|
||||
fi
|
46
manifests/bridges/telegram/job.yaml
Normal file
46
manifests/bridges/telegram/job.yaml
Normal file
@ -0,0 +1,46 @@
|
||||
apiVersion: batch/v1
|
||||
kind: Job
|
||||
metadata:
|
||||
name: telegram-db-init
|
||||
namespace: synapse
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- name: telegram-db-init
|
||||
image: postgres:15.10
|
||||
command: ["/bin/bash", "/data/create_db.sh"]
|
||||
env:
|
||||
- name: PGHOST
|
||||
value: synapse-db-rw.synapse.svc.cluster.local
|
||||
- name: PGUSER
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: synapse-db-superuser
|
||||
key: username
|
||||
- name: PGPASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: synapse-db-superuser
|
||||
key: password
|
||||
- name: TELEGRAM_USER
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: mautrix-telegram-db
|
||||
key: username
|
||||
- name: TELEGRAM_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: mautrix-telegram-db
|
||||
key: password
|
||||
- name: TELEGRAM_DB
|
||||
value: telegram
|
||||
volumeMounts:
|
||||
- name: create-db
|
||||
mountPath: /data
|
||||
volumes:
|
||||
- name: create-db
|
||||
configMap:
|
||||
name: telegram-db-creation
|
||||
restartPolicy: Never
|
||||
backoffLimit: 4
|
18
manifests/bridges/telegram/kustomization.yaml
Normal file
18
manifests/bridges/telegram/kustomization.yaml
Normal file
@ -0,0 +1,18 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
namespace: synapse
|
||||
|
||||
resources:
|
||||
- service.yaml
|
||||
- statefulset.yaml
|
||||
- job.yaml
|
||||
|
||||
generatorOptions:
|
||||
labels:
|
||||
app: telegram
|
||||
|
||||
configMapGenerator:
|
||||
- name: telegram-db-creation
|
||||
behavior: create
|
||||
files:
|
||||
- create_db.sh
|
16
manifests/bridges/telegram/service.yaml
Normal file
16
manifests/bridges/telegram/service.yaml
Normal file
@ -0,0 +1,16 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: telegram
|
||||
namespace: synapse
|
||||
labels:
|
||||
app.kubernetes.io/name: telegram
|
||||
spec:
|
||||
ports:
|
||||
- name: http
|
||||
port: 29317
|
||||
protocol: TCP
|
||||
targetPort: 29317
|
||||
selector:
|
||||
app: telegram
|
||||
publishNotReadyAddresses: true
|
37
manifests/bridges/telegram/statefulset.yaml
Normal file
37
manifests/bridges/telegram/statefulset.yaml
Normal file
@ -0,0 +1,37 @@
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: telegram
|
||||
namespace: synapse
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: telegram
|
||||
serviceName: telegram
|
||||
replicas: 1
|
||||
minReadySeconds: 10
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: telegram
|
||||
spec:
|
||||
terminationGracePeriodSeconds: 10
|
||||
containers:
|
||||
- name: telegram
|
||||
image: dock.mau.dev/mautrix/telegram:v0.15.2
|
||||
command: [
|
||||
"/usr/bin/python3",
|
||||
"-m", "mautrix_telegram",
|
||||
"--config", "/data/config.yaml",
|
||||
"--no-update",
|
||||
]
|
||||
ports:
|
||||
- containerPort: 29328
|
||||
volumeMounts:
|
||||
- mountPath: "/data/config.yaml"
|
||||
name: telegram-config-file
|
||||
subPath: config.yaml
|
||||
volumes:
|
||||
- name: telegram-config-file
|
||||
secret:
|
||||
secretName: telegram-secret-config
|
@ -36,6 +36,9 @@ spec:
|
||||
- mountPath: "/data/signal.yaml"
|
||||
name: signal-secret-registration
|
||||
subPath: signal.yaml
|
||||
- mountPath: "/data/telegram.yaml"
|
||||
name: telegram-secret-registration
|
||||
subPath: telegram.yaml
|
||||
- mountPath: "/data/messenger.yaml"
|
||||
name: messenger-secret-registration
|
||||
subPath: messenger.yaml
|
||||
@ -61,6 +64,9 @@ spec:
|
||||
- name: signal-secret-registration
|
||||
secret:
|
||||
secretName: signal-secret-registration
|
||||
- name: telegram-secret-registration
|
||||
secret:
|
||||
secretName: telegram-secret-registration
|
||||
- name: messenger-secret-registration
|
||||
secret:
|
||||
secretName: messenger-secret-registration
|
||||
|
Loading…
Reference in New Issue
Block a user