diff --git a/README.md b/README.md
index 6633016..1cdca24 100644
--- a/README.md
+++ b/README.md
@@ -18,7 +18,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
SimpleX - the first messaging platform operating without user identifiers of any kind - 100% private by design! iOS and Android apps are released.
-**Shipped version:** 5.0.0~ynh2
+**Shipped version:** 5.1.0~ynh1
## Screenshots
@@ -28,7 +28,7 @@ SimpleX - the first messaging platform operating without user identifiers of any
* Official app website:
* Official admin documentation:
-* Upstream app code repository:
+* Upstream app code repository:
* YunoHost documentation for this app:
* Report a bug:
diff --git a/README_fr.md b/README_fr.md
index 91d9689..0a92191 100644
--- a/README_fr.md
+++ b/README_fr.md
@@ -18,7 +18,7 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po
SimpleX - la première plate-forme de messagerie qui n'a aucun identifiant d'utilisateur d'aucune sorte - 100 % privée de par sa conception !
-**Version incluse :** 5.0.0~ynh2
+**Version incluse :** 5.1.0~ynh1
## Captures d’écran
@@ -28,7 +28,7 @@ SimpleX - la première plate-forme de messagerie qui n'a aucun identifiant d'uti
* Site officiel de l’app :
* Documentation officielle de l’admin :
-* Dépôt de code officiel de l’app :
+* Dépôt de code officiel de l’app :
* Documentation YunoHost pour cette app :
* Signaler un bug :
diff --git a/conf/file-server.ini b/conf/file-server.ini
new file mode 100644
index 0000000..b0aafc8
--- /dev/null
+++ b/conf/file-server.ini
@@ -0,0 +1,32 @@
+ 1,1 All
+[STORE_LOG]
+# The server uses STM memory for persistence,
+# that will be lost on restart (e.g., as with redis).
+# This option enables saving memory to append only log,
+# and restoring it when the server is started.
+# Log is compacted on start (deleted objects are removed).
+enable: on
+
+log_stats: off
+
+[AUTH]
+# Set new_files option to off to completely prohibit uploading new files.
+# This can be useful when you want to decommission the server, but still allow downloading the existing files.
+new_files: on
+
+# Use create_password option to enable basic auth to upload new files.
+# The password should be used as part of server address in client configuration:
+# xftp://fingerprint:password@host1,host2
+# The password will not be shared with file recipients, you must share it only
+# with the users who you want to allow uploading files to your server.
+# create_password: password to upload files (any printable ASCII characters without whitespace, '@', ':' and '/')
+
+[TRANSPORT]
+# host is only used to print server address on start
+host: __PUBLIC_IP4__
+port: __PORT_XFTP__
+log_tls_errors: off
+
+[FILES]
+path: __DATA_DIR__
+storage_quota: __STORAGE_QUOTA__
diff --git a/conf/systemd.service b/conf/systemd.service
index 0db7783..2c11a46 100644
--- a/conf/systemd.service
+++ b/conf/systemd.service
@@ -1,5 +1,6 @@
[Unit]
Description=SimpleX: Messaging Protocol Server
+Documentation=https://simplex.chat/docs/server.html
After=network.target
[Service]
diff --git a/conf/xftp.systemd.service b/conf/xftp.systemd.service
new file mode 100644
index 0000000..12c0092
--- /dev/null
+++ b/conf/xftp.systemd.service
@@ -0,0 +1,18 @@
+[Unit]
+Description=XFTP server systemd service
+Documentation=https://simplex.chat/docs/xftp-server.html
+After=network.target
+
+[Service]
+Type=simple
+User=__APP__
+Group=__APP__
+WorkingDirectory=__INSTALL_DIR__/
+ExecStart=__INSTALL_DIR__/xftp-server start +RTS -N -RTS
+LimitNOFILE=65535
+KillSignal=SIGINT
+TimeoutStopSec=infinity
+AmbientCapabilities=CAP_NET_BIND_SERVICE
+
+[Install]
+WantedBy=multi-user.target
diff --git a/config_panel.toml.example b/config_panel.toml.example
index c6bccd8..fcaabe2 100644
--- a/config_panel.toml.example
+++ b/config_panel.toml.example
@@ -1,295 +1,14 @@
-
-## Config panel are available from webadmin > Apps > YOUR_APP > Config Panel Button
-## Those panels let user configure some params on their apps using a friendly interface,
-## and remove the need to manually edit files from the command line.
-
-## From a packager perspective, this .toml is coupled to the scripts/config script,
-## which may be used to define custom getters/setters. However, most use cases
-## should be covered automagically by the core, thus it may not be necessary
-## to define a scripts/config at all!
-
-## -----------------------------------------------------------------------------
-## IMPORTANT: In accordance with YunoHost's spirit, please keep things simple and
-## do not overwhelm the admin with tons of misunderstandable or advanced settings.
-## -----------------------------------------------------------------------------
-
-## The top level describe the entire config panels screen.
-
-## The version is a required property.
-## Here a small reminder to associate config panel version with YunoHost version
-## | Config | YNH | Config panel small change log |
-## | ------ | --- | ------------------------------------------------------- |
-## | 0.1 | 3.x | 0.1 config script not compatible with YNH >= 4.3 |
-## | 1.0 | 4.3.x | The new config panel system with 'bind' property |
version = "1.0"
-## (optional) i18n property let you internationalize questions, however this feature
-## is only available in core configuration panel (like yunohost domain config).
-## So in app config panel this key is ignored for now, but you can internationalize
-## by using a lang dictionary (see property name bellow)
-# i18n = "prefix_translation_key"
-
-################################################################################
-#### ABOUT PANELS
-################################################################################
-
-## The next level describes web admin panels
-## You have to choose an ID for each panel, in this example the ID is "main"
-## Keep in mind this ID will be used in CLI to refer to your question, so choose
-## something short and meaningfull.
-## In the webadmin, each panel corresponds to a distinct tab / form
[main]
+name = "Simplex configuration"
+services = ["xftp"]
-## Define the label for your panel
-## Internationalization works similarly to the 'description' and 'ask' questions in the manifest
-# name.en = "Main configuration"
-# name.fr = "Configuration principale"
+ [main.config]
+ name = "Configuration Options"
-## (optional) If you need to trigger a service reload-or-restart after the user
-## change a question in this panel, you can add your service in the list.
-services = ["__APP__"]
-# or services = ["nginx", "__APP__"] to also reload-or-restart nginx
-
-## (optional) This help properties is a short help displayed on the same line
-## than the panel title but not displayed in the tab.
-# help = ""
-
- ############################################################################
- #### ABOUT SECTIONS
- ############################################################################
-
- ## A panel is composed of one or several sections.
- ##
- ## Sections are meant to group questions together when they correspond to
- ## a same subtopic. This impacts the rendering in terms of CLI prompts
- ## and HTML forms
- ##
- ## You should choose an ID for your section, and prefix it with the panel ID
- ## (Be sure to not make a typo in the panel ID, which would implicitly create
- ## an other entire panel)
- ##
- ## We use the context of pepettes_ynh as an example,
- ## which is a simple donation form app written in python,
- ## and for which the admin will want to edit the configuration
- [main.customization]
-
- ## (optional) Defining a proper title for sections is not mandatory
- ## and depends on the exact rendering you're aiming for the CLI / webadmin
- name = ""
-
- ## (optional) This help properties is a short help displayed on the same line
- ## than the section title, meant to provide additional details
- # help = ""
-
- ## (optional) As for panel, you can specify to trigger a service
- ## reload-or-restart after the user change a question in this section.
- ## This property is added to the panel property, it doesn't deactivate it.
- ## So no need to replicate, the service list from panel services property.
- # services = []
-
- ## (optional) By default all questions are optionals, but you can specify a
- ## default behaviour for question in the section
- optional = false
-
- ## (optional) It's also possible with the 'visible' property to only
- ## display the section depending on the user's answers to previous questions.
- ##
- ## Be careful that the 'visible' property should only refer to **previous** questions
- ## Hence, it should not make sense to have a "visible" property on the very first section.
- ##
- ## Also, keep in mind that this feature only works in the webadmin and not in CLI
- ## (therefore a user could be prompted in CLI for a question that may not be relevant)
- # visible = true
-
- ########################################################################
- #### ABOUT QUESTIONS
- ########################################################################
-
- ## A section is compound of one or several questions.
-
- ## ---------------------------------------------------------------------
- ## IMPORTANT: as for panel and section you have to choose an ID, but this
- ## one should be unique in all this document, even if the question is in
- ## an other panel.
- ## ---------------------------------------------------------------------
-
- ## You can use same questions types and properties than in manifest.yml
- ## install part. However, in YNH 4.3, a lot of change has been made to
- ## extend availables questions types list.
- ## See: TODO DOC LINK
-
- [main.customization.project_name]
-
- ## (required) The ask property is equivalent to the ask property in
- ## the manifest. However, in config panels, questions are displayed on the
- ## left side and therefore have less space to be rendered. Therefore,
- ## it is better to use a short question, and use the "help" property to
- ## provide additional details if necessary.
- ask.en = "Name of the project"
-
- ## (required) The type property indicates how the question should be
- ## displayed, validated and managed. Some types have specific properties.
- ##
- ## Types available: string, boolean, number, range, text, password, path
- ## email, url, date, time, color, select, domain, user, tags, file.
- ##
- ## For a complete list with specific properties, see: TODO DOC LINK
+ [main.config.storage_quota]
+ ask = "File storage quota"
type = "string"
-
- ########################################################################
- #### ABOUT THE BIND PROPERTY
- ########################################################################
-
- ## (recommended) 'bind' property is a powerful feature that let you
- ## configure how and where the data will be read, validated and written.
-
- ## By default, 'bind property is in "settings" mode, it means it will
- ## **only** read and write the value in application settings file.
- ## bind = "settings"
-
- ## However, settings usually correspond to key/values in actual app configurations
- ## Hence, a more useful mode is to have bind = ":FILENAME". In that case, YunoHost
- ## will automagically find a line with "KEY=VALUE" in FILENAME
- ## (with the adequate separator between KEY and VALUE)
- ##
- ## YunoHost will then use this value for the read/get operation.
- ## During write/set operations, YunoHost will overwrite the value
- ## in **both** FILENAME and in the app's settings.yml
-
- ## Configuration file format supported: yaml, toml, json, ini, env, php,
- ## python. The feature probably works with others formats, but should be tested carefully.
-
- ## Note that this feature only works with relatively simple cases
- ## such as `KEY: VALUE`, but won't properly work with
- ## complex data structures like multilin array/lists or dictionnaries.
- ## It also doesn't work with XML format, custom config function call, php define(), ...
-
- ## More info on TODO
- # bind = ":/var/www/__APP__/settings.py"
-
-
- ## By default, bind = ":FILENAME" will use the question ID as KEY
- ## ... but the question ID may sometime not be the exact KEY name in the configuration file.
- ##
- ## In particular, in pepettes, the python variable is 'name' and not 'project_name'
- ## (c.f. https://github.com/YunoHost-Apps/pepettes_ynh/blob/5cc2d3ffd6529cc7356ff93af92dbb6785c3ab9a/conf/settings.py##L11 )
- ##
- ## In that case, the key name can be specified before the column ':'
-
- bind = "name:/var/www/__APP__/settings.py"
-
- ## ---------------------------------------------------------------------
- ## IMPORTANT: other 'bind' mode exists:
- ##
- ## bind = "FILENAME" (with no column character before FILENAME)
- ## may be used to bind to the **entire file content** (instead of a single KEY/VALUE)
- ## This could be used to expose an entire configuration file, or binary files such as images
- ## For example:
- ## bind = "/var/www/__APP__/img/logo.png"
- ##
- ## bind = "null" can be used to disable reading / writing in settings.
- ## This creates sort of a "virtual" or "ephemeral" question which is not related to any actual setting
- ## In this mode, you are expected to define custom getter/setters/validators in scripts/config:
- ##
- ## getter: get__QUESTIONID()
- ## setter: set__QUESTIONID()
- ## validator: validate__QUESTIONID()
- ##
- ## You can also specify a common getter / setter / validator, with the
- ## function 'bind' mode, for example here it will try to run
- ## get__array_settings() first.
- # bind = "array_settings()"
- ## ---------------------------------------------------------------------
-
- ## ---------------------------------------------------------------------
- ## IMPORTANT: with the exception of bind=null questions,
- ## question IDs should almost **always** correspond to an app setting
- ## initialized / reused during install/upgrade.
- ## Not doing so may result in inconsistencies between the config panel mechanism
- ## and the use of ynh_add_config
- ## ---------------------------------------------------------------------
-
- ########################################################################
- #### OTHER GENERIC PROPERTY FOR QUESTIONS
- ########################################################################
-
- ## (optional) An help text for the question
- help = "Fill the name of the project which will received donation"
-
- ## (optional) An example display as placeholder in web form
- # example = "YunoHost"
-
- ## (optional) set to true in order to redact the value in operation logs
- # redact = false
-
- ## (optional) A validation pattern
- ## ---------------------------------------------------------------------
- ## IMPORTANT: your pattern should be between simple quote, not double.
- ## ---------------------------------------------------------------------
- pattern.regexp = '^\w{3,30}$'
- pattern.error = "The name should be at least 3 chars and less than 30 chars. Alphanumeric chars are accepted"
-
- ## Note: visible and optional properties are also available for questions
-
-
- [main.customization.contact_url]
- ask = "Contact url"
- type = "url"
- example = "mailto: contact@example.org"
- help = "mailto: accepted"
- pattern.regexp = '^mailto:[^@]+@[^@]+|https://$'
- pattern.error = "Should be https or mailto:"
- bind = ":/var/www/__APP__/settings.py"
-
- [main.customization.logo]
- ask = "Logo"
- type = "file"
- accept = ".png"
- help = "Fill with an already resized logo"
- bind = "__FINALPATH__/img/logo.png"
-
- [main.customization.favicon]
- ask = "Favicon"
- type = "file"
- accept = ".png"
- help = "Fill with an already sized favicon"
- bind = "__FINALPATH__/img/favicon.png"
-
-
- [main.stripe]
- name = "Stripe general info"
- optional = false
-
- # The next alert is overwrited with a getter from the config script
- [main.stripe.amount]
- ask = "Donation in the month : XX €
- type = "alert"
- style = "success"
-
- [main.stripe.publishable_key]
- ask = "Publishable key"
- type = "string"
- redact = true
- help = "Indicate here the stripe publishable key"
- bind = ":/var/www/__APP__/settings.py"
-
- [main.stripe.secret_key]
- ask = "Secret key"
- type = "string"
- redact = true
- help = "Indicate here the stripe secret key"
- bind = ":/var/www/__APP__/settings.py"
-
- [main.stripe.prices]
- ask = "Prices ID"
- type = "tags"
- help = """\
- Indicates here the prices ID of donation products you created in stripe interfaces. \
- Go on [Stripe products](https://dashboard.stripe.com/products) to create those donation products. \
- Fill it tag with 'FREQUENCY/CURRENCY/PRICE_ID' \
- FREQUENCY: 'one_time' or 'recuring' \
- CURRENCY: 'EUR' or 'USD' \
- PRICE_ID: ID from stripe interfaces starting with 'price_' \
- """
- pattern.regexp = '^(one_time|recuring)/(EUR|USD)/price_.*$'
- pattern.error = "Please respect the format describe in help text for each price ID"
+ help = "File storage quota (e.g. 100gb)"
+ bind = "storage_quota:/etc/opt/simplex-xftp/file-server.ini"
diff --git a/doc/ADMIN.md b/doc/ADMIN.md
index 17f099b..73c2488 100644
--- a/doc/ADMIN.md
+++ b/doc/ADMIN.md
@@ -2,6 +2,7 @@ Your SMP server address:
```
smp://__FINGERPRINT__@__PUBLIC_IP4__:__PORT__
+xftp://__XFTP_FINGERPRINT__@__PUBLIC_IP4__:__PORT_XFTP__
```
Mobile clients are available for [iOS](https://apps.apple.com/us/app/simplex-chat/id1605771084), [Android](https://play.google.com/store/apps/details?id=chat.simplex.app) and [f-droid](https://app.simplex.chat).
diff --git a/doc/ADMIN_fr.md b/doc/ADMIN_fr.md
index 35e5aa0..72b4840 100644
--- a/doc/ADMIN_fr.md
+++ b/doc/ADMIN_fr.md
@@ -1,7 +1,8 @@
-L'adresse de votre serveur SMP est :
+Les adresses de votre serveur SMP est :
```
smp://__FINGERPRINT__@__PUBLIC_IP4__:__PORT__
+xftp://__XFTP_FINGERPRINT__@__PUBLIC_IP4__:__PORT_XFTP__
```
Les clients mobiles sont disponibles pour [iOS](https://apps.apple.com/us/app/simplex-chat/id1605771084), [Android](https://play.google.com/store/apps/details?id=chat.simplex.app) et [f-droid](https://app.simplex.chat).
diff --git a/doc/POST_INSTALL.md b/doc/POST_INSTALL.md
index c7220db..c9323ca 100644
--- a/doc/POST_INSTALL.md
+++ b/doc/POST_INSTALL.md
@@ -1,3 +1,4 @@
Your SMP server address:
smp://__FINGERPRINT__@__PUBLIC_IP4__:__PORT__
+xftp://__XFTP_FINGERPRINT__@__PUBLIC_IP4__:__PORT_XFTP__
diff --git a/doc/POST_INSTALL_fr.md b/doc/POST_INSTALL_fr.md
index 531d913..c7aae49 100644
--- a/doc/POST_INSTALL_fr.md
+++ b/doc/POST_INSTALL_fr.md
@@ -1,3 +1,4 @@
-Adresse de votre serveur SMP :
+Adresses de votre serveur SMP :
smp://__FINGERPRINT__@__PUBLIC_IP4__:__PORT__
+xftp://__XFTP_FINGERPRINT__@__PUBLIC_IP4__:__PORT_XFTP__
diff --git a/doc/POST_UPGRADE.md b/doc/POST_UPGRADE.md
index c7220db..981da15 100644
--- a/doc/POST_UPGRADE.md
+++ b/doc/POST_UPGRADE.md
@@ -1,3 +1,4 @@
Your SMP server address:
smp://__FINGERPRINT__@__PUBLIC_IP4__:__PORT__
+xftp://__XFTP_FINGERPRINT__@__PUBLIC_IP4__:__PORT_XFTP__
\ No newline at end of file
diff --git a/doc/POST_UPGRADE_fr.md b/doc/POST_UPGRADE_fr.md
index 531d913..c7aae49 100644
--- a/doc/POST_UPGRADE_fr.md
+++ b/doc/POST_UPGRADE_fr.md
@@ -1,3 +1,4 @@
-Adresse de votre serveur SMP :
+Adresses de votre serveur SMP :
smp://__FINGERPRINT__@__PUBLIC_IP4__:__PORT__
+xftp://__XFTP_FINGERPRINT__@__PUBLIC_IP4__:__PORT_XFTP__
diff --git a/manifest.toml b/manifest.toml
index 59574ab..ee4ee89 100644
--- a/manifest.toml
+++ b/manifest.toml
@@ -5,7 +5,7 @@ name = "SimpleX"
description.en = "Messaging platform operating without user identifiers"
description.fr = "Plate-forme de messagerie fonctionnant sans identifiants d'utilisateurs"
-version = "5.0.0~ynh2"
+version = "5.1.0~ynh1"
maintainers = ["eric_G"]
@@ -13,12 +13,12 @@ maintainers = ["eric_G"]
license = "AGPL-3.0"
website = "https://simplex.chat/"
admindoc = "https://github.com/simplex-chat/simplex-chat/blob/stable/docs/SERVER.md"
-code = "https://github.com/simplex-chat/simplex-chat"
+code = "https://github.com/simplex-chat/simplexmq"
cpe = "cpe:2.3:a:simplex:simplex_chat"
fund = "https://opencollective.com/simplex-chat"
[integration]
-yunohost = ">= 11.1.19"
+yunohost = ">= 11.1.21"
architectures = ["amd64", "arm64"]
multi_instance = false
ldap = "not_relevant"
@@ -33,21 +33,34 @@ ram.runtime = "50M"
[resources.sources]
[resources.sources.main]
- amd64.url = "https://github.com/YunoHost-Apps/simplex_ynh/releases/download/v5.0.0.1/smp-server_amd64"
- amd64.sha256 = "fd5c88355496ae09aad7dba582be99307813a18550d870b742c12b8a17f41b71"
+ amd64.url = "https://github.com/YunoHost-Apps/simplex_ynh/releases/download/v5.1.0/smp-server_amd64"
+ amd64.sha256 = "017071d4f6126c8aba1c11bc6624a32ec78c3e337ee04ad5c0c508eeb827f5ef"
arm64.url = "https://github.com/YunoHost-Apps/simplex_ynh/releases/download/v5.0.0.1/smp-server_arm64"
arm64.sha256 = "b59f26e4ad1a5a8b1e0e6d564c01a713d26c4b01dd6f1e27dea8961df2468002"
in_subdir = false
extract = false
rename = "smp-server"
+ [resources.sources.xftp]
+ amd64.url = "https://github.com/YunoHost-Apps/simplex_ynh/releases/download/v5.1.0/xftp-server_amd64"
+ amd64.sha256 = "4c58fe2944cb448fecc70a07e6b3a01d06964da344108019cc9e3eb015c8cbbf"
+ arm64.url = "https://github.com/YunoHost-Apps/simplex_ynh/releases/download/v5.0.0.1/xftp-server_arm64"
+ arm64.sha256 = "e48e2a57e1992616e33be2b1bda564a978f8bdef3a5e30dce55712bc66278348"
+ in_subdir = false
+ extract = false
+ rename = "xftp-server"
+
[resources.ports]
main.default = 5223
main.exposed = "TCP"
+ xftp.default = 5224
+ xftp.exposed = "TCP"
[resources.system_user]
[resources.install_dir]
dir = "/usr/local/bin/__APP__"
+ [resources.data_dir]
+
[resources.permissions]
diff --git a/scripts/backup b/scripts/backup
index 3adb9d7..04a1a6c 100755
--- a/scripts/backup
+++ b/scripts/backup
@@ -22,12 +22,16 @@ ynh_print_info --message="Declaring files to be backed up..."
ynh_backup --src_path="$install_dir"
ynh_backup --src_path="/etc/opt/simplex"
+ynh_backup --src_path="/etc/opt/simplex-xftp"
+ynh_backup --src_path="/var/opt/simplex"
+ynh_backup --src_path="/var/opt/simplex-xftp"
#=================================================
# BACKUP SYSTEMD
#=================================================
ynh_backup --src_path="/etc/systemd/system/$app.service"
+ynh_backup --src_path="/etc/systemd/system/xftp.service"
#=================================================
# END OF SCRIPT
diff --git a/scripts/install b/scripts/install
index 7b1847c..3764039 100755
--- a/scripts/install
+++ b/scripts/install
@@ -9,6 +9,13 @@
source _common.sh
source /usr/share/yunohost/helpers
+#=================================================
+# RETRIEVE ARGUMENTS FROM THE MANIFEST
+#=================================================
+
+#storage_quota="20gb"
+#ynh_app_setting_set --app=$app --key=storage_quota --value=$storage_quota
+
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
@@ -16,25 +23,48 @@ ynh_script_progression --message="Setting up source files..." --weight=1
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir"
+ynh_setup_source --dest_dir="$install_dir" --source_id="xftp"
+
+mkdir -p /etc/opt/simplex-xftp /etc/opt/simplex /var/opt/simplex-xftp /var/opt/simplex
+chown -R $app:$app /etc/opt/simplex-xftp /etc/opt/simplex /var/opt/simplex-xftp /var/opt/simplex
chmod -R o-rwx "$install_dir"
chown -R $app:$app "$install_dir"
chmod +x $install_dir/smp-server
+chmod +x $install_dir/xftp-server
#=================================================
# SPECIFIC SETUP
#=================================================
+public_ip4="$(curl -s ip.yunohost.org)" || true
+ynh_app_setting_set --app=$app --key=public_ip4 --value=$public_ip4
+
pushd "$install_dir"
- public_ip4="$(curl -s ip.yunohost.org)" || true
- ynh_app_setting_set --app=$app --key=public_ip4 --value=$public_ip4
- ./smp-server init --no-password --ip $public_ip4 -y
+ ./smp-server init --no-password --ip $public_ip4 --store-log --yes
+ ./xftp-server init --ip $public_ip4 --quota '20gb' --store-log --path $data_dir
popd
fingerprint=$(cat /etc/opt/simplex/fingerprint)
ynh_app_setting_set --app=$app --key=fingerprint --value=$fingerprint
+xftp_fingerprint=$(cat /etc/opt/simplex-xftp/fingerprint)
+ynh_app_setting_set --app=$app --key=xftp_fingerprint --value=$xftp_fingerprint
+
+ynh_replace_string --match_string="port: 443" --replace_string="port: $port_xftp" --target_file="/etc/opt/simplex-xftp/file-server.ini"
+
chown -R $app:$app "/etc/opt/simplex"
+chown -R $app:$app "/etc/opt/simplex-xftp"
+
+#=================================================
+# ADD A CONFIGURATION
+#=================================================
+#ynh_script_progression --message="Adding a configuration file..." --weight=1
+
+#ynh_add_config --template="../conf/file-server.ini" --destination="/etc/opt/simplex-xftp/file-server.ini"
+
+#chmod 400 "/etc/opt/simplex-xftp/file-server.ini"
+#chown $app:$app "/etc/opt/simplex-xftp/file-server.ini"
#=================================================
# SYSTEM CONFIGURATION
@@ -43,8 +73,10 @@ ynh_script_progression --message="Adding system configurations related to $app..
# Create a dedicated systemd config
ynh_add_systemd_config
+ynh_add_systemd_config --service=xftp --template=../conf/xftp.systemd.service
yunohost service add $app --description="Messaging platform" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port"
+yunohost service add xftp --description="Messaging platform" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port_xftp"
#=================================================
# START SYSTEMD SERVICE
@@ -52,7 +84,8 @@ yunohost service add $app --description="Messaging platform" --log="/var/log/$ap
ynh_script_progression --message="Starting a systemd service..." --weight=1
# Start a systemd service
-ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
+ynh_systemd_action --service_name=$app --action="start" --log_path="systemd"
+ynh_systemd_action --service_name="xftp" --action="start" --log_path="systemd"
#=================================================
# END OF SCRIPT
diff --git a/scripts/remove b/scripts/remove
index 33d032c..0284b9b 100755
--- a/scripts/remove
+++ b/scripts/remove
@@ -20,6 +20,7 @@ if ynh_exec_warn_less yunohost service status $app >/dev/null
then
ynh_script_progression --message="Removing $app service integration..." --weight=1
yunohost service remove $app
+ yunohost service remove xftp
fi
#=================================================
@@ -31,9 +32,13 @@ ynh_script_progression --message="Removing system configurations related to $app
# Remove the dedicated systemd config
ynh_remove_systemd_config
+ynh_remove_systemd_config --service=xftp
# Remove the app directory securely
ynh_secure_remove --file="/etc/opt/simplex"
+ynh_secure_remove --file="/etc/opt/simplex-xftp"
+ynh_secure_remove --file="/var/opt/simplex"
+ynh_secure_remove --file="/var/opt/simplex-xftp"
#=================================================
# END OF SCRIPT
diff --git a/scripts/restore b/scripts/restore
index 6eb851b..52cb464 100755
--- a/scripts/restore
+++ b/scripts/restore
@@ -20,6 +20,16 @@ ynh_restore_file --origin_path="$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
+#=================================================
+# RESTORE THE DATA DIRECTORY
+#=================================================
+ynh_script_progression --message="Restoring the data directory..." --weight=1
+
+ynh_restore_file --origin_path="$data_dir" --not_mandatory
+
+# (Same as for install dir)
+chown -R $app:www-data "$data_dir"
+
#=================================================
# RESTORE SYSTEM CONFIGURATIONS
#=================================================
@@ -28,19 +38,28 @@ chown -R $app:www-data "$install_dir"
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=4
ynh_restore_file --origin_path="/etc/opt/simplex"
-chown -R $app:$app "/etc/opt/simplex"
+ynh_restore_file --origin_path="/etc/opt/simplex-xftp"
+
+ynh_restore_file --origin_path="/var/opt/simplex"
+ynh_restore_file --origin_path="/var/opt/simplex-xftp"
+
+chown -R $app:$app /var/opt/simplex-xftp /var/opt/simplex /etc/opt/simplex-xftp /etc/opt/simplex
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet
+ynh_restore_file --origin_path="/etc/systemd/system/xftp.service"
+systemctl enable xftp.service --quiet
yunohost service add $app --description="Messaging platform" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port"
+yunohost service add xftp --description="Messaging platform" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port_xftp"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
-ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
+ynh_systemd_action --service_name=$app --action="start" --log_path="systemd"
+ynh_systemd_action --service_name=xftp --action="start" --log_path="systemd"
#=================================================
# END OF SCRIPT
diff --git a/scripts/upgrade b/scripts/upgrade
index 5de770f..6df7ce4 100644
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -15,15 +15,6 @@ source /usr/share/yunohost/helpers
upgrade_type=$(ynh_check_app_version_changed)
-#=================================================
-# STORE SETTINGS
-#=================================================
-
-public_ip4="$(curl -s ip.yunohost.org)" || true
-fingerprint=$(cat /etc/opt/simplex/fingerprint)
-ynh_app_setting_set --app=$app --key=public_ip4 --value=$public_ip4
-ynh_app_setting_set --app=$app --key=fingerprint --value=$fingerprint
-
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
@@ -31,7 +22,18 @@ ynh_app_setting_set --app=$app --key=fingerprint --value=$fingerprint
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
-ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
+ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd"
+ynh_systemd_action --service_name=xftp --action="stop" --log_path="systemd"
+
+#=================================================
+# ENSURE DOWNWARD COMPATIBILITY
+#=================================================
+ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
+
+#if [ -z "${storage_quota:-}" ]; then
+# storage_quota="20gb"
+# ynh_app_setting_set --app=$app --key=storage_quota --value=$storage_quota
+#fi
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
@@ -43,11 +45,46 @@ then
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir"
+ ynh_setup_source --dest_dir="$install_dir" --source_id="xftp"
fi
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
chmod +x $install_dir/smp-server
+chmod +x $install_dir/xftp-server
+
+#=================================================
+# SPECIFIC SETUP
+#=================================================
+
+if [ ! -d /etc/opt/simplex-xftp ]; then
+
+ mkdir -p "/etc/opt/simplex-xftp"
+
+ public_ip4="$(curl -s ip.yunohost.org)" || true
+ ynh_app_setting_set --app=$app --key=public_ip4 --value=$public_ip4
+
+ pushd "$install_dir"
+ ./xftp-server init --ip $public_ip4 --quota '20gb' --store-log --path $data_dir
+ popd
+
+ xftp_fingerprint=$(cat /etc/opt/simplex-xftp/fingerprint)
+ ynh_app_setting_set --app=$app --key=xftp_fingerprint --value=$xftp_fingerprint
+
+ ynh_replace_string --match_string="port: 443" --replace_string="port: $port_xftp" --target_file="/etc/opt/simplex-xftp/file-server.ini"
+
+ chown -R $app:$app /etc/opt/simplex-xftp /var/opt/simplex-xftp
+fi
+
+#=================================================
+# ADD A CONFIGURATION
+#=================================================
+#ynh_script_progression --message="Adding a configuration file..." --weight=1
+
+#ynh_add_config --template="../conf/file-server.ini" --destination="/etc/opt/simplex-xftp/file-server.ini"
+
+#chmod 400 "/etc/opt/simplex-xftp/file-server.ini"
+#chown $app:$app "/etc/opt/simplex-xftp/file-server.ini"
#=================================================
# REAPPLY SYSTEM CONFIGURATIONS
@@ -56,15 +93,18 @@ ynh_script_progression --message="Upgrading system configurations related to $ap
# Create a dedicated systemd config
ynh_add_systemd_config
+ynh_add_systemd_config --service=xftp --template=../conf/xftp.systemd.service
yunohost service add $app --description="Messaging platform" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port"
+yunohost service add xftp --description="Messaging platform" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port_xftp"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
-ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
+ynh_systemd_action --service_name=$app --action="start" --log_path="systemd"
+ynh_systemd_action --service_name=xftp --action="start" --log_path="systemd"
#=================================================
# END OF SCRIPT
diff --git a/tests.toml b/tests.toml
index 3b883e2..34e157d 100644
--- a/tests.toml
+++ b/tests.toml
@@ -7,3 +7,9 @@ test_format = 1.0
# ------------
exclude = ["change_url"]
+
+ # -------------------------------
+ # Commits to test upgrade from
+ # -------------------------------
+
+ test_upgrade_from.5f452d7acda69f4897ce1344678d0f59ccb162ca.name = "Upgrade from 5.0.0~ynh2"