Skip to content

Commit

Permalink
add android-sms-gateway-server support (#1)
Browse files Browse the repository at this point in the history
* add truststore
* added liquibase script
* updated dependencies
* changed version names
* added banner
* fixed docker container creation
  • Loading branch information
benkuly authored Nov 20, 2020
1 parent 62ed94d commit 8ee1274
Show file tree
Hide file tree
Showing 39 changed files with 2,708 additions and 327 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/dockerimage-gammu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Docker Image CI

on:
release:
types: [ published ]

jobs:
publish-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Java
uses: actions/setup-java@v1
with:
java-version: 11
- uses: azure/docker-login@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: build image
run: gradle docker-gammu
- name: Set release version
run: echo ::set-env name=RELEASE_VERSION::${GITHUB_REF:11}
- name: Publish version tagged image to DockerHub
run: docker push folivonet/matrix-sms-bridge:${{ env.RELEASE_VERSION }}-gammu
- name: Publish latest image to DockerHub
run: docker push folivonet/matrix-sms-bridge:latest-gammu
4 changes: 2 additions & 2 deletions .github/workflows/dockerimage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Docker Image CI

on:
release:
types: [published]
types: [ published ]

jobs:
publish-image:
Expand All @@ -18,7 +18,7 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: build image
run: gradle docker-gammu
run: gradle bootBuildImage
- name: Set release version
run: echo ::set-env name=RELEASE_VERSION::${GITHUB_REF:11}
- name: Publish version tagged image to DockerHub
Expand Down
40 changes: 34 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,24 @@ This is a matrix bridge, which allows you to bridge matrix rooms to SMS with one
You need help? Ask your questions in [#matrix-sms-bridge:imbitbu.de](https://matrix.to/#/#matrix-sms-bridge:imbitbu.de)

Features:
* use with one telephone number only
* use with one outgoing telephone number only
* send SMS
* receive SMS
* use room aliases to have one room for incoming telephone number
* bot for automated sms sending
* creates rooms for you
* writes messages for you
* allows you to send SMS at a specific time (in future)
* invites users for you, when room gets created
* provider:
* modem (with [Gammu](https://github.com/gammu/gammu))
* Android Smartphone with [android-sms-gateway-server}](https://github.com/RebekkaMa/android-sms-gateway-server)
* modem (with [Gammu](https://github.com/gammu/gammu)) -> not actively maintained anymore

## User Guide
### Automated room creation
Create a room with you and `@smsBot:yourHomeServer.org` only. Now you can write `sms send --help` which gives you a help, how to use this command.

Example: `sms send -t 01749292923 "Hello World"` creates a new room with the telephone number and writes "Hello World" for you. If there already is a room with this telephone numer and you participating, then "Hello World" will send it to that room.
Example: `sms send -t 01749292923 "Hello World"` creates a new room with the telephone number and writes "Hello World" for you. If there already is a room with this telephone number, and you are participating, then "Hello World" will be sent to that room.

### Invite telephone number to matrix room
The virtual matrix users, which represents SMS numbers, have the following pattern:
Expand Down Expand Up @@ -109,7 +111,30 @@ namespaces:
```

### Configure Provider
Currently, only modems via [Gammu](https://github.com/gammu/gammu) are supported. If you want your SMS gateway provider to be supported, look into the package [`provider`](./src/main/kotlin/net/folivo/matrix/bridge/sms/provider) to see how you can add your own provider to this bridge.
If you want your SMS gateway provider to be supported, look into the package [`provider`](./src/main/kotlin/net/folivo/matrix/bridge/sms/provider) to see how you can add your own provider to this bridge.

#### android-sms-gateway-server
You need to add some properties to the Application Service yaml-file:
```yaml
matrix:
bridge:
sms:
provider:
android:
# (optional) default is disabled
enabled: true
# The url to the android-sms-gateway-server
baseUrl: https://192.168.25.26:9090
# The username of the gateway
username: admin
# The password of the gateway
password: 123
# (optional) if you use a self signed certificate, you can add the public key here
trustStore:
path: /data/matrix-sms-bridge-android.p12
password: 123
type: PKCS12
```

#### Gammu
First you need to add some properties to the Application Service yaml-file:
Expand Down Expand Up @@ -153,6 +178,9 @@ CheckBattery = 0
```

### Using Docker container
As long as there is only one Provider, Gammu is integrated into the Docker-container: `docker pull folivonet/matrix-sms-bridge`
There are two types of docker-containers. One, that is bundled with Gammu and one without:

* Default: `docker pull folivonet/matrix-sms-bridge:latest`
* Containers bundled with gammu use tags with the suffix `-gammu`: `docker pull folivonet/matrix-sms-bridge:latest-gammu`

To see, how a docker setup of the bridge could look like, have a look at the [example](./examples/gammu).
To see, how a docker setup of the bridge could look like, have a look at the [examples](./examples).
39 changes: 18 additions & 21 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.springframework.boot.gradle.tasks.bundling.BootBuildImage

plugins {
base
Expand All @@ -10,20 +11,21 @@ plugins {
}

repositories {
mavenCentral()
mavenLocal()
maven("https://repo.spring.io/milestone")
}

allprojects {
apply(plugin = "kotlin")
group = "net.folivo"
version = "0.5.0"
java.sourceCompatibility = JavaVersion.VERSION_11

group = "net.folivo"
version = "0.4.5.SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_11

repositories {
mavenCentral()
mavenLocal()
maven("https://repo.spring.io/milestone")
tasks.withType<org.springframework.boot.gradle.tasks.bundling.BootJar>() {
manifest {
attributes(
"Implementation-Title" to "matrix-sms-bridge",
"Implementation-Version" to archiveVersion
)
}
}

Expand All @@ -33,8 +35,7 @@ dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")

implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:${Versions.kotlinxCoroutines}")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor:${Versions.kotlinxCoroutines}")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")
implementation("com.michael-bull.kotlin-retry:kotlin-retry:${Versions.kotlinRetry}")

implementation("net.folivo:matrix-spring-boot-bot:${Versions.matrixSDK}")
Expand Down Expand Up @@ -77,12 +78,6 @@ configurations {
}
}

dependencyManagement {
imports {
mavenBom(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES)
}
}

tasks.withType<Test> {
useJUnitPlatform()
}
Expand All @@ -94,6 +89,10 @@ tasks.withType<KotlinCompile> {
}
}

tasks.getByName<BootBuildImage>("bootBuildImage") {
imageName = "folivonet/matrix-sms-bridge"
}

tasks.register<Exec>("docker-gammu") {
group = "build"
commandLine(
Expand All @@ -102,9 +101,7 @@ tasks.register<Exec>("docker-gammu") {
"--build-arg",
"JAR_FILE=./build/libs/*.jar",
"-t",
"folivonet/matrix-sms-bridge:$version",
"-t",
"folivonet/matrix-sms-bridge:latest",
"folivonet/matrix-sms-bridge:$version-gammu",
"-f",
"./src/main/docker/gammu/Dockerfile",
"."
Expand Down
5 changes: 2 additions & 3 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
object Versions {
const val kotlin = "1.4.10" // https://kotlinlang.org/
const val kotlinxCoroutines = "1.3.9" // https://github.com/Kotlin/kotlinx.coroutines/releases
const val kotlinRetry = "1.0.6" // https://github.com/michaelbull/kotlin-retry
const val kotest = "4.3.1" // https://github.com/kotest/kotest/releases
const val springBoot = "2.3.4.RELEASE" // https://spring.io/projects/spring-boot
const val springBoot = "2.4.0" // https://spring.io/projects/spring-boot
const val springDependencyManagement = "1.0.10.RELEASE" // https://github.com/spring-gradle-plugins/dependency-management-plugin/releases
const val springMockk = "2.0.3" // https://github.com/Ninja-Squad/springmockk/releases
const val matrixSDK = "0.4.1.RELEASE" // https://github.com/benkuly/matrix-spring-boot-sdk/releases
const val matrixSDK = "0.4.3" // https://github.com/benkuly/matrix-spring-boot-sdk/releases
const val clikt = "3.0.1" // https://github.com/ajalt/clikt/releases
const val ant = "1.10.9" // https://ant.apache.org/antnews.html
const val libphonenumber = "8.12.12" // https://github.com/google/libphonenumber/releases
Expand Down
File renamed without changes.
37 changes: 37 additions & 0 deletions examples/android/config/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
logging:
level:
net.folivo.matrix: DEBUG

matrix:
bridge:
sms:
provider:
android:
enabled: true
baseUrl: https://192.168.25.26:9090
username: admin
password: 123
trustStore:
path: /data/matrix-sms-bridge-android.p12
password: 123
type: PKCS12
defaultRoomId: "!tRraLABExGeUDmOWvF:matrix-local"
defaultRegion: DE
defaultTimeZone: Europe/Berlin
singleModeEnabled: true
bot:
serverName: matrix-local
migration:
url: jdbc:h2:file:/data/db/testdb
username: sa
database:
url: r2dbc:h2:file:////data/db/testdb
username: sa
client:
homeServer:
hostname: matrix-synapse
port: 8008
secure: false
token: 30c05ae90a248a4188e620216fa72e349803310ec83e2a77b34fe90be6081f46
appservice:
hsToken: 312df522183efd404ec1cd22d2ffa4bbc76a8c1ccf541dd692eef281356bb74e
4 changes: 4 additions & 0 deletions examples/android/data/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.log
*.txt
*.smsbackup
matrix-sms-bridge-android.p12
31 changes: 31 additions & 0 deletions examples/android/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
version: '3.3'
services:
matrix-sms-bridge:
image: folivonet/matrix-sms-bridge:latest
volumes:
- type: bind
source: ./config
target: /config
- type: bind
source: ./data
target: /data
environment:
- SPRING_CONFIG_ADDITIONAL_LOCATION=/config/application.yml
#- SPRING_PROFILES_ACTIVE=initialsync
expose:
- 8080
restart: on-failure
matrix-synapse:
image: matrixdotorg/synapse:latest
volumes:
- type: bind
source: ./synapse
target: /data
environment:
- SYNAPSE_REPORT_STATS=false
- UID=1000
- GID=1000
depends_on:
- matrix-sms-bridge
ports:
- 8008:8008
6 changes: 6 additions & 0 deletions examples/android/synapse/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
homeserver.db

!.gitignore
!homeserver.yaml
!matrix-kotlin-sdk-it-synapse.log.config
!matrix-kotlin-sdk-it-synapse.signing.key
Loading

0 comments on commit 8ee1274

Please sign in to comment.