From 91bffb059ae24a6e5d5fb4d06ac5ccf9819a8082 Mon Sep 17 00:00:00 2001
From: Gredin67 <35761345+Gredin67@users.noreply.github.com>
Date: Wed, 15 Apr 2020 19:53:26 +0200
Subject: [PATCH 01/34] Change go path and restart synapse with read
registration rights
This is the standard debian golang installation path
Restart synapse after rights to registration file given
---
scripts/install | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/scripts/install b/scripts/install
index 7e911e8..d2ae054 100755
--- a/scripts/install
+++ b/scripts/install
@@ -135,12 +135,12 @@ ynh_install_app_dependencies $pkg_dependencies
# INSTALL GO
#=================================================
-type /usr/local/go/bin/go > /dev/null || {
+type /usr/lib/go/bin/go > /dev/null || {
ynh_script_progression --message="Installing go..." --time --weight=1
wget https://dl.google.com/go/go$GO_VERSION.linux-$architecture.tar.gz -q
- tar -C /usr/local -xzf go$GO_VERSION.linux-$architecture.tar.gz
+ tar -C /usr/lib -xzf go$GO_VERSION.linux-$architecture.tar.gz
}
-export PATH=$PATH:/usr/local/go/bin
+export PATH=$PATH:/usr/lib/go/bin
#=================================================
# CREATE A POSTGRESQL DATABASE
@@ -332,10 +332,6 @@ fi
ynh_replace_string --match_string="#app_service_config_files:" --replace_string="app_service_config_files:" --target_file="/etc/matrix-synapse/homeserver.yaml"
ynh_replace_string --match_string="# - app_service_1.yaml" --replace_string=" - '/etc/matrix-synapse/$app-registration.yaml'" --target_file="/etc/matrix-synapse/homeserver.yaml"
#You will then need to restart the synapse server. Remember to restart it every time the registration file is regenerated.
-service matrix-synapse restart
-#Run the bridge with
-#service mautrix-whatsapp restart
-#./mautrix-whatsapp.
#=================================================
@@ -377,6 +373,11 @@ chown $mautrix_whatsapp_user:root -R $final_path
chown /etc/matrix-synapse/$app-registration.yaml --reference="/etc/matrix-synapse/homeserver.yaml"
chmod u=rwX,g=rX,o= /etc/matrix-synapse/$app-registration.yaml
+#You will then need to restart the synapse server. Remember to restart it every time the registration file is regenerated.
+service matrix-synapse restart
+#Run the bridge with
+#service mautrix-whatsapp restart
+#./mautrix-whatsapp.
#=================================================
# SETUP LOGROTATE
From 9b4924fd110592bf348684f92e3220b3a42f601a Mon Sep 17 00:00:00 2001
From: Gredin67 <35761345+Gredin67@users.noreply.github.com>
Date: Wed, 15 Apr 2020 22:23:35 +0200
Subject: [PATCH 02/34] Update _common.sh
---
scripts/_common.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/_common.sh b/scripts/_common.sh
index 4a4af3a..0f15a3d 100644
--- a/scripts/_common.sh
+++ b/scripts/_common.sh
@@ -6,7 +6,7 @@
# dependencies used by the app
pkg_dependencies=""
-GO_VERSION="1.14.2"
+GO_VERSION="1.11"
#=================================================
# PERSONAL HELPERS
From d60094777d051fe559cbfea21afb44a8f8f523bc Mon Sep 17 00:00:00 2001
From: Gredin67 <35761345+Gredin67@users.noreply.github.com>
Date: Wed, 15 Apr 2020 22:27:56 +0200
Subject: [PATCH 03/34] Update systemd.service
---
conf/systemd.service | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/conf/systemd.service b/conf/systemd.service
index 417e8c1..9e3f4d8 100644
--- a/conf/systemd.service
+++ b/conf/systemd.service
@@ -4,7 +4,7 @@ After=matrix-synapse.service
[Service]
Type=simple
-User=__APP__
+User=__WHATSAPPBOT__
WorkingDirectory=/opt/yunohost/__APP__
ExecStart=/opt/yunohost/__APP__/mautrix-whatsapp -c=/opt/yunohost/__APP__/config.yaml >> /var/log/__APP__/__APP__.log 2>&1
Restart=always
From 33a575dfe12784c8b7b66e5c9cca5684a5f48bb3 Mon Sep 17 00:00:00 2001
From: Gredin67 <35761345+Gredin67@users.noreply.github.com>
Date: Wed, 15 Apr 2020 22:47:55 +0200
Subject: [PATCH 04/34] golang-1.11
---
scripts/install | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/scripts/install b/scripts/install
index d2ae054..c84f3fc 100755
--- a/scripts/install
+++ b/scripts/install
@@ -135,12 +135,12 @@ ynh_install_app_dependencies $pkg_dependencies
# INSTALL GO
#=================================================
-type /usr/lib/go/bin/go > /dev/null || {
+type /usr/lib/golang-1.11/bin > /dev/null || {
ynh_script_progression --message="Installing go..." --time --weight=1
wget https://dl.google.com/go/go$GO_VERSION.linux-$architecture.tar.gz -q
tar -C /usr/lib -xzf go$GO_VERSION.linux-$architecture.tar.gz
}
-export PATH=$PATH:/usr/lib/go/bin
+export PATH=$PATH:/usr/lib/golang-1.11/bin
#=================================================
# CREATE A POSTGRESQL DATABASE
@@ -295,7 +295,7 @@ ynh_replace_string --match_string="@admin:example.com" --replace_string="$botadm
# Make app public if necessary
if [ $is_public -eq 1 ]
then
-ynh_replace_string --match_string="example.com" --replace_string="domain" --target_file="$final_path/config.yaml"
+ynh_replace_string --match_string="example.com" --replace_string="$domain" --target_file="$final_path/config.yaml"
else
ynh_replace_string --match_string="example.com" --replace_string="$botusers" --target_file="$final_path/config.yaml"
fi
From ccc498be47f080a093bc2a19dc9f1e0e222602d6 Mon Sep 17 00:00:00 2001
From: Gredin67 <35761345+Gredin67@users.noreply.github.com>
Date: Wed, 15 Apr 2020 23:29:47 +0200
Subject: [PATCH 05/34] Update install
---
scripts/install | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/install b/scripts/install
index c84f3fc..1592582 100755
--- a/scripts/install
+++ b/scripts/install
@@ -264,12 +264,12 @@ ynh_replace_string --match_string="uri: mautrix-whatsapp.db" --replace_string="u
# The unique ID of this appservice.
#id: whatsapp
- ynh_replace_string --match_string="id: whatsapp" --replace_string="id: $app" --target_file="$final_path/config.yaml"
+ ynh_replace_string --match_string="id: whatsapp" --replace_string="id: $whatsappbot" --target_file="$final_path/config.yaml"
# Appservice bot details.
#bot:
# Username of the appservice bot.
#username: whatsappbot
- ynh_replace_string --match_string="username: whatsappbot" --replace_string="username: $mautrix_whatsapp_user" --target_file="$final_path/config.yaml"
+ ynh_replace_string --match_string="username: whatsappbot" --replace_string="username: $whatsappbot" --target_file="$final_path/config.yaml"
# Maximum number of connections. Mostly relevant for Postgres.
From c4e0cf6edb05c2f55107acd150755bc0e6f381e2 Mon Sep 17 00:00:00 2001
From: Gredin67 <35761345+Gredin67@users.noreply.github.com>
Date: Wed, 15 Apr 2020 23:34:46 +0200
Subject: [PATCH 06/34] Update systemd.service
---
conf/systemd.service | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/conf/systemd.service b/conf/systemd.service
index 9e3f4d8..417e8c1 100644
--- a/conf/systemd.service
+++ b/conf/systemd.service
@@ -4,7 +4,7 @@ After=matrix-synapse.service
[Service]
Type=simple
-User=__WHATSAPPBOT__
+User=__APP__
WorkingDirectory=/opt/yunohost/__APP__
ExecStart=/opt/yunohost/__APP__/mautrix-whatsapp -c=/opt/yunohost/__APP__/config.yaml >> /var/log/__APP__/__APP__.log 2>&1
Restart=always
From 60ce2b7d8eecdc7d3c8848c81a33bab5a0f1d6fe Mon Sep 17 00:00:00 2001
From: Gredin67 <35761345+Gredin67@users.noreply.github.com>
Date: Wed, 15 Apr 2020 23:58:33 +0200
Subject: [PATCH 07/34] Update install
---
scripts/install | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/install b/scripts/install
index 1592582..cf67249 100755
--- a/scripts/install
+++ b/scripts/install
@@ -135,12 +135,12 @@ ynh_install_app_dependencies $pkg_dependencies
# INSTALL GO
#=================================================
-type /usr/lib/golang-1.11/bin > /dev/null || {
+type /usr/lib/go-1.11/bin > /dev/null || {
ynh_script_progression --message="Installing go..." --time --weight=1
wget https://dl.google.com/go/go$GO_VERSION.linux-$architecture.tar.gz -q
tar -C /usr/lib -xzf go$GO_VERSION.linux-$architecture.tar.gz
}
-export PATH=$PATH:/usr/lib/golang-1.11/bin
+export PATH=$PATH:/usr/lib/go-1.11/bin
#=================================================
# CREATE A POSTGRESQL DATABASE
From a8cc2a8e6ff503f96b4ea31238c3b7e8d40c1848 Mon Sep 17 00:00:00 2001
From: Gredin67 <35761345+Gredin67@users.noreply.github.com>
Date: Thu, 16 Apr 2020 00:01:46 +0200
Subject: [PATCH 08/34] Update install
---
scripts/install | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/install b/scripts/install
index cf67249..412a343 100755
--- a/scripts/install
+++ b/scripts/install
@@ -135,7 +135,7 @@ ynh_install_app_dependencies $pkg_dependencies
# INSTALL GO
#=================================================
-type /usr/lib/go-1.11/bin > /dev/null || {
+type /usr/lib/go-1.11/bin/go > /dev/null || {
ynh_script_progression --message="Installing go..." --time --weight=1
wget https://dl.google.com/go/go$GO_VERSION.linux-$architecture.tar.gz -q
tar -C /usr/lib -xzf go$GO_VERSION.linux-$architecture.tar.gz
From c15540c39bfacd24bca46a8e8f857214ac155273 Mon Sep 17 00:00:00 2001
From: Gredin67 <35761345+Gredin67@users.noreply.github.com>
Date: Thu, 16 Apr 2020 00:06:58 +0200
Subject: [PATCH 09/34] Update install
---
scripts/install | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/install b/scripts/install
index 412a343..a2fad9c 100755
--- a/scripts/install
+++ b/scripts/install
@@ -135,12 +135,12 @@ ynh_install_app_dependencies $pkg_dependencies
# INSTALL GO
#=================================================
-type /usr/lib/go-1.11/bin/go > /dev/null || {
+type /usr/lib/go-$GO_VERSION/bin/go > /dev/null || {
ynh_script_progression --message="Installing go..." --time --weight=1
wget https://dl.google.com/go/go$GO_VERSION.linux-$architecture.tar.gz -q
tar -C /usr/lib -xzf go$GO_VERSION.linux-$architecture.tar.gz
}
-export PATH=$PATH:/usr/lib/go-1.11/bin
+export PATH=$PATH:/usr/lib/go-$GO_VERSION/bin
#=================================================
# CREATE A POSTGRESQL DATABASE
From 2c332efdee354da38ceb25fea8c120965bff9d59 Mon Sep 17 00:00:00 2001
From: Gredin67 <35761345+Gredin67@users.noreply.github.com>
Date: Thu, 16 Apr 2020 01:46:47 +0200
Subject: [PATCH 10/34] Modified registration with $whatsappbot
---
scripts/install | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/scripts/install b/scripts/install
index a2fad9c..89bb779 100755
--- a/scripts/install
+++ b/scripts/install
@@ -264,14 +264,22 @@ ynh_replace_string --match_string="uri: mautrix-whatsapp.db" --replace_string="u
# The unique ID of this appservice.
#id: whatsapp
- ynh_replace_string --match_string="id: whatsapp" --replace_string="id: $whatsappbot" --target_file="$final_path/config.yaml"
+ #ynh_replace_string --match_string="id: whatsapp" --replace_string="id: $whatsappbot" --target_file="$final_path/config.yaml"
# Appservice bot details.
#bot:
# Username of the appservice bot.
#username: whatsappbot
ynh_replace_string --match_string="username: whatsappbot" --replace_string="username: $whatsappbot" --target_file="$final_path/config.yaml"
-
-
+# Bridge config
+#bridge:
+ # Localpart template of MXIDs for WhatsApp users.
+ # {{.}} is replaced with the phone number of the WhatsApp user.
+ #username_template: whatsapp_{{.}}
+ #ynh_replace_string --match_string="username_template: whatsapp" --replace_string="username_template: $whatsappbot" --target_file="$final_path/config.yaml"
+ # {{.Localpart}} is the MXID localpart and {{.Server}} is the MXID server part of the user.
+ #community_template: whatsapp_{{.Localpart}}={{.Server}}
+ #ynh_replace_string --match_string="community_template: whatsapp" --replace_string="community_template: $whatsappbot" --target_file="$final_path/config.yaml"
+
# Maximum number of connections. Mostly relevant for Postgres.
ynh_replace_string --match_string="max_open_conns: 20" --replace_string="max_open_conns: 20" --target_file="$final_path/config.yaml"
ynh_replace_string --match_string="max_idle_conns: 2" --replace_string="max_idle_conns: 2" --target_file="$final_path/config.yaml"
From 46e0485dba9d123f98a587682c79dc44806357ee Mon Sep 17 00:00:00 2001
From: Gredin67 <35761345+Gredin67@users.noreply.github.com>
Date: Thu, 16 Apr 2020 02:26:39 +0200
Subject: [PATCH 11/34] helper to install_extra golang-1.11
---
scripts/install | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/scripts/install b/scripts/install
index 89bb779..0f9ad30 100755
--- a/scripts/install
+++ b/scripts/install
@@ -8,7 +8,7 @@
source _common.sh
#source /opt/yunohost/mautrix-whatsapp/_ynh_install_extra_app_dependencies
-#source _ynh_install_extra_app_dependencies
+source _ynh_install_extra_app_dependencies
source /usr/share/yunohost/helpers
#=================================================
@@ -126,7 +126,7 @@ ynh_script_progression --message="Installing dependencies..." --time --weight=1
### - As well as the section "REINSTALL DEPENDENCIES" in the restore script
### - And the section "UPGRADE DEPENDENCIES" in the upgrade script
-#ynh_install_extra_app_dependencies --repo="http://http.debian.net/debian stretch-backports main" --package="golang-1.11"
+ynh_install_extra_app_dependencies --repo="http://http.debian.net/debian stretch-backports main" --package="golang-1.11"
#ynh_install_extra_app_dependencies --repo="http://http.debian.net/debian $(lsb_release -sc)" --package="golang-1.11"
ynh_install_app_dependencies $pkg_dependencies
@@ -135,11 +135,11 @@ ynh_install_app_dependencies $pkg_dependencies
# INSTALL GO
#=================================================
-type /usr/lib/go-$GO_VERSION/bin/go > /dev/null || {
- ynh_script_progression --message="Installing go..." --time --weight=1
- wget https://dl.google.com/go/go$GO_VERSION.linux-$architecture.tar.gz -q
- tar -C /usr/lib -xzf go$GO_VERSION.linux-$architecture.tar.gz
-}
+#type /usr/lib/go-$GO_VERSION/bin/go > /dev/null || {
+# ynh_script_progression --message="Installing go..." --time --weight=1
+# wget https://dl.google.com/go/go$GO_VERSION.linux-$architecture.tar.gz -q
+# tar -C /usr/lib -xzf go$GO_VERSION.linux-$architecture.tar.gz
+#}
export PATH=$PATH:/usr/lib/go-$GO_VERSION/bin
#=================================================
From 69c8e35117f1426d5659f2cabd65422f93b92b5e Mon Sep 17 00:00:00 2001
From: Gredin67 <35761345+Gredin67@users.noreply.github.com>
Date: Thu, 16 Apr 2020 02:46:40 +0200
Subject: [PATCH 12/34] appservice ID $whatsappbot and logging
---
scripts/install | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/scripts/install b/scripts/install
index 0f9ad30..cb87600 100755
--- a/scripts/install
+++ b/scripts/install
@@ -264,7 +264,7 @@ ynh_replace_string --match_string="uri: mautrix-whatsapp.db" --replace_string="u
# The unique ID of this appservice.
#id: whatsapp
- #ynh_replace_string --match_string="id: whatsapp" --replace_string="id: $whatsappbot" --target_file="$final_path/config.yaml"
+ ynh_replace_string --match_string="id: whatsapp" --replace_string="id: $whatsappbot" --target_file="$final_path/config.yaml"
# Appservice bot details.
#bot:
# Username of the appservice bot.
@@ -341,7 +341,23 @@ ynh_replace_string --match_string="#app_service_config_files:" --replace_string=
ynh_replace_string --match_string="# - app_service_1.yaml" --replace_string=" - '/etc/matrix-synapse/$app-registration.yaml'" --target_file="/etc/matrix-synapse/homeserver.yaml"
#You will then need to restart the synapse server. Remember to restart it every time the registration file is regenerated.
-
+# Logging config.
+#logging:
+ # The directory for log files. Will be created if not found.
+ #directory: ./logs
+ ynh_replace_string --match_string="directory: ./logs" --replace_string="/var/log/$app" --target_file="/etc/matrix-synapse/homeserver.yaml"
+ # Available variables: .Date for the file date and .Index for different log files on the same day.
+ #file_name_format: "{{.Date}}-{{.Index}}.log"
+ # Date format for file names in the Go time format: https://golang.org/pkg/time/#pkg-constants
+ #file_date_format: 2006-01-02
+ # Log file permissions.
+ #file_mode: 0600
+ # Timestamp format for log entries in the Go time format.
+ #timestamp_format: Jan _2, 2006 15:04:05
+ # Minimum severity for log messages.
+ # Options: debug, info, warn, error, fatal
+ #print_level: debug
+
#=================================================
# STORE THE CONFIG FILE CHECKSUM
#=================================================
@@ -372,7 +388,7 @@ ynh_store_file_checksum --file="/etc/matrix-synapse/homeserver.yaml"
chown $mautrix_whatsapp_user:root -R $final_path
#chmod 770 $final_path/Coturn_config_rotate.sh
#chown $mautrix_whatsapp_user:root -R /var/lib/$app
-#chown $mautrix_whatsapp_user:root -R /var/log/$app
+chown $mautrix_whatsapp_user:root -R /var/log/$app
#chown $mautrix_whatsapp_user:root -R /etc/$app
#chmod u=rwX,g=rX,o= -R /etc/$app
#chmod 600 /etc/matrix-$app/$server_name.signing.key
From 13ababdd24be78cd95f93aba431d0c66f0e3db7d Mon Sep 17 00:00:00 2001
From: Gredin67 <35761345+Gredin67@users.noreply.github.com>
Date: Thu, 16 Apr 2020 03:06:35 +0200
Subject: [PATCH 13/34] Update install
---
scripts/install | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/install b/scripts/install
index cb87600..ea7c729 100755
--- a/scripts/install
+++ b/scripts/install
@@ -388,7 +388,7 @@ ynh_store_file_checksum --file="/etc/matrix-synapse/homeserver.yaml"
chown $mautrix_whatsapp_user:root -R $final_path
#chmod 770 $final_path/Coturn_config_rotate.sh
#chown $mautrix_whatsapp_user:root -R /var/lib/$app
-chown $mautrix_whatsapp_user:root -R /var/log/$app
+#chown $mautrix_whatsapp_user:root -R /var/log/$app
#chown $mautrix_whatsapp_user:root -R /etc/$app
#chmod u=rwX,g=rX,o= -R /etc/$app
#chmod 600 /etc/matrix-$app/$server_name.signing.key
From accc5fdd43cad27d3523fab1ad1a2c1557c88f3c Mon Sep 17 00:00:00 2001
From: Gredin67 <35761345+Gredin67@users.noreply.github.com>
Date: Thu, 16 Apr 2020 09:11:32 +0200
Subject: [PATCH 14/34] added GO_PATH
---
scripts/_common.sh | 1 +
1 file changed, 1 insertion(+)
diff --git a/scripts/_common.sh b/scripts/_common.sh
index 0f15a3d..471f4f6 100644
--- a/scripts/_common.sh
+++ b/scripts/_common.sh
@@ -7,6 +7,7 @@
# dependencies used by the app
pkg_dependencies=""
GO_VERSION="1.11"
+GO_PATH="/usr/lib/go-$GO_VERSION/bin"
#=================================================
# PERSONAL HELPERS
From 98e8d3006f7151e4db42ae20d8ca50046b2d49f3 Mon Sep 17 00:00:00 2001
From: Gredin67 <35761345+Gredin67@users.noreply.github.com>
Date: Sun, 19 Apr 2020 19:16:28 +0200
Subject: [PATCH 15/34] Update remove
---
scripts/remove | 52 ++++++++++++++++++++++++++++++--------------------
1 file changed, 31 insertions(+), 21 deletions(-)
diff --git a/scripts/remove b/scripts/remove
index 3f147ca..9423376 100755
--- a/scripts/remove
+++ b/scripts/remove
@@ -16,12 +16,20 @@ ynh_script_progression --message="Loading installation settings..." --time --wei
app=$YNH_APP_INSTANCE_NAME
-domain=$(ynh_app_setting_get --app=$app --key=domain)
-port=$(ynh_app_setting_get --app=$app --key=port)
-db_name=$(ynh_app_setting_get --app=$app --key=db_name)
-db_user=$db_name
+#domain=$(ynh_app_setting_get --app=$app --key=domain)
+#port=$(ynh_app_setting_get --app=$app --key=port)
+#db_name=$(ynh_app_setting_get --app=$app --key=db_name)
+#db_user=$db_name
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
+#=================================================
+# SET CONSTANTS
+#=================================================
+
+mautrix_whatsapp_user=$app
+#mautrix_whatsapp_db_name=$app
+#mautrix_whatsapp_db_user=$app
+
#=================================================
# STANDARD REMOVE
#=================================================
@@ -46,10 +54,10 @@ ynh_remove_systemd_config
#=================================================
# REMOVE THE MYSQL DATABASE
#=================================================
-ynh_script_progression --message="Removing the MySQL database..." --time --weight=1
+ynh_script_progression --message="Removing the PostgreSQL database..." --time --weight=1
# Remove a database if it exists, along with the associated user
-ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
+#ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
ynh_psql_drop_db $app
ynh_psql_drop_user $app
@@ -70,22 +78,24 @@ ynh_script_progression --message="Removing app main directory..." --time --weigh
ynh_secure_remove --file="$final_path"
ynh_secure_remove --file="/etc/matrix-synapse/$app-registration.yaml"
+ynh_replace_string --match_string=" - '/etc/matrix-synapse/$app-registration.yaml'" --replace_string="# - app_service_1.yaml" --target_file="/etc/matrix-synapse/homeserver.yaml"
+service matrix-synapse restart
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
-ynh_script_progression --message="Removing nginx web server configuration..." --time --weight=1
+#ynh_script_progression --message="Removing nginx web server configuration..." --time --weight=1
# Remove the dedicated nginx config
-ynh_remove_nginx_config
+#ynh_remove_nginx_config
#=================================================
# REMOVE PHP-FPM CONFIGURATION
#=================================================
-ynh_script_progression --message="Removing php-fpm configuration..." --time --weight=1
+#ynh_script_progression --message="Removing php-fpm configuration..." --time --weight=1
# Remove the dedicated php-fpm config
-ynh_remove_fpm_config
+#ynh_remove_fpm_config
#=================================================
# REMOVE LOGROTATE CONFIGURATION
@@ -99,19 +109,19 @@ ynh_remove_logrotate
# CLOSE A PORT
#=================================================
-if yunohost firewall list | grep -q "\- $port$"
-then
- ynh_script_progression --message="Closing port $port..."
- ynh_exec_warn_less yunohost firewall disallow TCP $port
-fi
+#if yunohost firewall list | grep -q "\- $port$"
+#then
+# ynh_script_progression --message="Closing port $port..."
+# ynh_exec_warn_less yunohost firewall disallow TCP $port
+#fi
#=================================================
# REMOVE FAIL2BAN CONFIGURATION
#=================================================
-ynh_script_progression --message="Removing fail2ban configuration..." --time --weight=1
+#ynh_script_progression --message="Removing fail2ban configuration..." --time --weight=1
# Remove the dedicated fail2ban config
-ynh_remove_fail2ban_config
+#ynh_remove_fail2ban_config
#=================================================
# SPECIFIC REMOVE
@@ -120,13 +130,13 @@ ynh_remove_fail2ban_config
#=================================================
# Remove a cron file
-ynh_secure_remove --file="/etc/cron.d/$app"
+#ynh_secure_remove --file="/etc/cron.d/$app"
# Remove a directory securely
-ynh_secure_remove --file="/etc/$app/"
+#ynh_secure_remove --file="/etc/$app/"
# Remove the log files
-ynh_secure_remove --file="/var/log/$app/"
+#ynh_secure_remove --file="/var/log/$app/"
#=================================================
# GENERIC FINALIZATION
@@ -136,7 +146,7 @@ ynh_secure_remove --file="/var/log/$app/"
ynh_script_progression --message="Removing the dedicated system user..." --time --weight=1
# Delete a system user
-ynh_system_user_delete --username=$app
+ynh_system_user_delete --username=$mautrix_whatsapp_user
#=================================================
# END OF SCRIPT
From cbd3e2c93326bed7a299a969eb0d961dd63dbaee Mon Sep 17 00:00:00 2001
From: Gredin67 <35761345+Gredin67@users.noreply.github.com>
Date: Sun, 19 Apr 2020 21:36:33 +0200
Subject: [PATCH 16/34] Update developers info
---
README.md | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/README.md b/README.md
index 2149d38..bf2c602 100644
--- a/README.md
+++ b/README.md
@@ -67,12 +67,8 @@ https://github.com/tulir/mautrix-whatsapp/wiki
Developers info
----------------
-**Only if you want to use a testing branch for coding, instead of merging directly into master.**
-Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/REPLACEBYYOURAPP_ynh/tree/testing).
-
-To try the testing branch, please proceed like that.
+To test communication between the app service and synapse on a VM, you must install a certificate:
```
-sudo yunohost app install https://github.com/YunoHost-Apps/REPLACEBYYOURAPP_ynh/tree/testing --debug
-or
-sudo yunohost app upgrade REPLACEBYYOURAPP -u https://github.com/YunoHost-Apps/REPLACEBYYOURAPP_ynh/tree/testing --debug
+echo | openssl s_client -showcerts -servername synapse.vm -connect synapse.vm:443 2>/dev/null | awk '/-----BEGIN CERTIFICATE-----/, /-----END CERTIFICATE-----/' >> /usr/local/share/ca-certificates/synapse.vm.crt
+update-ca-certificates
```
From 215bd8e98f4b21cbc114afb65e2572c6816580a7 Mon Sep 17 00:00:00 2001
From: Gredin67 <35761345+Gredin67@users.noreply.github.com>
Date: Tue, 21 Apr 2020 12:02:17 +0200
Subject: [PATCH 17/34] Improved manifest questions
---
manifest.json | 41 +++++++++++++++++++++++++++--------------
1 file changed, 27 insertions(+), 14 deletions(-)
diff --git a/manifest.json b/manifest.json
index 1e76581..43b42cd 100644
--- a/manifest.json
+++ b/manifest.json
@@ -27,8 +27,8 @@
"name": "domain",
"type": "domain",
"ask": {
- "en": "Choose the domain name where Synapse is installed.",
- "fr": "Choisissez le nom de domaine associé à Synapse."
+ "en": "Choose the domain name where the local Matrix/Synapse instance is installed.",
+ "fr": "Choisissez le nom de domaine associé à l'instance locale Matrix/Synapse."
},
"example": "domain.org"
},
@@ -36,42 +36,55 @@
"name": "whatsappbot",
"type": "string",
"ask": {
- "en": "Choose the user name of the whatsapp bot for which to create a YunoHost and a local synapse server account.",
- "fr": "Choisissez le nom d'utilisateur du robot whatsapp pour lequel un compte sera créé sur YunoHost et le serveur local synapse."
+ "en": "Choose the local Matrix/Synapse user name of the WhatsApp bot.",
+ "fr": "Choisissez le nom d'utilisateur local Matrix/Synapse du robot WhatsApp."
},
"example": "whatsappbot",
+ "help": {
+ "en": "Invite @whatsappbot:domain.org from an authorize Matrix account to setup the bridge.",
+ "fr": "Inviter @whatsappbot:domain.org depuis votre compte Matrix principal pour démarrer la passerelle."
+ }
"default": "whatsappbot"
},
{
"name": "botadmin",
"type": "string",
"ask": {
- "en": "Choose the matrix account administrator of the whatsapp bot.",
- "fr": "Choisissez le compte matrix administrateur du robot whatsapp."
+ "en": "Choose the Matrix account administrator of the WhatsApp bot.",
+ "fr": "Choisissez le compte Matrix administrateur du robot WhatsApp."
},
"example": "@johndoe:domain.org or @johndoe:matrix.org",
- "default": "Your main matrix account"
+ "help": {
+ "en": "The WhatsApp bot administrator does not need to be a local Matrix/Synapse account.",
+ "fr": "Le compte administrateur du robot WhatsApp peut ne pas etre un compte Matrix/Synapse local."
+ }
+ "default": "Your main Matrix account"
},
{
"name": "botusers",
"type": "string",
"ask": {
- "en": "Choose a matrix server authorized to use the whatsapp bot.",
- "fr": "Choisissez un serveur matrix dont tous les utilisateurs sont autorisés à utiliser le robot whatsapp."
+ "en": "Choose Matrix user(s) authorized to use the WhatsApp bot.",
+ "fr": "Choisissez le/les compte(s) Matrix autorisés à utiliser le robot WhatsApp."
},
- "example": "matrix.org"
+ "example": "@johndoe:domain.org or matrix.org or *"
+ "default": ""
+ "help": {
+ "en": "Either the administrator only (), a Matrix user (@johndoe:domain.org), a server (matrix.org) or all servers (*) can be authorized.",
+ "fr": "On peut autoriser le compte administrateur seul (), un compte (@johndoe:domain.org), un serveur (matrix.org) ou tous les serveurs Matrix (*)."
+ }
},
{
"name": "is_public",
"type": "boolean",
"ask": {
- "en": "Is it a public bot?",
- "fr": "Est-ce un robot public ?"
+ "en": "Allow usage of the WhatsApp to all local Matrix/Synapse users?",
+ "fr": "Autoriser l'usage du robot WhatsApp à tous les utilisateurs locaux Matrix/Synapse ?"
},
"default": true,
"help": {
- "en": "A public bot means anyone with a matrix account on the synapse server will be able to use the bot.",
- "fr": "Un robot public signifie que chaque compte matrix du serveur synapse pourra utiliser le robot."
+ "en": "A public bot means anyone with a matrix account on the local Matrix/Synapse server will be able to use the bot.",
+ "fr": "Un robot public signifie que chaque compte matrix du serveur local Matrix/Synapse pourra utiliser le robot."
}
}
]
From e57bb79f0195b6bfa376f3eb4cbcc8cf4d0aaad1 Mon Sep 17 00:00:00 2001
From: Gredin67 <35761345+Gredin67@users.noreply.github.com>
Date: Tue, 21 Apr 2020 22:25:16 +0200
Subject: [PATCH 18/34] missing coma
---
manifest.json | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/manifest.json b/manifest.json
index 43b42cd..8c3053d 100644
--- a/manifest.json
+++ b/manifest.json
@@ -43,7 +43,7 @@
"help": {
"en": "Invite @whatsappbot:domain.org from an authorize Matrix account to setup the bridge.",
"fr": "Inviter @whatsappbot:domain.org depuis votre compte Matrix principal pour démarrer la passerelle."
- }
+ },
"default": "whatsappbot"
},
{
@@ -57,7 +57,7 @@
"help": {
"en": "The WhatsApp bot administrator does not need to be a local Matrix/Synapse account.",
"fr": "Le compte administrateur du robot WhatsApp peut ne pas etre un compte Matrix/Synapse local."
- }
+ },
"default": "Your main Matrix account"
},
{
@@ -67,8 +67,8 @@
"en": "Choose Matrix user(s) authorized to use the WhatsApp bot.",
"fr": "Choisissez le/les compte(s) Matrix autorisés à utiliser le robot WhatsApp."
},
- "example": "@johndoe:domain.org or matrix.org or *"
- "default": ""
+ "example": "@johndoe:domain.org or matrix.org or *",
+ "default": "",
"help": {
"en": "Either the administrator only (), a Matrix user (@johndoe:domain.org), a server (matrix.org) or all servers (*) can be authorized.",
"fr": "On peut autoriser le compte administrateur seul (), un compte (@johndoe:domain.org), un serveur (matrix.org) ou tous les serveurs Matrix (*)."
From 8449f38f81361d0b8c4a1f223c79fcc0a56d8c1e Mon Sep 17 00:00:00 2001
From: Gredin67 <35761345+Gredin67@users.noreply.github.com>
Date: Tue, 21 Apr 2020 23:59:45 +0200
Subject: [PATCH 19/34] Update README.md
---
README.md | 56 +++++++++++++++++++++++++++++++++++++++++++------------
1 file changed, 44 insertions(+), 12 deletions(-)
diff --git a/README.md b/README.md
index bf2c602..40f4fb6 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@
*[Lire ce readme en français.](./README_fr.md)*
-> *This package allows you to install Mautrix-WhatsApp quickly and simply on a YunoHost server.
+> *This package allows you to install a Mautrix-WhatsApp bridge quickly and simply on a YunoHost server alongside Matrix-Synapse.
If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.*
## Overview
@@ -20,37 +20,67 @@ A puppeting bridge between Matrix and WhatsApp packaged as a YunoHost service. M
## Demo
-* [Official demo](Link to a demo site for this app)
+* If you want to test the bridge, send an email to the App maintainer with the matrix user account you want to bridge to WhatsApp.
-## Configuration
+## Bridging usage
+### Bridge a WhatsApp user and a Matrix user
+* First your matrix user or server has to be authorized in the bridge configuration (see below)
+* Then, invite the bot (default @whatsappbot:yoursynapse.domain) in this new matrix-whatsapp bot administration room.
+* Type ``login``
+* Capture the QR code with the camera in the whatsapp of your VM or smartphone (WhatsApp Web)
+* Send ``help`` to the bot in the created room to know how to control the bot.
+See also [upstream wiki Authentication page](https://github.com/tulir/mautrix-whatsapp/wiki/Authentication)
-How to configure this app: by an admin panel, a plain file with SSH, or any other way.
+** Note that several WhatsApp and Matrix users can be bridge, each users has its own bot administration room. If they are in a same WhatsApp group, only one matrix room will be created. **
+
+### Bridge a WhatsApp group in Matrix "Relaybot"
+* First Relaybot option should be enabled in the bridge configuration (default=disabled, see below)
+* Once the bot administration room is setup, you can also bridge all messages between a Matrix room and a WhatsApp room/group.
+In whatsapp all messages will be sent by the account who is logged in with a prefix for the source matrix user. On the matrix side the bridge will still create matrix users corresponding to the whatsapp users when they send a message.
+See also [upstream wiki Relaybot page](https://github.com/tulir/mautrix-whatsapp/wiki/Relaybot)
+
+## Configuration of the bridge
+
+The bridge is roughly configured at installation, e.g. allowed admin and user of the bot. Finer configuration can be done by modifying the
+following configuration file with SSH:
+```/opt/yunohost/mautrix_whatsapp/config.yaml```
+and then restarting the mautrix_whatsapp service.
## Documentation
- * Official documentation: https://github.com/tulir/mautrix-whatsapp/wiki
+ * Official "mautrix-whatsapp" documentation: https://github.com/tulir/mautrix-whatsapp/wiki
+ * Matrix room: #whatsapp:maunium.net
+In case you need to upload your logs somewhere, be aware that they contain your contacts' and your phone numbers. Strip them out with
+``| sed -r 's/[0-9]{10,}/📞/g' ``
+ * "mautrix-whatsapp" bridge is based on the [Rhymen/go-whatsapp](https://github.com/Rhymen/go-whatsapp) implementation of the [sigalor/whatsapp-web-reveng](https://github.com/sigalor/whatsapp-web-reveng) project.
* YunoHost documentation: If specific documentation is needed, feel free to contribute.
## YunoHost specific features
#### Multi-users support
-Are LDAP and HTTP auth supported?
-Can the app be used by multiple users?
+* Bot users are not related to Yunohost users. Any matrix account or server autorized in the configuration of the bridge can use the bot.
+* The whatsapp bot is a local matrix-synapse user, but accessible through federation (synapse public or private).
+* Several WhatsApp and Matrix users can be bridged with one bridge, each user has its own bot administration room.
+* If several bot users are in a same WhatsApp group, only one matrix room will be created by the bridge.
+
+Multi-instance installation should work, but was not tested yet. A priori it makes only sense if several synapse instances are installed.
#### Supported architectures
-* x86-64b - [](https://ci-apps.yunohost.org/ci/apps/REPLACEBYYOURAPP/)
-* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/REPLACEBYYOURAPP/)
-* Jessie x86-64b - [](https://ci-stretch.nohost.me/ci/apps/REPLACEBYYOURAPP/)
+* Tested on ARMv7 in April 2020
+* x86-64b - [](https://ci-apps.yunohost.org/ci/apps/mautrix-whatsapp_ynh/)
+* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/mautrix-whatsapp_ynh/)
+* Jessie x86-64b - [](https://ci-stretch.nohost.me/ci/apps/mautrix-whatsapp_ynh/)
## Limitations
-* Audio/Video calls are not bridged yet. It is recommended to install whatsapp on a virtual android running on a server. If whatsapp loses connection, e.g. the phone is set in flight mode, the bot has to be restarted by sending a reconnnect message in the matrix administration room.
+* Audio/Video calls are not bridged yet.
+* If whatsapp loses connection, e.g. the phone is set in flight mode or push notifications are deactivated, the bot has sometimes to be restarted manually by sending a reconnnect message in the matrix administration room.
## Additional information
-* Other information you would add about this application
+* It is recommended to install whatsapp on a virtual android running on a server, see [upstream wiki Android-VM-Setup page](https://github.com/tulir/mautrix-whatsapp/wiki/Android-VM-Setup)
**More information on the documentation page:**
https://github.com/tulir/mautrix-whatsapp/wiki
@@ -60,6 +90,8 @@ https://github.com/tulir/mautrix-whatsapp/wiki
* Report a bug: https://github.com/YunoHost-Apps/mautrix-whatsapp_ynh/issues
* App website: https://github.com/Gredin67/mautrix-whatsapp_ynh
* Upstream app repository: https://github.com/tulir/mautrix-whatsapp
+ * Up-Upstream repository: https://github.com/Rhymen/go-whatsapp
+ * Up-Up-Upstream repository: https://github.com/sigalor/whatsapp-web-reveng
* YunoHost website: https://yunohost.org/
---
From 226011f8528a3a5ba410fda62cfdf352e43fdffc Mon Sep 17 00:00:00 2001
From: Gredin67 <35761345+Gredin67@users.noreply.github.com>
Date: Fri, 24 Apr 2020 16:35:11 +0200
Subject: [PATCH 20/34] Pre-install synapse for check_process
---
check_process.default | 35 ++++++++++++++++++++++-------------
1 file changed, 22 insertions(+), 13 deletions(-)
diff --git a/check_process.default b/check_process.default
index 97a2bc5..bda783c 100644
--- a/check_process.default
+++ b/check_process.default
@@ -4,37 +4,46 @@
# Move this file from check_process.default to check_process when you have filled it.
;; Test complet
+ auto_remove=1
; Manifest
domain="domain.tld" (DOMAIN)
- path="/path" (PATH)
- admin="john" (USER)
- language="fr"
+ #path="/_matrix/static/" (PATH)
+ #admin="john" (USER)
+ #language="en"
is_public=1 (PUBLIC|public=1|private=0)
- password="pass"
- port="666" (PORT)
+ #password="pass"
+ #port="666" (PORT)
+
+ whatsappbot="whatsappbot"
+ botadmin="@johndoe:domain.tld"
+ botusers="@johndoe:domain.tld"
+ ; pre-install
+ sudo yunohost app fetchlist
+ #sudo yunohost domain add baikaldomain.tld --admin-password $PASSWORD
+ sudo yunohost app install synapse -a "domain=domain.tld&server_name="Same than the domain"&is_public=1"
; Checks
pkg_linter=1
setup_sub_dir=1
setup_root=1
setup_nourl=0
- setup_private=1
+ setup_private=0
setup_public=1
- upgrade=1
- upgrade=1 from_commit=CommitHash
- backup_restore=1
+ upgrade=0
+ #upgrade=1 from_commit=CommitHash
+ backup_restore=0
multi_instance=1
# This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version.
# incorrect_path=1
port_already_use=0
- change_url=1
+ change_url=0
;;; Levels
# If the level 5 (Package linter) is forced to 1. Please add justifications here.
Level 5=auto
;;; Options
-Email=
+#Email=
Notification=none
;;; Upgrade options
; commit=CommitHash
- name=Name and date of the commit.
- manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666&
+ #name=Name and date of the commit.
+ #manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666&
From 8c1821c2a8a4b0edcb4bb10440e0d6cdd56caf6d Mon Sep 17 00:00:00 2001
From: Gredin67 <35761345+Gredin67@users.noreply.github.com>
Date: Sat, 25 Apr 2020 16:48:16 +0200
Subject: [PATCH 21/34] Testing (#1)
* standard app service registration
* Logging with static file name
* Update logging
* Rename check_process.default to check_process
* systemd change log name
* Update install logging
* install logging
* Update install
* Update install
* log not handled by systemd
* logging handled by synapse app service
* Update install
* Update install
* remove message fail2ban
* add log
* Update install
* remove linematch
---
check_process.default => check_process | 0
conf/systemd.service | 2 +-
scripts/install | 56 ++++++++++++++------------
3 files changed, 32 insertions(+), 26 deletions(-)
rename check_process.default => check_process (100%)
diff --git a/check_process.default b/check_process
similarity index 100%
rename from check_process.default
rename to check_process
diff --git a/conf/systemd.service b/conf/systemd.service
index 417e8c1..30624b1 100644
--- a/conf/systemd.service
+++ b/conf/systemd.service
@@ -6,7 +6,7 @@ After=matrix-synapse.service
Type=simple
User=__APP__
WorkingDirectory=/opt/yunohost/__APP__
-ExecStart=/opt/yunohost/__APP__/mautrix-whatsapp -c=/opt/yunohost/__APP__/config.yaml >> /var/log/__APP__/__APP__.log 2>&1
+ExecStart=/opt/yunohost/__APP__/mautrix-whatsapp -c=/opt/yunohost/__APP__/config.yaml >> /var/log/__APP__/log.log 2>&1
Restart=always
RestartSec=3
diff --git a/scripts/install b/scripts/install
index ea7c729..f080468 100755
--- a/scripts/install
+++ b/scripts/install
@@ -247,11 +247,11 @@ ynh_replace_string --match_string="domain: example.com" --replace_string="domain
# Changing these values requires regeneration of the registration.
#appservice:
# The address that the homeserver can use to connect to this appservice.
-ynh_replace_string --match_string="address: http://localhost:29318" --replace_string="address: http://0.0.0.0:8449" --target_file="$final_path/config.yaml"
+#ynh_replace_string --match_string="address: http://localhost:29318" --replace_string="address: http://localhost:8449" --target_file="$final_path/config.yaml"
# The hostname and port where this appservice should listen.
#ynh_replace_string --match_string="hostname: 0.0.0.0" --replace_string="hostname: 0.0.0.0" --target_file="$final_path/config.yaml"
-ynh_replace_string --match_string="port: 29318" --replace_string="port: 8449" --target_file="$final_path/config.yaml"
+#ynh_replace_string --match_string="port: 29318" --replace_string="port: 8449" --target_file="$final_path/config.yaml"
# Database config.
#database:
@@ -281,8 +281,8 @@ ynh_replace_string --match_string="uri: mautrix-whatsapp.db" --replace_string="u
#ynh_replace_string --match_string="community_template: whatsapp" --replace_string="community_template: $whatsappbot" --target_file="$final_path/config.yaml"
# Maximum number of connections. Mostly relevant for Postgres.
-ynh_replace_string --match_string="max_open_conns: 20" --replace_string="max_open_conns: 20" --target_file="$final_path/config.yaml"
-ynh_replace_string --match_string="max_idle_conns: 2" --replace_string="max_idle_conns: 2" --target_file="$final_path/config.yaml"
+#ynh_replace_string --match_string="max_open_conns: 20" --replace_string="max_open_conns: 20" --target_file="$final_path/config.yaml"
+#ynh_replace_string --match_string="max_idle_conns: 2" --replace_string="max_idle_conns: 2" --target_file="$final_path/config.yaml"
#You will also need to add your user of admin user under the permissions section.
# Permissions for using the bridge.
@@ -328,6 +328,27 @@ fi
# m.video: "{{ .Sender.Displayname }} sent a video"
# m.location: "{{ .Sender.Displayname }} sent a location"
+# Logging config.
+#logging:
+ # The directory for log files. Will be created if not found.
+ #directory: ./logs
+ ynh_replace_string --match_string="directory: ./logs" --replace_string="directory: /var/log/$app" --target_file="$final_path/config.yaml"
+ # Available variables: .Date for the file date and .Index for different log files on the same day.
+ #file_name_format: "{{.Date}}-{{.Index}}.log"
+ ynh_replace_string --match_string="{{.Date}}-{{.Index}}.log" --replace_string="log.log" --target_file="$final_path/config.yaml"
+ # Date format for file names in the Go time format: https://golang.org/pkg/time/#pkg-constants
+ #file_date_format: 2006-01-02
+ ynh_replace_string --match_string="file_date_format: 2006-01-02" --replace_string="#file_date_format: 2006-01-02" --target_file="$final_path/config.yaml"
+ # Log file permissions.
+ #file_mode: 0600
+ #ynh_replace_string --match_string="file_mode: 0600" --replace_string="file_mode: 384" --target_file="$final_path/config.yaml"
+ # Timestamp format for log entries in the Go time format.
+ #timestamp_format: Jan _2, 2006 15:04:05
+ # Minimum severity for log messages.
+ # Options: debug, info, warn, error, fatal
+ #print_level: debug
+ ynh_replace_string --match_string="print_level: debug" --replace_string="print_level: warn" --target_file="$final_path/config.yaml"
+
#Generate the appservice registration file by running ./mautrix-whatsapp -g.
#You can use the -c and -r flags to change the location of the config and registration files. They default to config.yaml and registration.yaml respectively.
./mautrix-whatsapp -g -r /etc/matrix-synapse/$app-registration.yaml
@@ -341,23 +362,7 @@ ynh_replace_string --match_string="#app_service_config_files:" --replace_string=
ynh_replace_string --match_string="# - app_service_1.yaml" --replace_string=" - '/etc/matrix-synapse/$app-registration.yaml'" --target_file="/etc/matrix-synapse/homeserver.yaml"
#You will then need to restart the synapse server. Remember to restart it every time the registration file is regenerated.
-# Logging config.
-#logging:
- # The directory for log files. Will be created if not found.
- #directory: ./logs
- ynh_replace_string --match_string="directory: ./logs" --replace_string="/var/log/$app" --target_file="/etc/matrix-synapse/homeserver.yaml"
- # Available variables: .Date for the file date and .Index for different log files on the same day.
- #file_name_format: "{{.Date}}-{{.Index}}.log"
- # Date format for file names in the Go time format: https://golang.org/pkg/time/#pkg-constants
- #file_date_format: 2006-01-02
- # Log file permissions.
- #file_mode: 0600
- # Timestamp format for log entries in the Go time format.
- #timestamp_format: Jan _2, 2006 15:04:05
- # Minimum severity for log messages.
- # Options: debug, info, warn, error, fatal
- #print_level: debug
-
+
#=================================================
# STORE THE CONFIG FILE CHECKSUM
#=================================================
@@ -417,7 +422,8 @@ ynh_script_progression --message="Configuring log rotation..." --time --weight=1
### - And the section "SETUP LOGROTATE" in the upgrade script
# Use logrotate to manage application logfile(s)
-ynh_use_logrotate --logfile "/var/log/$app"
+ynh_use_logrotate --logfile "/var/log/$app/log.log"
+chown $mautrix_whatsapp_user:root -R /var/log/$app
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
@@ -431,7 +437,7 @@ ynh_use_logrotate --logfile "/var/log/$app"
### - Remove the section "REMOVE SERVICE FROM ADMIN PANEL" in the remove script
### - As well as the section "ADVERTISE SERVICE IN ADMIN PANEL" in the restore script
-yunohost service add $app --log "/var/log/$app/$app.log"
+yunohost service add $app --log "/var/log/$app/log.log"
# if using yunohost version 3.2 or more in the 'manifest.json', a description can be added
#yunohost service add $app --description "$app daemon for XXX" --log "/var/log/$app/$app.log"
@@ -449,12 +455,12 @@ ynh_script_progression --message="Starting a systemd service..." --time --weight
### - And the section "STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the change_url script
# Start a systemd service
-ynh_systemd_action --service_name=$app --action="start" --line_match="Bot now ready to bridge Whatsapp and Matrix users from $botusers" --log_path="/var/log/$app/$app.log" --timeout=300
+ynh_systemd_action --service_name=$app --action="start"
#=================================================
# SETUP FAIL2BAN
#=================================================
-ynh_script_progression --message="Configuring fail2ban..." --time --weight=1
+#ynh_script_progression --message="Configuring fail2ban..." --time --weight=1
# Create a dedicated fail2ban config
#ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login"
From bc011d62443498a10e5c126dcecdaa9895eb90f4 Mon Sep 17 00:00:00 2001
From: Gredin67 <35761345+Gredin67@users.noreply.github.com>
Date: Sun, 26 Apr 2020 01:44:37 +0200
Subject: [PATCH 22/34] Testing (#2)
* standard app service registration
* Logging with static file name
* Update logging
* Rename check_process.default to check_process
* systemd change log name
* Update install logging
* log not handled by systemd
* logging handled by synapse app service
* remove message fail2ban
* add log
* remove linematch
* get synapse domain and server_name
* ynh_app_setting_get
* app port arg & instance_number
* domain not needed and port added
---
manifest.json | 33 ++++++++++++++++++++++-----------
scripts/install | 21 +++++++++++++++++----
2 files changed, 39 insertions(+), 15 deletions(-)
diff --git a/manifest.json b/manifest.json
index 8c3053d..1b9bd5d 100644
--- a/manifest.json
+++ b/manifest.json
@@ -24,20 +24,31 @@
"arguments": {
"install": [
{
- "name": "domain",
- "type": "domain",
+ "name": "port",
+ "type": "string",
"ask": {
- "en": "Choose the domain name where the local Matrix/Synapse instance is installed.",
- "fr": "Choisissez le nom de domaine associé à l'instance locale Matrix/Synapse."
+ "en": "Choose a port for communication between app service and home server",
+ "fr": "Choisissez un port pour la communication entre l'app service et le home server"
},
- "example": "domain.org"
+ "example": "29318",
+ "default": "8449"
+ },
+ {
+ "name": "synapsenumber",
+ "type": "string",
+ "ask": {
+ "en": "Choose the synapse instance number to communicate with app service",
+ "fr": "Choisissez le numéro de l'instance synapse qui doit communiquer avec l'app service"
+ },
+ "example": "2",
+ "default": "1"
},
{
"name": "whatsappbot",
"type": "string",
"ask": {
- "en": "Choose the local Matrix/Synapse user name of the WhatsApp bot.",
- "fr": "Choisissez le nom d'utilisateur local Matrix/Synapse du robot WhatsApp."
+ "en": "Choose the local Matrix/Synapse user name of the WhatsApp bot",
+ "fr": "Choisissez le nom d'utilisateur local Matrix/Synapse du robot WhatsApp"
},
"example": "whatsappbot",
"help": {
@@ -50,8 +61,8 @@
"name": "botadmin",
"type": "string",
"ask": {
- "en": "Choose the Matrix account administrator of the WhatsApp bot.",
- "fr": "Choisissez le compte Matrix administrateur du robot WhatsApp."
+ "en": "Choose the Matrix account administrator of the WhatsApp bot",
+ "fr": "Choisissez le compte Matrix administrateur du robot WhatsApp"
},
"example": "@johndoe:domain.org or @johndoe:matrix.org",
"help": {
@@ -64,8 +75,8 @@
"name": "botusers",
"type": "string",
"ask": {
- "en": "Choose Matrix user(s) authorized to use the WhatsApp bot.",
- "fr": "Choisissez le/les compte(s) Matrix autorisés à utiliser le robot WhatsApp."
+ "en": "Choose Matrix user(s) authorized to use the WhatsApp bot",
+ "fr": "Choisissez le/les compte(s) Matrix autorisés à utiliser le robot WhatsApp"
},
"example": "@johndoe:domain.org or matrix.org or *",
"default": "",
diff --git a/scripts/install b/scripts/install
index f080468..4852a87 100755
--- a/scripts/install
+++ b/scripts/install
@@ -26,8 +26,9 @@ ynh_abort_if_errors
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
-domain=$YNH_APP_ARG_DOMAIN
+#domain=$YNH_APP_ARG_DOMAIN
#path_url=$YNH_APP_ARG_PATH
+port=$YNH_APP_ARG_PORT
whatsappbot=$YNH_APP_ARG_WHATSAPPBOT
botadmin=$YNH_APP_ARG_BOTADMIN
botusers=$YNH_APP_ARG_BOTUSERS
@@ -47,6 +48,16 @@ is_public=$YNH_APP_ARG_IS_PUBLIC
### db names, ...
app=$YNH_APP_INSTANCE_NAME
+if [ $YNH_APP_INSTANCE_NUMBER -eq "1" ]
+then
+server_name=$(ynh_app_setting_get --app synapse --key server_name)
+domain=$(ynh_app_setting_get --app synapse --key domain)
+else
+server_name=$(ynh_app_setting_get --app synapse__$YNH_APP_INSTANCE_NUMBER --key server_name)
+domain=$(ynh_app_setting_get --app synapse__$YNH_APP_INSTANCE_NUMBER --key domain)
+fi
+
+
#=================================================
# SET CONSTANTS
#=================================================
@@ -86,6 +97,8 @@ test ! -e "$final_path" || ynh_die --message="This path already contains a folde
ynh_script_progression --message="Storing installation settings..." --time --weight=1
ynh_app_setting_set --app=$app --key=domain --value=$domain
+ynh_app_setting_set --app=$app --key=server_name --value=$server_name
+ynh_app_setting_set --app=$app --key=port --value=$port
#ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set --app=$app --key=whatsappbot --value=$whatsappbot
ynh_app_setting_set --app=$app --key=botadmin --value=$botadmin
@@ -241,17 +254,17 @@ cp example-config.yaml config.yaml
ynh_replace_string --match_string="address: https://example.com" --replace_string="address: https://$domain" --target_file="$final_path/config.yaml"
# The domain of the homeserver (for MXIDs, etc).
#"domain: example.com"
-ynh_replace_string --match_string="domain: example.com" --replace_string="domain: $domain" --target_file="$final_path/config.yaml"
+ynh_replace_string --match_string="domain: example.com" --replace_string="domain: $server_name" --target_file="$final_path/config.yaml"
# Application service host/registration related details.
# Changing these values requires regeneration of the registration.
#appservice:
# The address that the homeserver can use to connect to this appservice.
-#ynh_replace_string --match_string="address: http://localhost:29318" --replace_string="address: http://localhost:8449" --target_file="$final_path/config.yaml"
+ynh_replace_string --match_string="address: http://localhost:29318" --replace_string="address: http://localhost:$port" --target_file="$final_path/config.yaml"
# The hostname and port where this appservice should listen.
#ynh_replace_string --match_string="hostname: 0.0.0.0" --replace_string="hostname: 0.0.0.0" --target_file="$final_path/config.yaml"
-#ynh_replace_string --match_string="port: 29318" --replace_string="port: 8449" --target_file="$final_path/config.yaml"
+ynh_replace_string --match_string="port: 29318" --replace_string="port: $port" --target_file="$final_path/config.yaml"
# Database config.
#database:
From b6187f9d3f9286f7f93c0d53e14c95a3bd6ddd30 Mon Sep 17 00:00:00 2001
From: Gredin67 <35761345+Gredin67@users.noreply.github.com>
Date: Sun, 26 Apr 2020 13:04:10 +0200
Subject: [PATCH 23/34] use arg synapsenumber from manifest
---
scripts/install | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/scripts/install b/scripts/install
index 4852a87..aeafff4 100755
--- a/scripts/install
+++ b/scripts/install
@@ -29,6 +29,7 @@ ynh_abort_if_errors
#domain=$YNH_APP_ARG_DOMAIN
#path_url=$YNH_APP_ARG_PATH
port=$YNH_APP_ARG_PORT
+synapsenumber=$YNH_APP_ARG_SYNAPSENUMBER
whatsappbot=$YNH_APP_ARG_WHATSAPPBOT
botadmin=$YNH_APP_ARG_BOTADMIN
botusers=$YNH_APP_ARG_BOTUSERS
@@ -48,13 +49,14 @@ is_public=$YNH_APP_ARG_IS_PUBLIC
### db names, ...
app=$YNH_APP_INSTANCE_NAME
-if [ $YNH_APP_INSTANCE_NUMBER -eq "1" ]
+# ToDo check (in manifest?) if the selected synapse instance is not already connected to a mautrix_whatsapp bridge
+if [ $synapsenumber -eq "1" ]
then
server_name=$(ynh_app_setting_get --app synapse --key server_name)
domain=$(ynh_app_setting_get --app synapse --key domain)
else
-server_name=$(ynh_app_setting_get --app synapse__$YNH_APP_INSTANCE_NUMBER --key server_name)
-domain=$(ynh_app_setting_get --app synapse__$YNH_APP_INSTANCE_NUMBER --key domain)
+server_name=$(ynh_app_setting_get --app synapse__$synapsenumber --key server_name)
+domain=$(ynh_app_setting_get --app synapse__$synapsenumber --key domain)
fi
@@ -230,6 +232,7 @@ ynh_add_systemd_config --service=$app
cd $final_path
#echo 'export PATH=$PATH:/usr/lib/go-1.11/bin/' >> /etc/profile
#source /etc/profile
+export PATH=$PATH:/usr/lib/go-$GO_VERSION/bin
go build
#Copy example-config.yaml to config.yaml
cp example-config.yaml config.yaml
From 66b14dff75bd52585eb6a2dc76a02b097cb27a3b Mon Sep 17 00:00:00 2001
From: Gredin67 <35761345+Gredin67@users.noreply.github.com>
Date: Sun, 26 Apr 2020 14:19:00 +0200
Subject: [PATCH 24/34] authorized users $botusers
---
scripts/install | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/scripts/install b/scripts/install
index aeafff4..d9a29f5 100755
--- a/scripts/install
+++ b/scripts/install
@@ -312,17 +312,12 @@ ynh_replace_string --match_string="uri: mautrix-whatsapp.db" --replace_string="u
# mxid - Specific user
#permissions:
# "*": relaybot
-# "example.com": user
-# "@admin:example.com": admin
#ynh_replace_string --match_string=""*": relaybot" --replace_string=""*": relaybot" --target_file="$final_path/config.yaml"
-ynh_replace_string --match_string="@admin:example.com" --replace_string="$botadmin" --target_file="$final_path/config.yaml"
-# Make app public if necessary
-if [ $is_public -eq 1 ]
-then
-ynh_replace_string --match_string="example.com" --replace_string="$domain" --target_file="$final_path/config.yaml"
-else
+# "example.com": user
ynh_replace_string --match_string="example.com" --replace_string="$botusers" --target_file="$final_path/config.yaml"
-fi
+#ynh_replace_string --match_string="example.com" --replace_string="$domain" --target_file="$final_path/config.yaml"
+# "@admin:example.com": admin
+ynh_replace_string --match_string="@admin:example.com" --replace_string="$botadmin" --target_file="$final_path/config.yaml"
# relaybot:
# # Whether or not relaybot support is enabled.
From f3099eed65eb33701c01e743a0d39190c75e6446 Mon Sep 17 00:00:00 2001
From: Gredin67 <35761345+Gredin67@users.noreply.github.com>
Date: Sun, 26 Apr 2020 15:01:14 +0200
Subject: [PATCH 25/34] improve questions, remove is_public
---
manifest.json | 49 ++++++++++++++++++++-----------------------------
1 file changed, 20 insertions(+), 29 deletions(-)
diff --git a/manifest.json b/manifest.json
index 1b9bd5d..f058142 100644
--- a/manifest.json
+++ b/manifest.json
@@ -23,12 +23,12 @@
],
"arguments": {
"install": [
- {
+ {
"name": "port",
"type": "string",
"ask": {
- "en": "Choose a port for communication between app service and home server",
- "fr": "Choisissez un port pour la communication entre l'app service et le home server"
+ "en": "Choose a port for communication between mautrix_whatsapp (app service) and synapse (home server)",
+ "fr": "Choisissez un port pour la communication entre mautrix_whatsapp (app service) et synapse (home server)"
},
"example": "29318",
"default": "8449"
@@ -37,23 +37,27 @@
"name": "synapsenumber",
"type": "string",
"ask": {
- "en": "Choose the synapse instance number to communicate with app service",
+ "en": "Choose the local synapse instance number to communicate with app service",
"fr": "Choisissez le numéro de l'instance synapse qui doit communiquer avec l'app service"
},
- "example": "2",
+ "example": "2 (for instance synapse__2)",
+ "help": {
+ "en": "If you installed synapse only once time, then leave default value 1.",
+ "fr": "Si vous n'avez installé qu'une fois synapse, gardez la valeur par défaut 1."
+ },
"default": "1"
},
{
"name": "whatsappbot",
"type": "string",
"ask": {
- "en": "Choose the local Matrix/Synapse user name of the WhatsApp bot",
- "fr": "Choisissez le nom d'utilisateur local Matrix/Synapse du robot WhatsApp"
+ "en": "Choose a local Matrix/Synapse user name for the WhatsApp bot",
+ "fr": "Choisissez un nom d'utilisateur local Matrix/Synapse pour le robot WhatsApp"
},
"example": "whatsappbot",
"help": {
- "en": "Invite @whatsappbot:domain.org from an authorize Matrix account to setup the bridge.",
- "fr": "Inviter @whatsappbot:domain.org depuis votre compte Matrix principal pour démarrer la passerelle."
+ "en": "A system user will be created. Invite @whatsappbot:localsynapse.servername from an authorized Matrix account to start bridging. Give the synapse server name, not the domain.",
+ "fr": "Un utilisateur système sera créé. Inviter @whatsappbot:localsynapse.servername depuis un compte Matrix autorisé pour démarrer une passerelle. Donner le server name, pas le domain"
},
"default": "whatsappbot"
},
@@ -64,10 +68,10 @@
"en": "Choose the Matrix account administrator of the WhatsApp bot",
"fr": "Choisissez le compte Matrix administrateur du robot WhatsApp"
},
- "example": "@johndoe:domain.org or @johndoe:matrix.org",
+ "example": "@johndoe:localsynapse.servername or @johndoe:matrix.org",
"help": {
"en": "The WhatsApp bot administrator does not need to be a local Matrix/Synapse account.",
- "fr": "Le compte administrateur du robot WhatsApp peut ne pas etre un compte Matrix/Synapse local."
+ "fr": "Le compte administrateur du robot WhatsApp peut ne pas être un compte Matrix/Synapse local."
},
"default": "Your main Matrix account"
},
@@ -75,27 +79,14 @@
"name": "botusers",
"type": "string",
"ask": {
- "en": "Choose Matrix user(s) authorized to use the WhatsApp bot",
+ "en": "Choose Matrix user(s) authorized to bridge with the WhatsApp bot",
"fr": "Choisissez le/les compte(s) Matrix autorisés à utiliser le robot WhatsApp"
},
- "example": "@johndoe:domain.org or matrix.org or *",
- "default": "",
+ "example": "admin or local or @johndoe:server.name or server.name or *",
+ "default": "admin",
"help": {
- "en": "Either the administrator only (), a Matrix user (@johndoe:domain.org), a server (matrix.org) or all servers (*) can be authorized.",
- "fr": "On peut autoriser le compte administrateur seul (), un compte (@johndoe:domain.org), un serveur (matrix.org) ou tous les serveurs Matrix (*)."
- }
- },
- {
- "name": "is_public",
- "type": "boolean",
- "ask": {
- "en": "Allow usage of the WhatsApp to all local Matrix/Synapse users?",
- "fr": "Autoriser l'usage du robot WhatsApp à tous les utilisateurs locaux Matrix/Synapse ?"
- },
- "default": true,
- "help": {
- "en": "A public bot means anyone with a matrix account on the local Matrix/Synapse server will be able to use the bot.",
- "fr": "Un robot public signifie que chaque compte matrix du serveur local Matrix/Synapse pourra utiliser le robot."
+ "en": "Either the administrator only (admin), all local Matrix/Synapse users (local), a remote or local user (@johndoe:server.name), a remote server (matrix.org), or all remote/local servers (*) can be authorized. Give the synapse server name, not the domain.",
+ "fr": "On peut autoriser le compte administrateur seul (admin), tous les comptes Matrix/Synapse locaux (local), un compte local ou distant (@johndoe:server.name), un serveur distant (matrix.org), ou tous les serveurs remote/local (*). Donner le server name, pas le domain."
}
}
]
From 428f7a8b17bad0a4e9d334531854dc9e2bfc2287 Mon Sep 17 00:00:00 2001
From: Gredin67 <35761345+Gredin67@users.noreply.github.com>
Date: Sun, 26 Apr 2020 15:10:24 +0200
Subject: [PATCH 26/34] remove is_public improve user authorization
---
scripts/install | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/scripts/install b/scripts/install
index d9a29f5..546dae5 100755
--- a/scripts/install
+++ b/scripts/install
@@ -33,7 +33,7 @@ synapsenumber=$YNH_APP_ARG_SYNAPSENUMBER
whatsappbot=$YNH_APP_ARG_WHATSAPPBOT
botadmin=$YNH_APP_ARG_BOTADMIN
botusers=$YNH_APP_ARG_BOTUSERS
-is_public=$YNH_APP_ARG_IS_PUBLIC
+#is_public=$YNH_APP_ARG_IS_PUBLIC
#language=$YNH_APP_ARG_LANGUAGE
#password=$YNH_APP_ARG_PASSWORD
@@ -107,7 +107,7 @@ ynh_app_setting_set --app=$app --key=botadmin --value=$botadmin
ynh_app_setting_set --app=$app --key=botusers --value=$botusers
ynh_app_setting_set --app=$app --key=mautrix_version --value=$upstream_version
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
-ynh_app_setting_set --app=$app --key=is_public --value=$is_public
+#ynh_app_setting_set --app=$app --key=is_public --value=$is_public
#ynh_app_setting_set --app=$app --key=language --value=$language
#=================================================
@@ -314,8 +314,15 @@ ynh_replace_string --match_string="uri: mautrix-whatsapp.db" --replace_string="u
# "*": relaybot
#ynh_replace_string --match_string=""*": relaybot" --replace_string=""*": relaybot" --target_file="$final_path/config.yaml"
# "example.com": user
+if [ $botusers -eq "domain" ]
+then
+ynh_replace_string --match_string="example.com" --replace_string="$server_name" --target_file="$final_path/config.yaml"
+else if [ $botusers -eq "admin" ]
+ynh_replace_string --match_string="example.com" --replace_string="" --target_file="$final_path/config.yaml"
+else
ynh_replace_string --match_string="example.com" --replace_string="$botusers" --target_file="$final_path/config.yaml"
-#ynh_replace_string --match_string="example.com" --replace_string="$domain" --target_file="$final_path/config.yaml"
+fi
+
# "@admin:example.com": admin
ynh_replace_string --match_string="@admin:example.com" --replace_string="$botadmin" --target_file="$final_path/config.yaml"
From 6f8acf1fad5aec0f11e921d6ff90ef761eff2d8d Mon Sep 17 00:00:00 2001
From: Gredin67 <35761345+Gredin67@users.noreply.github.com>
Date: Sun, 26 Apr 2020 15:45:55 +0200
Subject: [PATCH 27/34] syntax shell elif
---
scripts/install | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/scripts/install b/scripts/install
index 546dae5..9917fa5 100755
--- a/scripts/install
+++ b/scripts/install
@@ -317,7 +317,8 @@ ynh_replace_string --match_string="uri: mautrix-whatsapp.db" --replace_string="u
if [ $botusers -eq "domain" ]
then
ynh_replace_string --match_string="example.com" --replace_string="$server_name" --target_file="$final_path/config.yaml"
-else if [ $botusers -eq "admin" ]
+elif [ $botusers -eq "admin" ]
+then
ynh_replace_string --match_string="example.com" --replace_string="" --target_file="$final_path/config.yaml"
else
ynh_replace_string --match_string="example.com" --replace_string="$botusers" --target_file="$final_path/config.yaml"
From 49546c81c7bf9ed691d6301497883b66dd23f371 Mon Sep 17 00:00:00 2001
From: Gredin67 <35761345+Gredin67@users.noreply.github.com>
Date: Sun, 26 Apr 2020 16:08:47 +0200
Subject: [PATCH 28/34] Update bot users and admin rights
---
scripts/install | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/scripts/install b/scripts/install
index 9917fa5..48f41f2 100755
--- a/scripts/install
+++ b/scripts/install
@@ -316,16 +316,16 @@ ynh_replace_string --match_string="uri: mautrix-whatsapp.db" --replace_string="u
# "example.com": user
if [ $botusers -eq "domain" ]
then
-ynh_replace_string --match_string="example.com" --replace_string="$server_name" --target_file="$final_path/config.yaml"
+ynh_replace_string --match_string='"example.com": user' --replace_string='"$server_name": user' --target_file='$final_path/config.yaml'
elif [ $botusers -eq "admin" ]
then
-ynh_replace_string --match_string="example.com" --replace_string="" --target_file="$final_path/config.yaml"
+ynh_replace_string --match_string='"example.com": user' --replace_string='#"example.com": user' --target_file='$final_path/config.yaml'
else
-ynh_replace_string --match_string="example.com" --replace_string="$botusers" --target_file="$final_path/config.yaml"
+ynh_replace_string --match_string='"example.com": user' --replace_string='"$botusers": user' --target_file='$final_path/config.yaml'
fi
# "@admin:example.com": admin
-ynh_replace_string --match_string="@admin:example.com" --replace_string="$botadmin" --target_file="$final_path/config.yaml"
+ynh_replace_string --match_string='"@admin:example.com": admin' --replace_string='"$botadmin": admin' --target_file="$final_path/config.yaml"
# relaybot:
# # Whether or not relaybot support is enabled.
From 53e104d1c8bcca63e362d6a5135ccc02ca96e1ca Mon Sep 17 00:00:00 2001
From: Gredin67 <35761345+Gredin67@users.noreply.github.com>
Date: Sun, 26 Apr 2020 16:15:11 +0200
Subject: [PATCH 29/34] string comparator ==
---
scripts/install | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/install b/scripts/install
index 48f41f2..2c3b812 100755
--- a/scripts/install
+++ b/scripts/install
@@ -314,10 +314,10 @@ ynh_replace_string --match_string="uri: mautrix-whatsapp.db" --replace_string="u
# "*": relaybot
#ynh_replace_string --match_string=""*": relaybot" --replace_string=""*": relaybot" --target_file="$final_path/config.yaml"
# "example.com": user
-if [ $botusers -eq "domain" ]
+if [ $botusers == "domain" ]
then
ynh_replace_string --match_string='"example.com": user' --replace_string='"$server_name": user' --target_file='$final_path/config.yaml'
-elif [ $botusers -eq "admin" ]
+elif [ $botusers == "admin" ]
then
ynh_replace_string --match_string='"example.com": user' --replace_string='#"example.com": user' --target_file='$final_path/config.yaml'
else
From a239cd90f5e820432b8579cd8b99c9c92ffac721 Mon Sep 17 00:00:00 2001
From: Gredin67 <35761345+Gredin67@users.noreply.github.com>
Date: Sun, 26 Apr 2020 16:26:11 +0200
Subject: [PATCH 30/34] and again
---
scripts/install | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/scripts/install b/scripts/install
index 2c3b812..4d8589d 100755
--- a/scripts/install
+++ b/scripts/install
@@ -314,10 +314,13 @@ ynh_replace_string --match_string="uri: mautrix-whatsapp.db" --replace_string="u
# "*": relaybot
#ynh_replace_string --match_string=""*": relaybot" --replace_string=""*": relaybot" --target_file="$final_path/config.yaml"
# "example.com": user
-if [ $botusers == "domain" ]
+echo "$botusers"
+echo "domain"
+echo "admin"
+if [ "$botusers" = "domain" ]
then
ynh_replace_string --match_string='"example.com": user' --replace_string='"$server_name": user' --target_file='$final_path/config.yaml'
-elif [ $botusers == "admin" ]
+elif [ "$botusers" = "admin" ]
then
ynh_replace_string --match_string='"example.com": user' --replace_string='#"example.com": user' --target_file='$final_path/config.yaml'
else
@@ -325,7 +328,7 @@ ynh_replace_string --match_string='"example.com": user' --replace_string='"$botu
fi
# "@admin:example.com": admin
-ynh_replace_string --match_string='"@admin:example.com": admin' --replace_string='"$botadmin": admin' --target_file="$final_path/config.yaml"
+ynh_replace_string --match_string='"@admin:example.com": admin' --replace_string='"$botadmin": admin' --target_file='$final_path/config.yaml'
# relaybot:
# # Whether or not relaybot support is enabled.
From 0fd862344b44e8c4313b3b18848f592189764069 Mon Sep 17 00:00:00 2001
From: Gredin67 <35761345+Gredin67@users.noreply.github.com>
Date: Sun, 26 Apr 2020 16:42:27 +0200
Subject: [PATCH 31/34] " ' issues
---
scripts/install | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/scripts/install b/scripts/install
index 4d8589d..50a3bec 100755
--- a/scripts/install
+++ b/scripts/install
@@ -319,16 +319,16 @@ echo "domain"
echo "admin"
if [ "$botusers" = "domain" ]
then
-ynh_replace_string --match_string='"example.com": user' --replace_string='"$server_name": user' --target_file='$final_path/config.yaml'
+ynh_replace_string --match_string='"example.com": user' --replace_string='"$server_name": user' --target_file="$final_path/config.yaml"
elif [ "$botusers" = "admin" ]
then
-ynh_replace_string --match_string='"example.com": user' --replace_string='#"example.com": user' --target_file='$final_path/config.yaml'
+ynh_replace_string --match_string='"example.com": user' --replace_string='#"example.com": user' --target_file="$final_path/config.yaml"
else
-ynh_replace_string --match_string='"example.com": user' --replace_string='"$botusers": user' --target_file='$final_path/config.yaml'
+ynh_replace_string --match_string='"example.com": user' --replace_string='"$botusers": user' --target_file="$final_path/config.yaml"
fi
# "@admin:example.com": admin
-ynh_replace_string --match_string='"@admin:example.com": admin' --replace_string='"$botadmin": admin' --target_file='$final_path/config.yaml'
+ynh_replace_string --match_string='"@admin:example.com": admin' --replace_string='"$botadmin": admin' --target_file="$final_path/config.yaml"
# relaybot:
# # Whether or not relaybot support is enabled.
From bb52075dbc04108a5dfb8f86bfe5b23395a66166 Mon Sep 17 00:00:00 2001
From: Gredin67 <35761345+Gredin67@users.noreply.github.com>
Date: Sun, 26 Apr 2020 16:52:33 +0200
Subject: [PATCH 32/34] and again
---
scripts/install | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/scripts/install b/scripts/install
index 50a3bec..257132f 100755
--- a/scripts/install
+++ b/scripts/install
@@ -312,23 +312,23 @@ ynh_replace_string --match_string="uri: mautrix-whatsapp.db" --replace_string="u
# mxid - Specific user
#permissions:
# "*": relaybot
-#ynh_replace_string --match_string=""*": relaybot" --replace_string=""*": relaybot" --target_file="$final_path/config.yaml"
+ynh_replace_string --match_string="'*': relaybot" --replace_string="'': relaybot" --target_file="$final_path/config.yaml"
+# "@admin:example.com": admin
+ynh_replace_string --match_string="@admin:example.com" --replace_string="$botadmin" --target_file="$final_path/config.yaml"
# "example.com": user
echo "$botusers"
echo "domain"
echo "admin"
if [ "$botusers" = "domain" ]
then
-ynh_replace_string --match_string='"example.com": user' --replace_string='"$server_name": user' --target_file="$final_path/config.yaml"
+ynh_replace_string --match_string="example.com" --replace_string="$server_name" --target_file="$final_path/config.yaml"
elif [ "$botusers" = "admin" ]
then
-ynh_replace_string --match_string='"example.com": user' --replace_string='#"example.com": user' --target_file="$final_path/config.yaml"
+#ynh_replace_string --match_string='"example.com": user' --replace_string='#"example.com": user' --target_file="$final_path/config.yaml"
else
-ynh_replace_string --match_string='"example.com": user' --replace_string='"$botusers": user' --target_file="$final_path/config.yaml"
+ynh_replace_string --match_string="example.com" --replace_string="$botusers" --target_file="$final_path/config.yaml"
fi
-# "@admin:example.com": admin
-ynh_replace_string --match_string='"@admin:example.com": admin' --replace_string='"$botadmin": admin' --target_file="$final_path/config.yaml"
# relaybot:
# # Whether or not relaybot support is enabled.
From f23db5ca3b51cfc3b25c6a324e2639024afeefa2 Mon Sep 17 00:00:00 2001
From: Gredin67 <35761345+Gredin67@users.noreply.github.com>
Date: Sun, 26 Apr 2020 16:59:57 +0200
Subject: [PATCH 33/34] again
---
scripts/install | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/scripts/install b/scripts/install
index 257132f..b7d3c27 100755
--- a/scripts/install
+++ b/scripts/install
@@ -312,19 +312,16 @@ ynh_replace_string --match_string="uri: mautrix-whatsapp.db" --replace_string="u
# mxid - Specific user
#permissions:
# "*": relaybot
-ynh_replace_string --match_string="'*': relaybot" --replace_string="'': relaybot" --target_file="$final_path/config.yaml"
+#ynh_replace_string --match_string="'*': relaybot" --replace_string="'': relaybot" --target_file="$final_path/config.yaml"
# "@admin:example.com": admin
ynh_replace_string --match_string="@admin:example.com" --replace_string="$botadmin" --target_file="$final_path/config.yaml"
# "example.com": user
-echo "$botusers"
-echo "domain"
-echo "admin"
if [ "$botusers" = "domain" ]
then
ynh_replace_string --match_string="example.com" --replace_string="$server_name" --target_file="$final_path/config.yaml"
elif [ "$botusers" = "admin" ]
then
-#ynh_replace_string --match_string='"example.com": user' --replace_string='#"example.com": user' --target_file="$final_path/config.yaml"
+ynh_replace_string --match_string="'example.com': user" --replace_string="#'example.com': user" --target_file="$final_path/config.yaml"
else
ynh_replace_string --match_string="example.com" --replace_string="$botusers" --target_file="$final_path/config.yaml"
fi
From b8e5fa4849eeb12c4ad62f3c4b9dc30e55a63ad5 Mon Sep 17 00:00:00 2001
From: Gredin67 <35761345+Gredin67@users.noreply.github.com>
Date: Thu, 30 Apr 2020 14:42:24 +0200
Subject: [PATCH 34/34] Unified mautrix_whatsapp
---
manifest.json | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/manifest.json b/manifest.json
index f058142..b3e9752 100644
--- a/manifest.json
+++ b/manifest.json
@@ -11,8 +11,8 @@
"license": "AGPL3",
"maintainer": {
"name": "Gredin67",
- "email": "ghentz@mailz.org",
- "url": "https://github.com/YunoHost-Apps/mautrix-whatsapp_ynh"
+ "email": "mautrix_whatsapp@neutralite.org",
+ "url": "https://github.com/Gredin67/mautrix_whatsapp_ynh"
},
"requirements": {
"yunohost": ">= 3.5"
@@ -56,8 +56,8 @@
},
"example": "whatsappbot",
"help": {
- "en": "A system user will be created. Invite @whatsappbot:localsynapse.servername from an authorized Matrix account to start bridging. Give the synapse server name, not the domain.",
- "fr": "Un utilisateur système sera créé. Inviter @whatsappbot:localsynapse.servername depuis un compte Matrix autorisé pour démarrer une passerelle. Donner le server name, pas le domain"
+ "en": "A system user will be created. Invite @whatsappbot:localsynapse.servername from an authorized Matrix account to start bridging. Give the matrix server_name, not the full domain/url.",
+ "fr": "Un utilisateur système sera créé. Inviter @whatsappbot:localsynapse.servername depuis un compte Matrix autorisé pour démarrer une passerelle. Donner le nom du serveur matrix, pas le domaine/url complet."
},
"default": "whatsappbot"
},
@@ -71,7 +71,7 @@
"example": "@johndoe:localsynapse.servername or @johndoe:matrix.org",
"help": {
"en": "The WhatsApp bot administrator does not need to be a local Matrix/Synapse account.",
- "fr": "Le compte administrateur du robot WhatsApp peut ne pas être un compte Matrix/Synapse local."
+ "fr": "Le compte administrateur du robot WhatsApp peut ne pas être un compte local Matrix/Synapse."
},
"default": "Your main Matrix account"
},
@@ -85,8 +85,8 @@
"example": "admin or local or @johndoe:server.name or server.name or *",
"default": "admin",
"help": {
- "en": "Either the administrator only (admin), all local Matrix/Synapse users (local), a remote or local user (@johndoe:server.name), a remote server (matrix.org), or all remote/local servers (*) can be authorized. Give the synapse server name, not the domain.",
- "fr": "On peut autoriser le compte administrateur seul (admin), tous les comptes Matrix/Synapse locaux (local), un compte local ou distant (@johndoe:server.name), un serveur distant (matrix.org), ou tous les serveurs remote/local (*). Donner le server name, pas le domain."
+ "en": "Either the administrator only (admin), all local Matrix/Synapse users (local), a remote or local user (@johndoe:server.name), a remote server (matrix.org), or all remote/local servers (*) can be authorized. Give the matrix server_name, not the full domain/url.",
+ "fr": "On peut autoriser le compte administrateur seul (admin), tous les comptes Matrix/Synapse locaux (local), un compte local ou distant (@johndoe:server.name), un serveur distant (matrix.org), ou tous les serveurs remote/local (*). Donner le nom du serveur matrix, pas le domaine/url complet."
}
}
]