From 2d75fca257db5ff754954bf2be7d6d5ad73ad6a4 Mon Sep 17 00:00:00 2001 From: benkuly <12199167+benkuly@users.noreply.github.com> Date: Fri, 22 May 2020 13:50:59 +0200 Subject: [PATCH 01/32] added matrix-sms-bridge --- group_vars/matrix_servers | 28 +++- roles/matrix-sms-bridge/defaults/main.yml | 151 ++++++++++++++++++ roles/matrix-sms-bridge/tasks/init.yml | 24 +++ roles/matrix-sms-bridge/tasks/main.yml | 21 +++ .../matrix-sms-bridge/tasks/setup_install.yml | 71 ++++++++ .../tasks/setup_uninstall.yml | 24 +++ .../tasks/validate_config.yml | 12 ++ .../systemd/matrix-sms-bridge.service.j2 | 59 +++++++ 8 files changed, 389 insertions(+), 1 deletion(-) create mode 100644 roles/matrix-sms-bridge/defaults/main.yml create mode 100644 roles/matrix-sms-bridge/tasks/init.yml create mode 100644 roles/matrix-sms-bridge/tasks/main.yml create mode 100644 roles/matrix-sms-bridge/tasks/setup_install.yml create mode 100644 roles/matrix-sms-bridge/tasks/setup_uninstall.yml create mode 100644 roles/matrix-sms-bridge/tasks/validate_config.yml create mode 100644 roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 diff --git a/group_vars/matrix_servers b/group_vars/matrix_servers index 6d9876ac..1fb1ea0f 100755 --- a/group_vars/matrix_servers +++ b/group_vars/matrix_servers @@ -276,7 +276,6 @@ matrix_mautrix_telegram_login_shared_secret: "{{ matrix_synapse_ext_password_pro # ###################################################################### - ###################################################################### # # matrix-bridge-mautrix-whatsapp @@ -305,6 +304,33 @@ matrix_mautrix_whatsapp_login_shared_secret: "{{ matrix_synapse_ext_password_pro # ###################################################################### +###################################################################### +# +# matrix-sms-bridge +# +###################################################################### + +# We don't enable bridges by default. +matrix_sms_bridge_enabled: false + +matrix_sms_bridge_systemd_required_services_list: | + {{ + ['docker.service'] + + + (['matrix-synapse.service'] if matrix_synapse_enabled else []) + }} + +matrix_sms_bridge_appservice_token: "{{ matrix_synapse_macaroon_secret_key | password_hash('sha512', 'sms.as.token') | to_uuid }}" + +matrix_sms_bridge_homeserver_token: "{{ matrix_synapse_macaroon_secret_key | password_hash('sha512', 'sms.hs.token') | to_uuid }}" + +matrix_sms_bridge_database_password: "{{ matrix_synapse_macaroon_secret_key | password_hash('sha512', 'sms.db.password') | to_uuid }}" + +###################################################################### +# +# /matrix-sms-bridge +# +###################################################################### ###################################################################### # diff --git a/roles/matrix-sms-bridge/defaults/main.yml b/roles/matrix-sms-bridge/defaults/main.yml new file mode 100644 index 00000000..089b78ef --- /dev/null +++ b/roles/matrix-sms-bridge/defaults/main.yml @@ -0,0 +1,151 @@ +# matrix-sms-bridge is a Matrix <-> SMS bridge +# See: https://github.com/benkuly/matrix-sms-bridge + +matrix_sms_bridge_enabled: true + +matrix_sms_bridge_docker_image: "folivonet/matrix-sms-bridge:latest" +matrix_sms_bridge_docker_image_force_pull: "{{ matrix_sms_bridge_docker_image.endswith(':latest') }}" +matrix_sms_bridge_database_docker_image: "neo4j:latest" +matrix_sms_bridge_database_docker_image_force_pull: "{{ matrix_sms_bridge_docker_image.endswith(':latest') }}" + +matrix_sms_bridge_base_path: "{{ matrix_base_data_path }}/matrix-sms-bridge" +matrix_sms_bridge_config_path: "{{ matrix_base_data_path }}/matrix-sms-bridge/config" +matrix_sms_bridge_data_path: "{{ matrix_base_data_path }}/matrix-sms-bridge/data" +matrix_sms_bridge_data_spool_path: "{{ matrix_base_data_path }}/matrix-sms-bridge/data/spool" +matrix_sms_bridge_data_spool_inbox_path: "{{ matrix_base_data_path }}/matrix-sms-bridge/data/spool/inbox" +matrix_sms_bridge_data_spool_inbox_processed_path: "{{ matrix_base_data_path }}/matrix-sms-bridge/data/spool/inbox_processed" +matrix_sms_bridge_data_spool_outbox_path: "{{ matrix_base_data_path }}/matrix-sms-bridge/data/spool/outbox" +matrix_sms_bridge_data_spool_sent_path: "{{ matrix_base_data_path }}/matrix-sms-bridge/data/spool/sent" +matrix_sms_bridge_data_spool_error_path: "{{ matrix_base_data_path }}/matrix-sms-bridge/data/spool/error" +matrix_sms_bridge_database_path: "{{ matrix_base_data_path }}/matrix-sms-bridge/database" + +matrix_sms_bridge_appservice_token: '' +matrix_sms_bridge_homeserver_token: '' + +matrix_sms_bridge_database_username: 'matrix-sms-bridge' +matrix_sms_bridge_database_password: '' + +matrix_sms_bridge_container_http_host_bind_port: '' + +# A list of extra arguments to pass to the container +matrix_sms_bridge_container_extra_arguments: [] + +# List of systemd services that matrix-appservice-discord.service depends on. +matrix_sms_bridge_systemd_required_services_list: ['docker.service'] + +# List of systemd services that matrix-appservice-discord.service wants +matrix_sms_bridge_systemd_wanted_services_list: [] + +matrix_sms_bridge_appservice_url: 'http://matrix-sms-bridge:8080' +matrix_sms_bridge_database_url: 'bolt://matrix-sms-bridge-database:7687' +matrix_sms_bridge_homeserver_hostname: 'matrix-synapse' +matrix_sms_bridge_homeserver_port: '8008' + +matrix_sms_bridge_homserver_domain: "{{ matrix_domain }}" +matrix_sms_bridge_default_room: '' + +matrix_sms_bridge_gammu_modem: '' + + +matrix_sms_bridge_configuration_yaml: | + #jinja2: lstrip_blocks: "True" + + # Database connection + org: + neo4j: + driver: + uri: {{ matrix_sms_bridge_database_url }} + authentication: + username: {{ matrix_sms_bridge_database_username }} + password: {{ matrix_sms_bridge_database_password }} + + matrix: + bridge: + sms: + # (optional) SMS messages without a valid token a routed to this room. + # Note that you must invite @smsbot:yourHomeServer to this room. + defaultRoomId: "{{ matrix_sms_bridge_default_room }}" + templates: + # (optional) The message, that will be sent as SMS. Valid placeholders are {sender}, {body} and {token}. + outgoingMessage: "{sender} wrote:\n\n{body}\n\nTo answer to this message add this token to your message: {token}" + # (optional) The message, that will be sent as SMS, when an incoming SMS didn't contain a valid token + # and was routed to a default room. By default no answer will be sent. + answerInvalidTokenWithDefaultRoom: "Your token was invalid. The message will be sent to a default matrix room." + # (optional) The message, that will be sent as SMS, when an incoming SMS didn't contain a valid token + # and no default room is configured. + answerInvalidTokenWithoutDefaultRoom: "Your message did not contain any valid token. Nobody will read your message.", + # (optional) The message, that will be sent to a matrix room, when sending a bridged message via SMS failed. + sendSmsError: "Could not send SMS to this user. Please try it again later." + # (optional) The content of bridged SMS message into the default room. Valid placeholders are {sender} and {body}. + defaultRoomIncomingMessage: "{sender} wrote:\n{body}" + provider: + gammu: + # (optional) default is disabled + enabled: true + # (optional) Path to the Gammu-Inbox directory. Default is "/var/spool/gammu/inbox". + inboxPath: "{{ matrix_sms_bridge_data_path }}/spool/inbox" + # (optional) Path to the directory, where to put processed messages. Default is "/var/spool/gammu/inbox_processed". + inboxProcessedPath: "{{ matrix_sms_bridge_data_path }}/spool/inbox_processed" + bot: + # The domain-part of matrix-ids. E. g. example.org when your userIds look like @unicorn:example.org + serverName: {{ matrix_sms_bridge_homserver_domain }} + client: + homeServer: + # The hostname of your Homeserver. + hostname: {{ matrix_sms_bridge_homeserver_hostname }} + # (optional) The port of your Homeserver. Default is 443. + port: {{ matrix_sms_bridge_homeserver_port }} + # (optional) Use http or https. Default is true (so uses https). + secure: false + # The token to authenticate against the Homeserver. + token: {{ matrix_sms_bridge_appservice_token }} + appservice: + # A unique token for Homeservers to use to authenticate requests to this application service. + hsToken: {{ matrix_sms_bridge_homeserver_token }} + +matrix_sms_bridge_configuration_extension_yaml: | + # Your custom YAML configuration goes here. + # This configuration extends the default starting configuration (`matrix_sms_bridge_configuration_yaml`). + # + # You can override individual variables from the default configuration, or introduce new ones. + # + # If you need something more special, you can take full control by + # completely redefining `matrix_sms_bridge_configuration_yaml`. + +matrix_sms_bridge_configuration_extension: "{{ matrix_sms_bridge_configuration_extension_yaml|from_yaml if matrix_sms_bridge_configuration_extension_yaml|from_yaml is mapping else {} }}" + +matrix_sms_bridge_gammu_configuration: | + [gammu] + Device = /dev/ttyModem + LogFile = {{ matrix_sms_bridge_data_path }}/log/gammu.log + debugLevel = 1 + + [smsd] + Service = files + LoopSleep = 2 + InboxPath = {{ matrix_sms_bridge_data_path }}/spool/inbox/ + OutboxPath = {{ matrix_sms_bridge_data_path }}/spool/outbox/ + SentSMSPath = {{ matrix_sms_bridge_data_path }}/spool/sent/ + ErrorSMSPath = {{ matrix_sms_bridge_data_path }}/spool/error/ + InboxFormat = detail + OutboxFormat = detail + TransmitFormat = auto + debugLevel = 1 + LogFile = {{ matrix_sms_bridge_data_path }}/log/smsd.log + DeliveryReport = log + DeliveryReportDelay = 7200 + HangupCalls = 1 + CheckBattery = 0 + + +matrix_sms_bridge_registration_yaml: | + id: sms + as_token: "{{ matrix_sms_bridge_appservice_token }}" + hs_token: "{{ matrix_sms_bridge_homeserver_token }}" + namespaces: + users: + - exclusive: true + regex: '^@sms_.+:{{ matrix_sms_bridge_homserver_domain|regex_escape }}$' + url: {{ matrix_sms_bridge_appservice_url }} + sender_localpart: smsbot + rate_limited: false diff --git a/roles/matrix-sms-bridge/tasks/init.yml b/roles/matrix-sms-bridge/tasks/init.yml new file mode 100644 index 00000000..7a49e4b2 --- /dev/null +++ b/roles/matrix-sms-bridge/tasks/init.yml @@ -0,0 +1,24 @@ +# If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist. +# We don't want to fail in such cases. +- name: Fail if matrix-synapse role already executed + fail: + msg: >- + The matrix-sms-bridge role needs to execute before the matrix-synapse role. + when: "matrix_sms_bridge_enabled and matrix_synapse_role_executed|default(False)" + +- set_fact: + matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-sms-bridge','matrix-sms-bridge-database'] }}" + when: matrix_sms_bridge_enabled|bool + +# If the matrix-synapse role is not used, these variables may not exist. +- set_fact: + matrix_synapse_container_extra_arguments: > + {{ matrix_synapse_container_extra_arguments|default([]) }} + + + ["--mount type=bind,src={{ matrix_sms_bridge_config_path }}/registration.yaml,dst=/matrix-sms-bridge-registration.yaml,ro"] + + matrix_synapse_app_service_config_files: > + {{ matrix_synapse_app_service_config_files|default([]) }} + + + {{ ["/matrix-sms-bridge-registration.yaml"] }} + when: matrix_sms_bridge_enabled|bool diff --git a/roles/matrix-sms-bridge/tasks/main.yml b/roles/matrix-sms-bridge/tasks/main.yml new file mode 100644 index 00000000..c1c499de --- /dev/null +++ b/roles/matrix-sms-bridge/tasks/main.yml @@ -0,0 +1,21 @@ +- import_tasks: "{{ role_path }}/tasks/init.yml" + tags: + - always + +- import_tasks: "{{ role_path }}/tasks/validate_config.yml" + when: "run_setup|bool and matrix_sms_bridge_enabled|bool" + tags: + - setup-all + - setup-matrix-sms-bridge + +- import_tasks: "{{ role_path }}/tasks/setup_install.yml" + when: "run_setup|bool and matrix_sms_bridge_enabled|bool" + tags: + - setup-all + - setup-matrix-sms-bridge + +- import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" + when: "run_setup|bool and not matrix_sms_bridge_enabled|bool" + tags: + - setup-all + - setup-matrix-sms-bridge diff --git a/roles/matrix-sms-bridge/tasks/setup_install.yml b/roles/matrix-sms-bridge/tasks/setup_install.yml new file mode 100644 index 00000000..1ceb371e --- /dev/null +++ b/roles/matrix-sms-bridge/tasks/setup_install.yml @@ -0,0 +1,71 @@ +--- + +- name: Ensure matrix-sms-bridge image is pulled + docker_image: + name: "{{ matrix_sms_bridge_docker_image }}" + source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}" + force_source: "{{ matrix_sms_bridge_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}" + force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_sms_bridge_docker_image_force_pull }}" + +- name: Ensure matrix-sms-bridge databse image is pulled + docker_image: + name: "{{ matrix_sms_bridge_database_docker_image }}" + source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}" + force_source: "{{ matrix_sms_bridge_database_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}" + force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_sms_bridge_database_docker_image_force_pull }}" + + +- name: Ensure matrix-sms-bridge paths exist + file: + path: "{{ item }}" + state: directory + mode: 0750 + owner: "{{ matrix_user_username }}" + group: "{{ matrix_user_groupname }}" + with_items: + - "{{ matrix_sms_bridge_base_path }}" + - "{{ matrix_sms_bridge_config_path }}" + - "{{ matrix_sms_bridge_data_path }}" + - "{{ matrix_sms_bridge_data_spool_path }}" + - "{{ matrix_sms_bridge_data_spool_inbox_path }}" + - "{{ matrix_sms_bridge_data_spool_inbox_processed_path }}" + - "{{ matrix_sms_bridge_data_spool_outbox_path }}" + - "{{ matrix_sms_bridge_data_spool_sent_path }}" + - "{{ matrix_sms_bridge_data_spool_error_path }}" + - "{{ matrix_sms_bridge_database_path }}" + +- name: Ensure matrix-sms-bridge application.yml installed + copy: + content: "{{ matrix_sms_bridge_configuration|to_nice_yaml }}" + dest: "{{ matrix_sms_bridge_config_path }}/application.yml" + mode: 0644 + owner: "{{ matrix_user_username }}" + group: "{{ matrix_user_groupname }}" + +- name: Ensure matrix-sms-bridge registration.yaml installed + copy: + content: "{{ matrix_sms_bridge_registration|to_nice_yaml }}" + dest: "{{ matrix_sms_bridge_config_path }}/registration.yaml" + mode: 0644 + owner: "{{ matrix_user_username }}" + group: "{{ matrix_user_groupname }}" + +- name: Ensure matrix-sms-bridge gammu-smsdrc installed + copy: + content: "{{ matrix_sms_bridge_registration }}" + dest: "{{ matrix_sms_bridge_config_path }}/gammu-smsdrc" + mode: 0644 + owner: "{{ matrix_user_username }}" + group: "{{ matrix_user_groupname }}" + +- name: Ensure matrix-sms-bridge.service installed + template: + src: "{{ role_path }}/templates/systemd/matrix-sms-bridge.service.j2" + dest: "{{ matrix_systemd_path }}/matrix-sms-bridge.service" + mode: 0644 + register: matrix_sms_bridge_systemd_service_result + +- name: Ensure systemd reloaded after matrix-sms-bridge.service installation + service: + daemon_reload: yes + when: "matrix_sms_bridge_systemd_service_result.changed" diff --git a/roles/matrix-sms-bridge/tasks/setup_uninstall.yml b/roles/matrix-sms-bridge/tasks/setup_uninstall.yml new file mode 100644 index 00000000..10912700 --- /dev/null +++ b/roles/matrix-sms-bridge/tasks/setup_uninstall.yml @@ -0,0 +1,24 @@ +--- + +- name: Check existence of matrix-sms-bridge service + stat: + path: "{{ matrix_systemd_path }}/matrix-sms-bridge.service" + register: matrix_sms_bridge_service_stat + +- name: Ensure matrix-sms-bridge is stopped + service: + name: matrix-sms-bridge + state: stopped + daemon_reload: yes + when: "matrix_sms_bridge_service_stat.stat.exists" + +- name: Ensure matrix-sms-bridge.service doesn't exist + file: + path: "{{ matrix_systemd_path }}/matrix-sms-bridge.service" + state: absent + when: "matrix_sms_bridge_service_stat.stat.exists" + +- name: Ensure systemd reloaded after matrix-sms-bridge.service removal + service: + daemon_reload: yes + when: "matrix_sms_bridge_service_stat.stat.exists" diff --git a/roles/matrix-sms-bridge/tasks/validate_config.yml b/roles/matrix-sms-bridge/tasks/validate_config.yml new file mode 100644 index 00000000..8eb7b63c --- /dev/null +++ b/roles/matrix-sms-bridge/tasks/validate_config.yml @@ -0,0 +1,12 @@ +--- + +- name: Fail if required settings not defined + fail: + msg: >- + You need to define a required configuration setting (`{{ item }}`). + when: "vars[item] == ''" + with_items: + - "matrix_sms_bridge_appservice_token" + - "matrix_sms_bridge_homeserver_token" + - "matrix_sms_bridge_database_password" + - "matrix_sms_bridge_gammu_modem" diff --git a/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 b/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 new file mode 100644 index 00000000..a97db783 --- /dev/null +++ b/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 @@ -0,0 +1,59 @@ +#jinja2: lstrip_blocks: "True" +[Unit] +Description=matrix-sms-bridge server +{% for service in matrix_sms_bridge_systemd_required_services_list %} +Requires={{ service }} +After={{ service }} +{% endfor %} +{% for service in matrix_sms_bridge_systemd_wanted_services_list %} +Wants={{ service }} +{% endfor %} + +[Service] +Type=simple +ExecStartPre=-/usr/bin/docker kill matrix-sms-bridge +ExecStartPre=-/usr/bin/docker rm matrix-sms-bridge +ExecStartPre=-/usr/bin/docker kill matrix-sms-bridge-database +ExecStartPre=-/usr/bin/docker rm matrix-sms-bridge-database + +ExecStartPre=/usr/bin/docker run --rm --name matrix-sms-bridge-database \ + --log-driver=none \ + --user={{ matrix_user_uid }}:{{ matrix_user_gid }} \ + --cap-drop=ALL \ + --network={{ matrix_docker_network }} \ + {% if matrix_sms_bridge_container_http_host_bind_port %} + -p {{ matrix_sms_bridge_container_http_host_bind_port }}:7687 \ + {% endif %} + -v {{ matrix_sms_bridge_database_path }}:/data:z \ + -e NEO4J_AUTH={{ matrix_sms_bridge_database_username }}/{{ matrix_sms_bridge_database_password }} + {{ matrix_sms_bridge_database_docker_image }} + +# Intentional delay, so that the homeserver (we likely depend on) can manage to start. +ExecStartPre=/bin/sleep 5 + +ExecStart=/usr/bin/docker run --rm --name matrix-sms-bridge \ + --log-driver=none \ + --user={{ matrix_user_uid }}:{{ matrix_user_gid }} \ + --cap-drop=ALL \ + --network={{ matrix_docker_network }} \ + {% if matrix_sms_bridge_container_http_host_bind_port %} + -p {{ matrix_sms_bridge_container_http_host_bind_port }}:8080 \ + {% endif %} + -v {{ matrix_sms_bridge_config_path }}:/config:z \ + -v {{ matrix_sms_bridge_data_path }}:/data:z \ + --device {{ matrix_sms_bridge_gammu_modem }}:/dev/ttyModem + {% for arg in matrix_sms_bridge_container_extra_arguments %} + {{ arg }} \ + {% endfor %} + {{ matrix_sms_bridge_docker_image }} + +ExecStop=-/usr/bin/docker kill matrix-sms-bridge +ExecStop=-/usr/bin/docker rm matrix-sms-bridge +ExecStop=-/usr/bin/docker kill matrix-sms-database +ExecStop=-/usr/bin/docker rm matrix-sms-database +Restart=always +RestartSec=30 +SyslogIdentifier=matrix-sms-bridge + + [Install] +WantedBy=multi-user.target From 4913ca4bb266521815169b3f01e4972ad22c2c35 Mon Sep 17 00:00:00 2001 From: benkuly <12199167+benkuly@users.noreply.github.com> Date: Fri, 22 May 2020 13:59:38 +0200 Subject: [PATCH 02/32] matri-sms-bridge: better path handling, fixed some mistakes --- roles/matrix-sms-bridge/defaults/main.yml | 21 ++++++++++--------- roles/matrix-sms-bridge/tasks/init.yml | 2 +- .../matrix-sms-bridge/tasks/setup_install.yml | 1 + 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/roles/matrix-sms-bridge/defaults/main.yml b/roles/matrix-sms-bridge/defaults/main.yml index 089b78ef..d69724bd 100644 --- a/roles/matrix-sms-bridge/defaults/main.yml +++ b/roles/matrix-sms-bridge/defaults/main.yml @@ -11,6 +11,7 @@ matrix_sms_bridge_database_docker_image_force_pull: "{{ matrix_sms_bridge_docker matrix_sms_bridge_base_path: "{{ matrix_base_data_path }}/matrix-sms-bridge" matrix_sms_bridge_config_path: "{{ matrix_base_data_path }}/matrix-sms-bridge/config" matrix_sms_bridge_data_path: "{{ matrix_base_data_path }}/matrix-sms-bridge/data" +matrix_sms_bridge_data_log_path: "{{ matrix_base_data_path }}/matrix-sms-bridge/data/log" matrix_sms_bridge_data_spool_path: "{{ matrix_base_data_path }}/matrix-sms-bridge/data/spool" matrix_sms_bridge_data_spool_inbox_path: "{{ matrix_base_data_path }}/matrix-sms-bridge/data/spool/inbox" matrix_sms_bridge_data_spool_inbox_processed_path: "{{ matrix_base_data_path }}/matrix-sms-bridge/data/spool/inbox_processed" @@ -82,10 +83,10 @@ matrix_sms_bridge_configuration_yaml: | gammu: # (optional) default is disabled enabled: true - # (optional) Path to the Gammu-Inbox directory. Default is "/var/spool/gammu/inbox". - inboxPath: "{{ matrix_sms_bridge_data_path }}/spool/inbox" - # (optional) Path to the directory, where to put processed messages. Default is "/var/spool/gammu/inbox_processed". - inboxProcessedPath: "{{ matrix_sms_bridge_data_path }}/spool/inbox_processed" + # (optional) Path to the Gammu-Inbox directory. + inboxPath: "{{ matrix_sms_bridge_data_spool_inbox_path }}" + # (optional) Path to the directory, where to put processed messages. + inboxProcessedPath: "{{ matrix_sms_bridge_data_spool_inbox_path_processed }}" bot: # The domain-part of matrix-ids. E. g. example.org when your userIds look like @unicorn:example.org serverName: {{ matrix_sms_bridge_homserver_domain }} @@ -117,21 +118,21 @@ matrix_sms_bridge_configuration_extension: "{{ matrix_sms_bridge_configuration_e matrix_sms_bridge_gammu_configuration: | [gammu] Device = /dev/ttyModem - LogFile = {{ matrix_sms_bridge_data_path }}/log/gammu.log + LogFile = {{ matrix_sms_bridge_data_log_path }}/gammu.log debugLevel = 1 [smsd] Service = files LoopSleep = 2 - InboxPath = {{ matrix_sms_bridge_data_path }}/spool/inbox/ - OutboxPath = {{ matrix_sms_bridge_data_path }}/spool/outbox/ - SentSMSPath = {{ matrix_sms_bridge_data_path }}/spool/sent/ - ErrorSMSPath = {{ matrix_sms_bridge_data_path }}/spool/error/ + InboxPath = {{ matrix_sms_bridge_data_spool_inbox_path }} + OutboxPath = {{ matrix_sms_bridge_data_spool_outbox_path }} + SentSMSPath = {{ matrix_sms_bridge_data_spool_sent_path }} + ErrorSMSPath = {{ matrix_sms_bridge_data_spool_error_path }} InboxFormat = detail OutboxFormat = detail TransmitFormat = auto debugLevel = 1 - LogFile = {{ matrix_sms_bridge_data_path }}/log/smsd.log + LogFile = {{ matrix_sms_bridge_data_log_path }}/smsd.log DeliveryReport = log DeliveryReportDelay = 7200 HangupCalls = 1 diff --git a/roles/matrix-sms-bridge/tasks/init.yml b/roles/matrix-sms-bridge/tasks/init.yml index 7a49e4b2..cca4d4c5 100644 --- a/roles/matrix-sms-bridge/tasks/init.yml +++ b/roles/matrix-sms-bridge/tasks/init.yml @@ -7,7 +7,7 @@ when: "matrix_sms_bridge_enabled and matrix_synapse_role_executed|default(False)" - set_fact: - matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-sms-bridge','matrix-sms-bridge-database'] }}" + matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-sms-bridge'] }}" when: matrix_sms_bridge_enabled|bool # If the matrix-synapse role is not used, these variables may not exist. diff --git a/roles/matrix-sms-bridge/tasks/setup_install.yml b/roles/matrix-sms-bridge/tasks/setup_install.yml index 1ceb371e..6a800892 100644 --- a/roles/matrix-sms-bridge/tasks/setup_install.yml +++ b/roles/matrix-sms-bridge/tasks/setup_install.yml @@ -26,6 +26,7 @@ - "{{ matrix_sms_bridge_base_path }}" - "{{ matrix_sms_bridge_config_path }}" - "{{ matrix_sms_bridge_data_path }}" + - "{{ matrix_sms_bridge_data_log_path }}" - "{{ matrix_sms_bridge_data_spool_path }}" - "{{ matrix_sms_bridge_data_spool_inbox_path }}" - "{{ matrix_sms_bridge_data_spool_inbox_processed_path }}" From 1ffa4a326ca44b1d0f8eb4ebaddeab265ca8cda8 Mon Sep 17 00:00:00 2001 From: benkuly <12199167+benkuly@users.noreply.github.com> Date: Sat, 23 May 2020 13:14:24 +0200 Subject: [PATCH 03/32] matrix-sms-bridge: added docs, added seperate service for database, pr comments --- README.md | 4 +++ .../configuring-playbook-matrix-sms-bridge.md | 24 +++++++++++++ docs/configuring-playbook.md | 2 ++ group_vars/matrix_servers | 2 -- roles/matrix-sms-bridge/defaults/main.yml | 8 +++-- .../matrix-sms-bridge/tasks/setup_install.yml | 11 ++++-- .../tasks/setup_uninstall.yml | 22 ++++++++++-- .../matrix-sms-bridge-database.service.j2 | 36 +++++++++++++++++++ .../systemd/matrix-sms-bridge.service.j2 | 18 +--------- 9 files changed, 101 insertions(+), 26 deletions(-) create mode 100644 docs/configuring-playbook-matrix-sms-bridge.md create mode 100644 roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge-database.service.j2 diff --git a/README.md b/README.md index 6f7d25e0..a5ec78d3 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,8 @@ Using this playbook, you can get the following services configured on your serve - (optional) the [matrix-appservice-webhooks](https://github.com/turt2live/matrix-appservice-webhooks) bridge for slack compatible webhooks ([ConcourseCI](https://concourse-ci.org/), [Slack](https://slack.com/) etc. pp.) +- (optional) the [matrix-sms-bridge](https://github.com/benkuly/matrix-sms-bridge) for bridging your Matrix server to SMS + - (optional) [Email2Matrix](https://github.com/devture/email2matrix) for relaying email messages to Matrix rooms - (optional) [Dimension](https://github.com/turt2live/matrix-dimension), an open source integrations manager for matrix clients @@ -144,6 +146,8 @@ This playbook sets up your server using the following Docker images: - [turt2live/matrix-appservice-webhooks](https://hub.docker.com/r/turt2live/matrix-appservice-webhooks) - the [Appservice Webhooks](https://github.com/turt2live/matrix-appservice-webhooks) bridge (optional) +- [folivonet/matrix-sms-bridge](https://hub.docker.com/repository/docker/folivonet/matrix-sms-bridge) - the [matrix-sms-brdige](https://github.com/benkuly/matrix-sms-bridge) (optional) + - [sorunome/mx-puppet-skype](https://hub.docker.com/r/sorunome/mx-puppet-skype) - the [mx-puppet-skype](https://github.com/Sorunome/mx-puppet-skype) bridge to [Skype](https:/www.skype.com) (optional) - [sorunome/mx-puppet-slack](https://hub.docker.com/r/sorunome/mx-puppet-slack) - the [mx-puppet-slack](https://github.com/Sorunome/mx-puppet-slack) bridge to [Slack](https:/slack.com) (optional) diff --git a/docs/configuring-playbook-matrix-sms-bridge.md b/docs/configuring-playbook-matrix-sms-bridge.md new file mode 100644 index 00000000..ef2aeb08 --- /dev/null +++ b/docs/configuring-playbook-matrix-sms-bridge.md @@ -0,0 +1,24 @@ +# Setting up matrix-sms-bridge (optional) + +The playbook can install and configure +[matrix-sms-brdige](https://github.com/benkuly/matrix-sms-bridge) for you. + +See the project page to learn what it does and why it might be useful to you. + +To enable the bridge just use the following +playbook configuration: + + +```yaml +matrix_sms_bridge_enabled: true +matrix_sms_bridge_gammu_modem: "/path/to/modem" +# generate a secret passwort e.g. with pwgen -s 64 1 +matrix_sms_bridge_database_password: "" +# (optional) a room id to a default room +matrix_sms_bridge_default_room: "" +``` + + +## Usage + +Read the [user guide](https://github.com/benkuly/matrix-sms-bridge/blob/master/README.md#user-guide) to see how this bridge works. diff --git a/docs/configuring-playbook.md b/docs/configuring-playbook.md index 7e911095..90771cf3 100644 --- a/docs/configuring-playbook.md +++ b/docs/configuring-playbook.md @@ -102,3 +102,5 @@ When you're done with all the configuration you'd like to do, continue with [Ins - [Setting up MX Puppet Slack bridging](configuring-playbook-bridge-mx-puppet-slack.md) (optional) - [Setting up Email2Matrix](configuring-playbook-email2matrix.md) (optional) + +- [Setting up Matrix SMS bridging](configuring-playbook-matrix-sms-bridge.md) (optional) diff --git a/group_vars/matrix_servers b/group_vars/matrix_servers index 1fb1ea0f..8ff5ce96 100755 --- a/group_vars/matrix_servers +++ b/group_vars/matrix_servers @@ -324,8 +324,6 @@ matrix_sms_bridge_appservice_token: "{{ matrix_synapse_macaroon_secret_key | pas matrix_sms_bridge_homeserver_token: "{{ matrix_synapse_macaroon_secret_key | password_hash('sha512', 'sms.hs.token') | to_uuid }}" -matrix_sms_bridge_database_password: "{{ matrix_synapse_macaroon_secret_key | password_hash('sha512', 'sms.db.password') | to_uuid }}" - ###################################################################### # # /matrix-sms-bridge diff --git a/roles/matrix-sms-bridge/defaults/main.yml b/roles/matrix-sms-bridge/defaults/main.yml index d69724bd..57a7a373 100644 --- a/roles/matrix-sms-bridge/defaults/main.yml +++ b/roles/matrix-sms-bridge/defaults/main.yml @@ -31,11 +31,13 @@ matrix_sms_bridge_container_http_host_bind_port: '' # A list of extra arguments to pass to the container matrix_sms_bridge_container_extra_arguments: [] -# List of systemd services that matrix-appservice-discord.service depends on. -matrix_sms_bridge_systemd_required_services_list: ['docker.service'] +# List of systemd services that service depends on. +matrix_sms_bridge_systemd_required_services_list: ['docker.service','matrix-sms-bridge-database.service'] +matrix_sms_bridge_database_systemd_required_services_list: ['docker.service'] -# List of systemd services that matrix-appservice-discord.service wants +# List of systemd services that service wants matrix_sms_bridge_systemd_wanted_services_list: [] +matrix_sms_bridge_database_systemd_wanted_services_list: [] matrix_sms_bridge_appservice_url: 'http://matrix-sms-bridge:8080' matrix_sms_bridge_database_url: 'bolt://matrix-sms-bridge-database:7687' diff --git a/roles/matrix-sms-bridge/tasks/setup_install.yml b/roles/matrix-sms-bridge/tasks/setup_install.yml index 6a800892..1e86f2e6 100644 --- a/roles/matrix-sms-bridge/tasks/setup_install.yml +++ b/roles/matrix-sms-bridge/tasks/setup_install.yml @@ -66,7 +66,14 @@ mode: 0644 register: matrix_sms_bridge_systemd_service_result -- name: Ensure systemd reloaded after matrix-sms-bridge.service installation +- name: Ensure matrix-sms-bridge-database.service installed + template: + src: "{{ role_path }}/templates/systemd/matrix-sms-bridge-database.service.j2" + dest: "{{ matrix_systemd_path }}/matrix-sms-bridge-database.service" + mode: 0644 + register: matrix_sms_bridge_database_systemd_service_result + +- name: Ensure systemd reloaded after matrix-sms-bridge.service or matrix-sms-bridge-database.service installation service: daemon_reload: yes - when: "matrix_sms_bridge_systemd_service_result.changed" + when: matrix_sms_bridge_systemd_service_result.changed or matrix_sms_bridge_database_systemd_service_result.changed diff --git a/roles/matrix-sms-bridge/tasks/setup_uninstall.yml b/roles/matrix-sms-bridge/tasks/setup_uninstall.yml index 10912700..87436687 100644 --- a/roles/matrix-sms-bridge/tasks/setup_uninstall.yml +++ b/roles/matrix-sms-bridge/tasks/setup_uninstall.yml @@ -5,6 +5,11 @@ path: "{{ matrix_systemd_path }}/matrix-sms-bridge.service" register: matrix_sms_bridge_service_stat +- name: Check existence of matrix-sms-bridge-database service + stat: + path: "{{ matrix_systemd_path }}/matrix-sms-bridge-database.service" + register: matrix_sms_bridge_database_service_stat + - name: Ensure matrix-sms-bridge is stopped service: name: matrix-sms-bridge @@ -12,13 +17,26 @@ daemon_reload: yes when: "matrix_sms_bridge_service_stat.stat.exists" +- name: Ensure matrix-sms-bridge-database is stopped + service: + name: matrix-sms-bridge-database + state: stopped + daemon_reload: yes + when: "matrix_sms_bridge_database_service_stat.stat.exists" + - name: Ensure matrix-sms-bridge.service doesn't exist file: path: "{{ matrix_systemd_path }}/matrix-sms-bridge.service" state: absent when: "matrix_sms_bridge_service_stat.stat.exists" -- name: Ensure systemd reloaded after matrix-sms-bridge.service removal +- name: Ensure matrix-sms-bridge-database.service doesn't exist + file: + path: "{{ matrix_systemd_path }}/matrix-sms-bridge-database.service" + state: absent + when: "matrix_sms_bridge_database_service_stat.stat.exists" + +- name: Ensure systemd reloaded after matrix-sms-bridge.service or matrix-sms-bridge-database.service removal service: daemon_reload: yes - when: "matrix_sms_bridge_service_stat.stat.exists" + when: matrix_sms_bridge_service_stat.stat.exists or matrix_sms_bridge_database_service_stat.stat.exists diff --git a/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge-database.service.j2 b/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge-database.service.j2 new file mode 100644 index 00000000..e2cad164 --- /dev/null +++ b/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge-database.service.j2 @@ -0,0 +1,36 @@ +#jinja2: lstrip_blocks: "True" +[Unit] +Description=matrix-sms-bridge-database server +{% for service in matrix_sms_bridge_database_systemd_required_services_list %} +Requires={{ service }} +After={{ service }} +{% endfor %} +{% for service in matrix_sms_bridge_database_systemd_wanted_services_list %} +Wants={{ service }} +{% endfor %} + +[Service] +Type=simple +ExecStartPre=-/usr/bin/docker kill matrix-sms-bridge-database +ExecStartPre=-/usr/bin/docker rm matrix-sms-bridge-database + +# Intentional delay, so that the homeserver (we likely depend on) can manage to start. +ExecStartPre=/bin/sleep 5 + +ExecStart=/usr/bin/docker run --rm --name matrix-sms-bridge-database \ + --log-driver=none \ + --user={{ matrix_user_uid }}:{{ matrix_user_gid }} \ + --cap-drop=ALL \ + --network={{ matrix_docker_network }} \ + -v {{ matrix_sms_bridge_database_path }}:/data:z \ + -e NEO4J_AUTH={{ matrix_sms_bridge_database_username }}/{{ matrix_sms_bridge_database_password }} \ + {{ matrix_sms_bridge_database_docker_image }} + +ExecStop=-/usr/bin/docker kill matrix-sms-bridge-database +ExecStop=-/usr/bin/docker rm matrix-sms-bridge-database +Restart=always +RestartSec=30 +SyslogIdentifier=matrix-sms-bridge + + [Install] +WantedBy=multi-user.target diff --git a/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 b/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 index a97db783..86ac264d 100644 --- a/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 +++ b/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 @@ -13,20 +13,6 @@ Wants={{ service }} Type=simple ExecStartPre=-/usr/bin/docker kill matrix-sms-bridge ExecStartPre=-/usr/bin/docker rm matrix-sms-bridge -ExecStartPre=-/usr/bin/docker kill matrix-sms-bridge-database -ExecStartPre=-/usr/bin/docker rm matrix-sms-bridge-database - -ExecStartPre=/usr/bin/docker run --rm --name matrix-sms-bridge-database \ - --log-driver=none \ - --user={{ matrix_user_uid }}:{{ matrix_user_gid }} \ - --cap-drop=ALL \ - --network={{ matrix_docker_network }} \ - {% if matrix_sms_bridge_container_http_host_bind_port %} - -p {{ matrix_sms_bridge_container_http_host_bind_port }}:7687 \ - {% endif %} - -v {{ matrix_sms_bridge_database_path }}:/data:z \ - -e NEO4J_AUTH={{ matrix_sms_bridge_database_username }}/{{ matrix_sms_bridge_database_password }} - {{ matrix_sms_bridge_database_docker_image }} # Intentional delay, so that the homeserver (we likely depend on) can manage to start. ExecStartPre=/bin/sleep 5 @@ -41,7 +27,7 @@ ExecStart=/usr/bin/docker run --rm --name matrix-sms-bridge \ {% endif %} -v {{ matrix_sms_bridge_config_path }}:/config:z \ -v {{ matrix_sms_bridge_data_path }}:/data:z \ - --device {{ matrix_sms_bridge_gammu_modem }}:/dev/ttyModem + --device {{ matrix_sms_bridge_gammu_modem }}:/dev/ttyModem \ {% for arg in matrix_sms_bridge_container_extra_arguments %} {{ arg }} \ {% endfor %} @@ -49,8 +35,6 @@ ExecStart=/usr/bin/docker run --rm --name matrix-sms-bridge \ ExecStop=-/usr/bin/docker kill matrix-sms-bridge ExecStop=-/usr/bin/docker rm matrix-sms-bridge -ExecStop=-/usr/bin/docker kill matrix-sms-database -ExecStop=-/usr/bin/docker rm matrix-sms-database Restart=always RestartSec=30 SyslogIdentifier=matrix-sms-bridge From ca9d0909c7db61d6a947bdab4a9acebfa58d9086 Mon Sep 17 00:00:00 2001 From: benkuly <12199167+benkuly@users.noreply.github.com> Date: Sat, 23 May 2020 13:48:33 +0200 Subject: [PATCH 04/32] added missing role --- setup.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.yml b/setup.yml index ff80320a..fc0ddc2c 100755 --- a/setup.yml +++ b/setup.yml @@ -18,6 +18,7 @@ - matrix-bridge-mautrix-whatsapp - matrix-bridge-mx-puppet-skype - matrix-bridge-mx-puppet-slack + - matrix-sms-bridge - matrix-synapse - matrix-riot-web - matrix-jitsi From 9ed80e754b285fb6ed97bda31fa89199062f9fb5 Mon Sep 17 00:00:00 2001 From: benkuly <12199167+benkuly@users.noreply.github.com> Date: Sat, 23 May 2020 13:54:07 +0200 Subject: [PATCH 05/32] added missing variable --- roles/matrix-sms-bridge/defaults/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/roles/matrix-sms-bridge/defaults/main.yml b/roles/matrix-sms-bridge/defaults/main.yml index 57a7a373..13263396 100644 --- a/roles/matrix-sms-bridge/defaults/main.yml +++ b/roles/matrix-sms-bridge/defaults/main.yml @@ -117,6 +117,8 @@ matrix_sms_bridge_configuration_extension_yaml: | matrix_sms_bridge_configuration_extension: "{{ matrix_sms_bridge_configuration_extension_yaml|from_yaml if matrix_sms_bridge_configuration_extension_yaml|from_yaml is mapping else {} }}" +matrix_sms_bridge_configuration: "{{ matrix_sms_bridge_configuration_yaml|from_yaml|combine(matrix_sms_bridge_configuration_extension, recursive=True) }}" + matrix_sms_bridge_gammu_configuration: | [gammu] Device = /dev/ttyModem From be101a3114e4e4876cd09facaec0c0843d41f2e7 Mon Sep 17 00:00:00 2001 From: benkuly <12199167+benkuly@users.noreply.github.com> Date: Sat, 23 May 2020 14:16:44 +0200 Subject: [PATCH 06/32] added missing service to service list --- roles/matrix-sms-bridge/tasks/init.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/matrix-sms-bridge/tasks/init.yml b/roles/matrix-sms-bridge/tasks/init.yml index cca4d4c5..7a49e4b2 100644 --- a/roles/matrix-sms-bridge/tasks/init.yml +++ b/roles/matrix-sms-bridge/tasks/init.yml @@ -7,7 +7,7 @@ when: "matrix_sms_bridge_enabled and matrix_synapse_role_executed|default(False)" - set_fact: - matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-sms-bridge'] }}" + matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-sms-bridge','matrix-sms-bridge-database'] }}" when: matrix_sms_bridge_enabled|bool # If the matrix-synapse role is not used, these variables may not exist. From c802009b5c3570eb51690ea58b4079f9d72c6016 Mon Sep 17 00:00:00 2001 From: benkuly <12199167+benkuly@users.noreply.github.com> Date: Sat, 23 May 2020 15:12:56 +0200 Subject: [PATCH 07/32] fixed wrong var name --- roles/matrix-sms-bridge/defaults/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/matrix-sms-bridge/defaults/main.yml b/roles/matrix-sms-bridge/defaults/main.yml index 13263396..8c0aa026 100644 --- a/roles/matrix-sms-bridge/defaults/main.yml +++ b/roles/matrix-sms-bridge/defaults/main.yml @@ -88,7 +88,7 @@ matrix_sms_bridge_configuration_yaml: | # (optional) Path to the Gammu-Inbox directory. inboxPath: "{{ matrix_sms_bridge_data_spool_inbox_path }}" # (optional) Path to the directory, where to put processed messages. - inboxProcessedPath: "{{ matrix_sms_bridge_data_spool_inbox_path_processed }}" + inboxProcessedPath: "{{ matrix_sms_bridge_data_spool_inbox_processed_path }}" bot: # The domain-part of matrix-ids. E. g. example.org when your userIds look like @unicorn:example.org serverName: {{ matrix_sms_bridge_homserver_domain }} From 63705f94f11006636214cbb90311be118ce33edd Mon Sep 17 00:00:00 2001 From: benkuly <12199167+benkuly@users.noreply.github.com> Date: Sat, 23 May 2020 15:30:31 +0200 Subject: [PATCH 08/32] removed templates --- roles/matrix-sms-bridge/defaults/main.yml | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/roles/matrix-sms-bridge/defaults/main.yml b/roles/matrix-sms-bridge/defaults/main.yml index 8c0aa026..aa2dba7e 100644 --- a/roles/matrix-sms-bridge/defaults/main.yml +++ b/roles/matrix-sms-bridge/defaults/main.yml @@ -68,19 +68,6 @@ matrix_sms_bridge_configuration_yaml: | # (optional) SMS messages without a valid token a routed to this room. # Note that you must invite @smsbot:yourHomeServer to this room. defaultRoomId: "{{ matrix_sms_bridge_default_room }}" - templates: - # (optional) The message, that will be sent as SMS. Valid placeholders are {sender}, {body} and {token}. - outgoingMessage: "{sender} wrote:\n\n{body}\n\nTo answer to this message add this token to your message: {token}" - # (optional) The message, that will be sent as SMS, when an incoming SMS didn't contain a valid token - # and was routed to a default room. By default no answer will be sent. - answerInvalidTokenWithDefaultRoom: "Your token was invalid. The message will be sent to a default matrix room." - # (optional) The message, that will be sent as SMS, when an incoming SMS didn't contain a valid token - # and no default room is configured. - answerInvalidTokenWithoutDefaultRoom: "Your message did not contain any valid token. Nobody will read your message.", - # (optional) The message, that will be sent to a matrix room, when sending a bridged message via SMS failed. - sendSmsError: "Could not send SMS to this user. Please try it again later." - # (optional) The content of bridged SMS message into the default room. Valid placeholders are {sender} and {body}. - defaultRoomIncomingMessage: "{sender} wrote:\n{body}" provider: gammu: # (optional) default is disabled From fe54690ea1f266cc4825564facbe6c078b940388 Mon Sep 17 00:00:00 2001 From: benkuly <12199167+benkuly@users.noreply.github.com> Date: Sat, 23 May 2020 15:32:16 +0200 Subject: [PATCH 09/32] fixed missing registration var --- roles/matrix-sms-bridge/defaults/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/roles/matrix-sms-bridge/defaults/main.yml b/roles/matrix-sms-bridge/defaults/main.yml index aa2dba7e..8ffad09b 100644 --- a/roles/matrix-sms-bridge/defaults/main.yml +++ b/roles/matrix-sms-bridge/defaults/main.yml @@ -141,3 +141,5 @@ matrix_sms_bridge_registration_yaml: | url: {{ matrix_sms_bridge_appservice_url }} sender_localpart: smsbot rate_limited: false + +matrix_sms_bridge_registration: "{{ matrix_sms_bridge_registration_yaml|from_yaml }}" \ No newline at end of file From f0ff8112c74d2800354900181750cb9134fbe556 Mon Sep 17 00:00:00 2001 From: benkuly <12199167+benkuly@users.noreply.github.com> Date: Sat, 23 May 2020 20:51:07 +0200 Subject: [PATCH 10/32] database admin username must be neo4j --- roles/matrix-sms-bridge/defaults/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/matrix-sms-bridge/defaults/main.yml b/roles/matrix-sms-bridge/defaults/main.yml index 8ffad09b..db337313 100644 --- a/roles/matrix-sms-bridge/defaults/main.yml +++ b/roles/matrix-sms-bridge/defaults/main.yml @@ -23,7 +23,7 @@ matrix_sms_bridge_database_path: "{{ matrix_base_data_path }}/matrix-sms-bridge/ matrix_sms_bridge_appservice_token: '' matrix_sms_bridge_homeserver_token: '' -matrix_sms_bridge_database_username: 'matrix-sms-bridge' +matrix_sms_bridge_database_username: 'neo4j' matrix_sms_bridge_database_password: '' matrix_sms_bridge_container_http_host_bind_port: '' From eb8e3572fda55490aee53b31489218f3e2d454b1 Mon Sep 17 00:00:00 2001 From: benkuly <12199167+benkuly@users.noreply.github.com> Date: Mon, 25 May 2020 15:37:46 +0200 Subject: [PATCH 11/32] fixed wrong behaviour of gammu --- .../templates/systemd/matrix-sms-bridge.service.j2 | 1 + 1 file changed, 1 insertion(+) diff --git a/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 b/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 index 86ac264d..e963f8cf 100644 --- a/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 +++ b/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 @@ -27,6 +27,7 @@ ExecStart=/usr/bin/docker run --rm --name matrix-sms-bridge \ {% endif %} -v {{ matrix_sms_bridge_config_path }}:/config:z \ -v {{ matrix_sms_bridge_data_path }}:/data:z \ + -v {{ matrix_sms_bridge_data_path }}/gammu-smsdrc:/etc/gammu-smsdrc:z \ --device {{ matrix_sms_bridge_gammu_modem }}:/dev/ttyModem \ {% for arg in matrix_sms_bridge_container_extra_arguments %} {{ arg }} \ From 469554b8363edfa910f639c4cdcf3f200242fa56 Mon Sep 17 00:00:00 2001 From: benkuly <12199167+benkuly@users.noreply.github.com> Date: Mon, 25 May 2020 19:04:56 +0200 Subject: [PATCH 12/32] try to use other mount option to prevent docker from using dir instead of file --- .../templates/systemd/matrix-sms-bridge.service.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 b/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 index e963f8cf..1c82dc31 100644 --- a/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 +++ b/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 @@ -27,7 +27,7 @@ ExecStart=/usr/bin/docker run --rm --name matrix-sms-bridge \ {% endif %} -v {{ matrix_sms_bridge_config_path }}:/config:z \ -v {{ matrix_sms_bridge_data_path }}:/data:z \ - -v {{ matrix_sms_bridge_data_path }}/gammu-smsdrc:/etc/gammu-smsdrc:z \ + --mount type=bind,source={{ matrix_sms_bridge_data_path }}/gammu-smsdrc,target=/etc/gammu-smsdrc \ --device {{ matrix_sms_bridge_gammu_modem }}:/dev/ttyModem \ {% for arg in matrix_sms_bridge_container_extra_arguments %} {{ arg }} \ From 1f570b3251eba6d28df14d92d398ec1ab4868c04 Mon Sep 17 00:00:00 2001 From: benkuly <12199167+benkuly@users.noreply.github.com> Date: Mon, 25 May 2020 19:09:08 +0200 Subject: [PATCH 13/32] revert last change --- .../templates/systemd/matrix-sms-bridge.service.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 b/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 index 1c82dc31..e963f8cf 100644 --- a/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 +++ b/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 @@ -27,7 +27,7 @@ ExecStart=/usr/bin/docker run --rm --name matrix-sms-bridge \ {% endif %} -v {{ matrix_sms_bridge_config_path }}:/config:z \ -v {{ matrix_sms_bridge_data_path }}:/data:z \ - --mount type=bind,source={{ matrix_sms_bridge_data_path }}/gammu-smsdrc,target=/etc/gammu-smsdrc \ + -v {{ matrix_sms_bridge_data_path }}/gammu-smsdrc:/etc/gammu-smsdrc:z \ --device {{ matrix_sms_bridge_gammu_modem }}:/dev/ttyModem \ {% for arg in matrix_sms_bridge_container_extra_arguments %} {{ arg }} \ From 73b71a34c86e0e8f53f60f01e03325af32dea402 Mon Sep 17 00:00:00 2001 From: benkuly <12199167+benkuly@users.noreply.github.com> Date: Mon, 25 May 2020 19:19:30 +0200 Subject: [PATCH 14/32] try to fix gammu-smsdrc is not a file --- roles/matrix-sms-bridge/defaults/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/roles/matrix-sms-bridge/defaults/main.yml b/roles/matrix-sms-bridge/defaults/main.yml index db337313..7f048ff3 100644 --- a/roles/matrix-sms-bridge/defaults/main.yml +++ b/roles/matrix-sms-bridge/defaults/main.yml @@ -107,6 +107,8 @@ matrix_sms_bridge_configuration_extension: "{{ matrix_sms_bridge_configuration_e matrix_sms_bridge_configuration: "{{ matrix_sms_bridge_configuration_yaml|from_yaml|combine(matrix_sms_bridge_configuration_extension, recursive=True) }}" matrix_sms_bridge_gammu_configuration: | + #jinja2: lstrip_blocks: "True" + [gammu] Device = /dev/ttyModem LogFile = {{ matrix_sms_bridge_data_log_path }}/gammu.log From 805708e0894c88dd65a334822725577ba319da58 Mon Sep 17 00:00:00 2001 From: benkuly <12199167+benkuly@users.noreply.github.com> Date: Mon, 25 May 2020 19:21:07 +0200 Subject: [PATCH 15/32] fix wrong used paath for gammu config file --- .../templates/systemd/matrix-sms-bridge.service.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 b/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 index e963f8cf..5475a389 100644 --- a/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 +++ b/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 @@ -27,7 +27,7 @@ ExecStart=/usr/bin/docker run --rm --name matrix-sms-bridge \ {% endif %} -v {{ matrix_sms_bridge_config_path }}:/config:z \ -v {{ matrix_sms_bridge_data_path }}:/data:z \ - -v {{ matrix_sms_bridge_data_path }}/gammu-smsdrc:/etc/gammu-smsdrc:z \ + -v {{ matrix_sms_bridge_config_path }}/gammu-smsdrc:/etc/gammu-smsdrc:z \ --device {{ matrix_sms_bridge_gammu_modem }}:/dev/ttyModem \ {% for arg in matrix_sms_bridge_container_extra_arguments %} {{ arg }} \ From f8663512de2b0997e0b4e0ac4dde956dfe6aaedd Mon Sep 17 00:00:00 2001 From: benkuly <12199167+benkuly@users.noreply.github.com> Date: Mon, 25 May 2020 19:31:03 +0200 Subject: [PATCH 16/32] fixed wrong paths --- roles/matrix-sms-bridge/defaults/main.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/roles/matrix-sms-bridge/defaults/main.yml b/roles/matrix-sms-bridge/defaults/main.yml index 7f048ff3..1dccb4e8 100644 --- a/roles/matrix-sms-bridge/defaults/main.yml +++ b/roles/matrix-sms-bridge/defaults/main.yml @@ -73,9 +73,9 @@ matrix_sms_bridge_configuration_yaml: | # (optional) default is disabled enabled: true # (optional) Path to the Gammu-Inbox directory. - inboxPath: "{{ matrix_sms_bridge_data_spool_inbox_path }}" + inboxPath: /data/spool/inbox # (optional) Path to the directory, where to put processed messages. - inboxProcessedPath: "{{ matrix_sms_bridge_data_spool_inbox_processed_path }}" + inboxProcessedPath: /data/spool/inbox_processed bot: # The domain-part of matrix-ids. E. g. example.org when your userIds look like @unicorn:example.org serverName: {{ matrix_sms_bridge_homserver_domain }} @@ -111,21 +111,21 @@ matrix_sms_bridge_gammu_configuration: | [gammu] Device = /dev/ttyModem - LogFile = {{ matrix_sms_bridge_data_log_path }}/gammu.log + LogFile = /data/log/gammu.log debugLevel = 1 [smsd] Service = files LoopSleep = 2 - InboxPath = {{ matrix_sms_bridge_data_spool_inbox_path }} - OutboxPath = {{ matrix_sms_bridge_data_spool_outbox_path }} - SentSMSPath = {{ matrix_sms_bridge_data_spool_sent_path }} - ErrorSMSPath = {{ matrix_sms_bridge_data_spool_error_path }} + InboxPath = /data/spool/inbox + OutboxPath = /data/spool/outbox + SentSMSPath = /data/spool/sent + ErrorSMSPath = /data/spool/error InboxFormat = detail OutboxFormat = detail TransmitFormat = auto debugLevel = 1 - LogFile = {{ matrix_sms_bridge_data_log_path }}/smsd.log + LogFile = /data/log/smsd.log DeliveryReport = log DeliveryReportDelay = 7200 HangupCalls = 1 From ecf3116c4ab450e2ca54208d25044517a8b4e5c9 Mon Sep 17 00:00:00 2001 From: benkuly <12199167+benkuly@users.noreply.github.com> Date: Mon, 25 May 2020 19:34:40 +0200 Subject: [PATCH 17/32] fixed wrong gammu config dest --- roles/matrix-sms-bridge/tasks/setup_install.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/matrix-sms-bridge/tasks/setup_install.yml b/roles/matrix-sms-bridge/tasks/setup_install.yml index 1e86f2e6..47454b27 100644 --- a/roles/matrix-sms-bridge/tasks/setup_install.yml +++ b/roles/matrix-sms-bridge/tasks/setup_install.yml @@ -53,7 +53,7 @@ - name: Ensure matrix-sms-bridge gammu-smsdrc installed copy: - content: "{{ matrix_sms_bridge_registration }}" + content: "{{ matrix_sms_bridge_gammu_configuration }}" dest: "{{ matrix_sms_bridge_config_path }}/gammu-smsdrc" mode: 0644 owner: "{{ matrix_user_username }}" From a7fd27c43c0d8bd56f92163a896c72001d99a5c2 Mon Sep 17 00:00:00 2001 From: benkuly <12199167+benkuly@users.noreply.github.com> Date: Mon, 25 May 2020 19:36:19 +0200 Subject: [PATCH 18/32] removed jinja command --- roles/matrix-sms-bridge/defaults/main.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/roles/matrix-sms-bridge/defaults/main.yml b/roles/matrix-sms-bridge/defaults/main.yml index 1dccb4e8..428560f5 100644 --- a/roles/matrix-sms-bridge/defaults/main.yml +++ b/roles/matrix-sms-bridge/defaults/main.yml @@ -107,8 +107,6 @@ matrix_sms_bridge_configuration_extension: "{{ matrix_sms_bridge_configuration_e matrix_sms_bridge_configuration: "{{ matrix_sms_bridge_configuration_yaml|from_yaml|combine(matrix_sms_bridge_configuration_extension, recursive=True) }}" matrix_sms_bridge_gammu_configuration: | - #jinja2: lstrip_blocks: "True" - [gammu] Device = /dev/ttyModem LogFile = /data/log/gammu.log From 3d63ee6d13bbf087e8538b3927ffd4f8f345efe5 Mon Sep 17 00:00:00 2001 From: benkuly <12199167+benkuly@users.noreply.github.com> Date: Tue, 26 May 2020 18:12:26 +0200 Subject: [PATCH 19/32] add group dialout to container --- .../templates/systemd/matrix-sms-bridge.service.j2 | 1 + 1 file changed, 1 insertion(+) diff --git a/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 b/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 index 5475a389..5c3b9544 100644 --- a/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 +++ b/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 @@ -20,6 +20,7 @@ ExecStartPre=/bin/sleep 5 ExecStart=/usr/bin/docker run --rm --name matrix-sms-bridge \ --log-driver=none \ --user={{ matrix_user_uid }}:{{ matrix_user_gid }} \ + --group-add dialout \ --cap-drop=ALL \ --network={{ matrix_docker_network }} \ {% if matrix_sms_bridge_container_http_host_bind_port %} From e4f128a1ba02bf45709e0d7111abe352135630fd Mon Sep 17 00:00:00 2001 From: benkuly <12199167+benkuly@users.noreply.github.com> Date: Tue, 26 May 2020 18:19:22 +0200 Subject: [PATCH 20/32] fixed wrong gammu path --- roles/matrix-sms-bridge/defaults/main.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/roles/matrix-sms-bridge/defaults/main.yml b/roles/matrix-sms-bridge/defaults/main.yml index 428560f5..faf2b6fc 100644 --- a/roles/matrix-sms-bridge/defaults/main.yml +++ b/roles/matrix-sms-bridge/defaults/main.yml @@ -115,10 +115,10 @@ matrix_sms_bridge_gammu_configuration: | [smsd] Service = files LoopSleep = 2 - InboxPath = /data/spool/inbox - OutboxPath = /data/spool/outbox - SentSMSPath = /data/spool/sent - ErrorSMSPath = /data/spool/error + InboxPath = /data/spool/inbox/ + OutboxPath = /data/spool/outbox/ + SentSMSPath = /data/spool/sent/ + ErrorSMSPath = /data/spool/error/ InboxFormat = detail OutboxFormat = detail TransmitFormat = auto From 0b7d6744bfd64b1c6be1131d3d68bd93fba2f9b2 Mon Sep 17 00:00:00 2001 From: benkuly <12199167+benkuly@users.noreply.github.com> Date: Tue, 2 Jun 2020 08:39:30 +0200 Subject: [PATCH 21/32] added more docs and timeout value --- docs/configuring-playbook-matrix-sms-bridge.md | 6 ++++++ roles/matrix-sms-bridge/defaults/main.yml | 3 +++ .../templates/systemd/matrix-sms-bridge.service.j2 | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/configuring-playbook-matrix-sms-bridge.md b/docs/configuring-playbook-matrix-sms-bridge.md index ef2aeb08..00aaecec 100644 --- a/docs/configuring-playbook-matrix-sms-bridge.md +++ b/docs/configuring-playbook-matrix-sms-bridge.md @@ -5,6 +5,8 @@ The playbook can install and configure See the project page to learn what it does and why it might be useful to you. +First you need to ensure, that the bridge has unix read and write rights to your modem. On debian based distributions there is nothing to do. On others distributions you either add a group `dialout` to your host and assign it to your modem or you give the matrix user or group access to your modem. + To enable the bridge just use the following playbook configuration: @@ -16,6 +18,10 @@ matrix_sms_bridge_gammu_modem: "/path/to/modem" matrix_sms_bridge_database_password: "" # (optional) a room id to a default room matrix_sms_bridge_default_room: "" +# (optional) gammu reset frequency (see https://wammu.eu/docs/manual/smsd/config.html#option-ResetFrequency) +matrix_sms_bridge_gammu_reset_frequency: 3600 +# (optional) group with unix read and write rights to modem +matrix_sms_bridge_modem_group: 'dialout' ``` diff --git a/roles/matrix-sms-bridge/defaults/main.yml b/roles/matrix-sms-bridge/defaults/main.yml index faf2b6fc..610b8f46 100644 --- a/roles/matrix-sms-bridge/defaults/main.yml +++ b/roles/matrix-sms-bridge/defaults/main.yml @@ -48,6 +48,8 @@ matrix_sms_bridge_homserver_domain: "{{ matrix_domain }}" matrix_sms_bridge_default_room: '' matrix_sms_bridge_gammu_modem: '' +matrix_sms_bridge_modem_group: 'dialout' +matrix_sms_bridge_gammu_reset_frequency: 0 matrix_sms_bridge_configuration_yaml: | @@ -122,6 +124,7 @@ matrix_sms_bridge_gammu_configuration: | InboxFormat = detail OutboxFormat = detail TransmitFormat = auto + ResetFrequency = {{ matrix_sms_bridge_gammu_reset_frequency }} debugLevel = 1 LogFile = /data/log/smsd.log DeliveryReport = log diff --git a/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 b/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 index 5c3b9544..cf8ab9fe 100644 --- a/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 +++ b/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 @@ -20,7 +20,7 @@ ExecStartPre=/bin/sleep 5 ExecStart=/usr/bin/docker run --rm --name matrix-sms-bridge \ --log-driver=none \ --user={{ matrix_user_uid }}:{{ matrix_user_gid }} \ - --group-add dialout \ + --group-add {{ matrix_sms_bridge_modem_group }} \ --cap-drop=ALL \ --network={{ matrix_docker_network }} \ {% if matrix_sms_bridge_container_http_host_bind_port %} From f383b152da8f0c5fcc68fcbf237fc8054465c41b Mon Sep 17 00:00:00 2001 From: benkuly <12199167+benkuly@users.noreply.github.com> Date: Tue, 2 Jun 2020 14:49:55 +0200 Subject: [PATCH 22/32] removed gammu reset frequency because the tty port will change --- docs/configuring-playbook-matrix-sms-bridge.md | 4 +--- roles/matrix-sms-bridge/defaults/main.yml | 3 --- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/docs/configuring-playbook-matrix-sms-bridge.md b/docs/configuring-playbook-matrix-sms-bridge.md index 00aaecec..b3629ce5 100644 --- a/docs/configuring-playbook-matrix-sms-bridge.md +++ b/docs/configuring-playbook-matrix-sms-bridge.md @@ -17,9 +17,7 @@ matrix_sms_bridge_gammu_modem: "/path/to/modem" # generate a secret passwort e.g. with pwgen -s 64 1 matrix_sms_bridge_database_password: "" # (optional) a room id to a default room -matrix_sms_bridge_default_room: "" -# (optional) gammu reset frequency (see https://wammu.eu/docs/manual/smsd/config.html#option-ResetFrequency) -matrix_sms_bridge_gammu_reset_frequency: 3600 +matrix_sms_bridge_default_room: "" # (optional) group with unix read and write rights to modem matrix_sms_bridge_modem_group: 'dialout' ``` diff --git a/roles/matrix-sms-bridge/defaults/main.yml b/roles/matrix-sms-bridge/defaults/main.yml index 610b8f46..1e0bfaa3 100644 --- a/roles/matrix-sms-bridge/defaults/main.yml +++ b/roles/matrix-sms-bridge/defaults/main.yml @@ -49,8 +49,6 @@ matrix_sms_bridge_default_room: '' matrix_sms_bridge_gammu_modem: '' matrix_sms_bridge_modem_group: 'dialout' -matrix_sms_bridge_gammu_reset_frequency: 0 - matrix_sms_bridge_configuration_yaml: | #jinja2: lstrip_blocks: "True" @@ -124,7 +122,6 @@ matrix_sms_bridge_gammu_configuration: | InboxFormat = detail OutboxFormat = detail TransmitFormat = auto - ResetFrequency = {{ matrix_sms_bridge_gammu_reset_frequency }} debugLevel = 1 LogFile = /data/log/smsd.log DeliveryReport = log From cd179288053b628e7e2962744e1d56094e4902e8 Mon Sep 17 00:00:00 2001 From: benkuly <12199167+benkuly@users.noreply.github.com> Date: Tue, 2 Jun 2020 14:56:22 +0200 Subject: [PATCH 23/32] revert remove of frequency --- docs/configuring-playbook-matrix-sms-bridge.md | 4 +++- roles/matrix-sms-bridge/defaults/main.yml | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/configuring-playbook-matrix-sms-bridge.md b/docs/configuring-playbook-matrix-sms-bridge.md index b3629ce5..00aaecec 100644 --- a/docs/configuring-playbook-matrix-sms-bridge.md +++ b/docs/configuring-playbook-matrix-sms-bridge.md @@ -17,7 +17,9 @@ matrix_sms_bridge_gammu_modem: "/path/to/modem" # generate a secret passwort e.g. with pwgen -s 64 1 matrix_sms_bridge_database_password: "" # (optional) a room id to a default room -matrix_sms_bridge_default_room: "" +matrix_sms_bridge_default_room: "" +# (optional) gammu reset frequency (see https://wammu.eu/docs/manual/smsd/config.html#option-ResetFrequency) +matrix_sms_bridge_gammu_reset_frequency: 3600 # (optional) group with unix read and write rights to modem matrix_sms_bridge_modem_group: 'dialout' ``` diff --git a/roles/matrix-sms-bridge/defaults/main.yml b/roles/matrix-sms-bridge/defaults/main.yml index 1e0bfaa3..610b8f46 100644 --- a/roles/matrix-sms-bridge/defaults/main.yml +++ b/roles/matrix-sms-bridge/defaults/main.yml @@ -49,6 +49,8 @@ matrix_sms_bridge_default_room: '' matrix_sms_bridge_gammu_modem: '' matrix_sms_bridge_modem_group: 'dialout' +matrix_sms_bridge_gammu_reset_frequency: 0 + matrix_sms_bridge_configuration_yaml: | #jinja2: lstrip_blocks: "True" @@ -122,6 +124,7 @@ matrix_sms_bridge_gammu_configuration: | InboxFormat = detail OutboxFormat = detail TransmitFormat = auto + ResetFrequency = {{ matrix_sms_bridge_gammu_reset_frequency }} debugLevel = 1 LogFile = /data/log/smsd.log DeliveryReport = log From 2fd8216fbc4d0525da3d65b7abb44e266baca5f9 Mon Sep 17 00:00:00 2001 From: benkuly <12199167+benkuly@users.noreply.github.com> Date: Tue, 2 Jun 2020 18:27:33 +0200 Subject: [PATCH 24/32] try to fix device reconnect issues --- docs/configuring-playbook-matrix-sms-bridge.md | 4 +++- roles/matrix-sms-bridge/defaults/main.yml | 3 ++- .../templates/systemd/matrix-sms-bridge.service.j2 | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/configuring-playbook-matrix-sms-bridge.md b/docs/configuring-playbook-matrix-sms-bridge.md index 00aaecec..4a486774 100644 --- a/docs/configuring-playbook-matrix-sms-bridge.md +++ b/docs/configuring-playbook-matrix-sms-bridge.md @@ -13,7 +13,7 @@ playbook configuration: ```yaml matrix_sms_bridge_enabled: true -matrix_sms_bridge_gammu_modem: "/path/to/modem" +matrix_sms_bridge_gammu_modem: "/dev/serial/by-id/myDeviceId" # generate a secret passwort e.g. with pwgen -s 64 1 matrix_sms_bridge_database_password: "" # (optional) a room id to a default room @@ -22,6 +22,8 @@ matrix_sms_bridge_default_room: "" matrix_sms_bridge_gammu_reset_frequency: 3600 # (optional) group with unix read and write rights to modem matrix_sms_bridge_modem_group: 'dialout' +# (optional) cgroup major number to allow access to devices, that gets reconnected (e.g. due to reset) +matrix_sms_bridge_cgroup_major_number: '188' ``` diff --git a/roles/matrix-sms-bridge/defaults/main.yml b/roles/matrix-sms-bridge/defaults/main.yml index 610b8f46..0bbdc5a0 100644 --- a/roles/matrix-sms-bridge/defaults/main.yml +++ b/roles/matrix-sms-bridge/defaults/main.yml @@ -48,6 +48,7 @@ matrix_sms_bridge_homserver_domain: "{{ matrix_domain }}" matrix_sms_bridge_default_room: '' matrix_sms_bridge_gammu_modem: '' +matrix_sms_bridge_cgroup_major_number: '188' matrix_sms_bridge_modem_group: 'dialout' matrix_sms_bridge_gammu_reset_frequency: 0 @@ -110,7 +111,7 @@ matrix_sms_bridge_configuration: "{{ matrix_sms_bridge_configuration_yaml|from_y matrix_sms_bridge_gammu_configuration: | [gammu] - Device = /dev/ttyModem + Device = {{ matrix_sms_bridge_gammu_modem }} LogFile = /data/log/gammu.log debugLevel = 1 diff --git a/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 b/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 index cf8ab9fe..bb43a4b8 100644 --- a/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 +++ b/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 @@ -29,7 +29,8 @@ ExecStart=/usr/bin/docker run --rm --name matrix-sms-bridge \ -v {{ matrix_sms_bridge_config_path }}:/config:z \ -v {{ matrix_sms_bridge_data_path }}:/data:z \ -v {{ matrix_sms_bridge_config_path }}/gammu-smsdrc:/etc/gammu-smsdrc:z \ - --device {{ matrix_sms_bridge_gammu_modem }}:/dev/ttyModem \ + --device-cgroup-rule='c {{ matrix_sms_bridge_cgroup_major_number }}:* rmw' \ + --device {{ matrix_sms_bridge_gammu_modem }}:{{ matrix_sms_bridge_gammu_modem }} \ {% for arg in matrix_sms_bridge_container_extra_arguments %} {{ arg }} \ {% endfor %} From 26846a5f6c4e9293dede8001f20828e2be227125 Mon Sep 17 00:00:00 2001 From: benkuly <12199167+benkuly@users.noreply.github.com> Date: Tue, 2 Jun 2020 22:04:52 +0200 Subject: [PATCH 25/32] try privileged way --- docs/configuring-playbook-matrix-sms-bridge.md | 2 -- roles/matrix-sms-bridge/defaults/main.yml | 1 - .../templates/systemd/matrix-sms-bridge.service.j2 | 4 ++-- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/docs/configuring-playbook-matrix-sms-bridge.md b/docs/configuring-playbook-matrix-sms-bridge.md index 4a486774..31a85228 100644 --- a/docs/configuring-playbook-matrix-sms-bridge.md +++ b/docs/configuring-playbook-matrix-sms-bridge.md @@ -22,8 +22,6 @@ matrix_sms_bridge_default_room: "" matrix_sms_bridge_gammu_reset_frequency: 3600 # (optional) group with unix read and write rights to modem matrix_sms_bridge_modem_group: 'dialout' -# (optional) cgroup major number to allow access to devices, that gets reconnected (e.g. due to reset) -matrix_sms_bridge_cgroup_major_number: '188' ``` diff --git a/roles/matrix-sms-bridge/defaults/main.yml b/roles/matrix-sms-bridge/defaults/main.yml index 0bbdc5a0..6465a9d4 100644 --- a/roles/matrix-sms-bridge/defaults/main.yml +++ b/roles/matrix-sms-bridge/defaults/main.yml @@ -48,7 +48,6 @@ matrix_sms_bridge_homserver_domain: "{{ matrix_domain }}" matrix_sms_bridge_default_room: '' matrix_sms_bridge_gammu_modem: '' -matrix_sms_bridge_cgroup_major_number: '188' matrix_sms_bridge_modem_group: 'dialout' matrix_sms_bridge_gammu_reset_frequency: 0 diff --git a/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 b/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 index bb43a4b8..f0634dbe 100644 --- a/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 +++ b/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 @@ -29,8 +29,8 @@ ExecStart=/usr/bin/docker run --rm --name matrix-sms-bridge \ -v {{ matrix_sms_bridge_config_path }}:/config:z \ -v {{ matrix_sms_bridge_data_path }}:/data:z \ -v {{ matrix_sms_bridge_config_path }}/gammu-smsdrc:/etc/gammu-smsdrc:z \ - --device-cgroup-rule='c {{ matrix_sms_bridge_cgroup_major_number }}:* rmw' \ - --device {{ matrix_sms_bridge_gammu_modem }}:{{ matrix_sms_bridge_gammu_modem }} \ + --privileged \ + -v /dev:/dev \ {% for arg in matrix_sms_bridge_container_extra_arguments %} {{ arg }} \ {% endfor %} From 0967bc3cd9500bc75363996e0c16f09e7099201b Mon Sep 17 00:00:00 2001 From: benkuly <12199167+benkuly@users.noreply.github.com> Date: Wed, 3 Jun 2020 12:03:44 +0200 Subject: [PATCH 26/32] added missing z flag --- .../templates/systemd/matrix-sms-bridge.service.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 b/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 index f0634dbe..087e678a 100644 --- a/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 +++ b/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 @@ -30,7 +30,7 @@ ExecStart=/usr/bin/docker run --rm --name matrix-sms-bridge \ -v {{ matrix_sms_bridge_data_path }}:/data:z \ -v {{ matrix_sms_bridge_config_path }}/gammu-smsdrc:/etc/gammu-smsdrc:z \ --privileged \ - -v /dev:/dev \ + -v /dev:/dev:z \ {% for arg in matrix_sms_bridge_container_extra_arguments %} {{ arg }} \ {% endfor %} From 41b1925b2a20c302ff2c6b7e13858030d22fb629 Mon Sep 17 00:00:00 2001 From: benkuly <12199167+benkuly@users.noreply.github.com> Date: Wed, 3 Jun 2020 13:07:36 +0200 Subject: [PATCH 27/32] remove dev mount --- .../templates/systemd/matrix-sms-bridge.service.j2 | 1 - 1 file changed, 1 deletion(-) diff --git a/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 b/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 index 087e678a..6bb6449e 100644 --- a/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 +++ b/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 @@ -30,7 +30,6 @@ ExecStart=/usr/bin/docker run --rm --name matrix-sms-bridge \ -v {{ matrix_sms_bridge_data_path }}:/data:z \ -v {{ matrix_sms_bridge_config_path }}/gammu-smsdrc:/etc/gammu-smsdrc:z \ --privileged \ - -v /dev:/dev:z \ {% for arg in matrix_sms_bridge_container_extra_arguments %} {{ arg }} \ {% endfor %} From 3a3b95abfc6c67457e349170c81e90f203b3cdfe Mon Sep 17 00:00:00 2001 From: benkuly <12199167+benkuly@users.noreply.github.com> Date: Wed, 3 Jun 2020 13:13:25 +0200 Subject: [PATCH 28/32] added dev volume to find serial by id --- .../templates/systemd/matrix-sms-bridge.service.j2 | 1 + 1 file changed, 1 insertion(+) diff --git a/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 b/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 index 6bb6449e..087e678a 100644 --- a/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 +++ b/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 @@ -30,6 +30,7 @@ ExecStart=/usr/bin/docker run --rm --name matrix-sms-bridge \ -v {{ matrix_sms_bridge_data_path }}:/data:z \ -v {{ matrix_sms_bridge_config_path }}/gammu-smsdrc:/etc/gammu-smsdrc:z \ --privileged \ + -v /dev:/dev:z \ {% for arg in matrix_sms_bridge_container_extra_arguments %} {{ arg }} \ {% endfor %} From b60a4ac6433cbb7467c450135511f9368e72a565 Mon Sep 17 00:00:00 2001 From: benkuly <12199167+benkuly@users.noreply.github.com> Date: Wed, 3 Jun 2020 14:25:23 +0200 Subject: [PATCH 29/32] mount as slave --- .../templates/systemd/matrix-sms-bridge.service.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 b/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 index 087e678a..7bf91700 100644 --- a/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 +++ b/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 @@ -30,7 +30,7 @@ ExecStart=/usr/bin/docker run --rm --name matrix-sms-bridge \ -v {{ matrix_sms_bridge_data_path }}:/data:z \ -v {{ matrix_sms_bridge_config_path }}/gammu-smsdrc:/etc/gammu-smsdrc:z \ --privileged \ - -v /dev:/dev:z \ + -v /dev:/dev:slave \ {% for arg in matrix_sms_bridge_container_extra_arguments %} {{ arg }} \ {% endfor %} From 85c6befc041b7365ff1c9200a837358f706b413d Mon Sep 17 00:00:00 2001 From: benkuly <12199167+benkuly@users.noreply.github.com> Date: Wed, 3 Jun 2020 20:02:37 +0200 Subject: [PATCH 30/32] removed unused delivery report --- roles/matrix-sms-bridge/defaults/main.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/roles/matrix-sms-bridge/defaults/main.yml b/roles/matrix-sms-bridge/defaults/main.yml index 6465a9d4..4019f7be 100644 --- a/roles/matrix-sms-bridge/defaults/main.yml +++ b/roles/matrix-sms-bridge/defaults/main.yml @@ -127,8 +127,7 @@ matrix_sms_bridge_gammu_configuration: | ResetFrequency = {{ matrix_sms_bridge_gammu_reset_frequency }} debugLevel = 1 LogFile = /data/log/smsd.log - DeliveryReport = log - DeliveryReportDelay = 7200 + DeliveryReport = no HangupCalls = 1 CheckBattery = 0 From f68e47d3c4175b3b1ba2727ecf33326774c92ca6 Mon Sep 17 00:00:00 2001 From: benkuly <12199167+benkuly@users.noreply.github.com> Date: Fri, 5 Jun 2020 12:25:41 +0200 Subject: [PATCH 31/32] renamed role matrix-sms-bridge to matrix-bridge-sms --- ...-sms-bridge.md => configuring-playbook-matrix-bridge-sms.md} | 2 +- docs/configuring-playbook.md | 2 +- .../{matrix-sms-bridge => matrix-bridge-sms}/defaults/main.yml | 0 roles/{matrix-sms-bridge => matrix-bridge-sms}/tasks/init.yml | 0 roles/{matrix-sms-bridge => matrix-bridge-sms}/tasks/main.yml | 0 .../tasks/setup_install.yml | 0 .../tasks/setup_uninstall.yml | 0 .../tasks/validate_config.yml | 0 .../templates/systemd/matrix-sms-bridge-database.service.j2 | 0 .../templates/systemd/matrix-sms-bridge.service.j2 | 0 setup.yml | 2 +- 11 files changed, 3 insertions(+), 3 deletions(-) rename docs/{configuring-playbook-matrix-sms-bridge.md => configuring-playbook-matrix-bridge-sms.md} (96%) rename roles/{matrix-sms-bridge => matrix-bridge-sms}/defaults/main.yml (100%) rename roles/{matrix-sms-bridge => matrix-bridge-sms}/tasks/init.yml (100%) rename roles/{matrix-sms-bridge => matrix-bridge-sms}/tasks/main.yml (100%) rename roles/{matrix-sms-bridge => matrix-bridge-sms}/tasks/setup_install.yml (100%) rename roles/{matrix-sms-bridge => matrix-bridge-sms}/tasks/setup_uninstall.yml (100%) rename roles/{matrix-sms-bridge => matrix-bridge-sms}/tasks/validate_config.yml (100%) rename roles/{matrix-sms-bridge => matrix-bridge-sms}/templates/systemd/matrix-sms-bridge-database.service.j2 (100%) rename roles/{matrix-sms-bridge => matrix-bridge-sms}/templates/systemd/matrix-sms-bridge.service.j2 (100%) diff --git a/docs/configuring-playbook-matrix-sms-bridge.md b/docs/configuring-playbook-matrix-bridge-sms.md similarity index 96% rename from docs/configuring-playbook-matrix-sms-bridge.md rename to docs/configuring-playbook-matrix-bridge-sms.md index 31a85228..2809fb03 100644 --- a/docs/configuring-playbook-matrix-sms-bridge.md +++ b/docs/configuring-playbook-matrix-bridge-sms.md @@ -1,4 +1,4 @@ -# Setting up matrix-sms-bridge (optional) +# Setting up matrix-bridge-sms (optional) The playbook can install and configure [matrix-sms-brdige](https://github.com/benkuly/matrix-sms-bridge) for you. diff --git a/docs/configuring-playbook.md b/docs/configuring-playbook.md index 90771cf3..208db5bb 100644 --- a/docs/configuring-playbook.md +++ b/docs/configuring-playbook.md @@ -103,4 +103,4 @@ When you're done with all the configuration you'd like to do, continue with [Ins - [Setting up Email2Matrix](configuring-playbook-email2matrix.md) (optional) -- [Setting up Matrix SMS bridging](configuring-playbook-matrix-sms-bridge.md) (optional) +- [Setting up Matrix SMS bridging](configuring-playbook-matrix-bridge-sms.md) (optional) diff --git a/roles/matrix-sms-bridge/defaults/main.yml b/roles/matrix-bridge-sms/defaults/main.yml similarity index 100% rename from roles/matrix-sms-bridge/defaults/main.yml rename to roles/matrix-bridge-sms/defaults/main.yml diff --git a/roles/matrix-sms-bridge/tasks/init.yml b/roles/matrix-bridge-sms/tasks/init.yml similarity index 100% rename from roles/matrix-sms-bridge/tasks/init.yml rename to roles/matrix-bridge-sms/tasks/init.yml diff --git a/roles/matrix-sms-bridge/tasks/main.yml b/roles/matrix-bridge-sms/tasks/main.yml similarity index 100% rename from roles/matrix-sms-bridge/tasks/main.yml rename to roles/matrix-bridge-sms/tasks/main.yml diff --git a/roles/matrix-sms-bridge/tasks/setup_install.yml b/roles/matrix-bridge-sms/tasks/setup_install.yml similarity index 100% rename from roles/matrix-sms-bridge/tasks/setup_install.yml rename to roles/matrix-bridge-sms/tasks/setup_install.yml diff --git a/roles/matrix-sms-bridge/tasks/setup_uninstall.yml b/roles/matrix-bridge-sms/tasks/setup_uninstall.yml similarity index 100% rename from roles/matrix-sms-bridge/tasks/setup_uninstall.yml rename to roles/matrix-bridge-sms/tasks/setup_uninstall.yml diff --git a/roles/matrix-sms-bridge/tasks/validate_config.yml b/roles/matrix-bridge-sms/tasks/validate_config.yml similarity index 100% rename from roles/matrix-sms-bridge/tasks/validate_config.yml rename to roles/matrix-bridge-sms/tasks/validate_config.yml diff --git a/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge-database.service.j2 b/roles/matrix-bridge-sms/templates/systemd/matrix-sms-bridge-database.service.j2 similarity index 100% rename from roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge-database.service.j2 rename to roles/matrix-bridge-sms/templates/systemd/matrix-sms-bridge-database.service.j2 diff --git a/roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 b/roles/matrix-bridge-sms/templates/systemd/matrix-sms-bridge.service.j2 similarity index 100% rename from roles/matrix-sms-bridge/templates/systemd/matrix-sms-bridge.service.j2 rename to roles/matrix-bridge-sms/templates/systemd/matrix-sms-bridge.service.j2 diff --git a/setup.yml b/setup.yml index fc0ddc2c..4831873e 100755 --- a/setup.yml +++ b/setup.yml @@ -18,7 +18,7 @@ - matrix-bridge-mautrix-whatsapp - matrix-bridge-mx-puppet-skype - matrix-bridge-mx-puppet-slack - - matrix-sms-bridge + - matrix-bridge-sms - matrix-synapse - matrix-riot-web - matrix-jitsi From d6c44879984dc9a69e1780a35cfff4508e36e7fb Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Fri, 5 Jun 2020 14:52:24 +0300 Subject: [PATCH 32/32] Fix some typos --- docs/configuring-playbook-matrix-bridge-sms.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/configuring-playbook-matrix-bridge-sms.md b/docs/configuring-playbook-matrix-bridge-sms.md index 2809fb03..c208bb81 100644 --- a/docs/configuring-playbook-matrix-bridge-sms.md +++ b/docs/configuring-playbook-matrix-bridge-sms.md @@ -1,7 +1,7 @@ -# Setting up matrix-bridge-sms (optional) +# Setting up matrix-sms-bridge (optional) The playbook can install and configure -[matrix-sms-brdige](https://github.com/benkuly/matrix-sms-bridge) for you. +[matrix-sms-bridge](https://github.com/benkuly/matrix-sms-bridge) for you. See the project page to learn what it does and why it might be useful to you.