diff --git a/README.md b/README.md index 791799a..f7ce2a9 100644 --- a/README.md +++ b/README.md @@ -1,44 +1,48 @@ + + # Pleroma for YunoHost [![Integration level](https://dash.yunohost.org/integration/pleroma.svg)](https://dash.yunohost.org/appci/app/pleroma) ![](https://ci-apps.yunohost.org/ci/badges/pleroma.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/pleroma.maintain.svg) [![Install Pleroma with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=pleroma) -> *This package allows you to install Pleroma quickly and simply on a YunoHost server. +*[Lire ce readme en français.](./README_fr.md)* + +> *This package allows you to install Pleroma quickly and simply on a YunoHost server. If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.* ## Overview -Pleroma is a microblogging server software that can federate (= exchange messages with) other servers that support ActivityPub. What that means is that you can host a server for yourself or your friends and stay in control of your online identity, but still exchange messages with people on larger servers. Pleroma will federate with all servers that implement ActivityPub, like Friendica, GNU Social, Hubzilla, Mastodon, Misskey, Peertube, and Pixelfed. -For user friendly details about Pleroma: [see here](https://blog.soykaf.com/post/what-is-pleroma/) +A free, federated social networking server built on open protocols. -**Mastodon web front-end for Pleroma:** Add **/web** in front of your Pleroma domain, eg. pleroma.domain.tld/web +**Shipped version:** 2.4.0~ynh2 -## Mobile clients that work with Pleroma: - -- Twidere -- Tusky -- Pawoo (Android + iOS) -- Subway Tooter -- Amaroq (iOS) -- Tootdon (Android + iOS) -- Tootle (iOS) - -**Shipped version:** 2.4.0 - -## Important points to read before installing - -1. **Pleroma** require a dedicated **root domain**, eg. pleroma.domain.tld -1. **Pleroma** require a valid **certificate** installed on the domain. Yunohost can **install Letsencrypt certificate** on the domain from **admin web-interface** or through **command-line**. -1. This package is currently set to **single-instance** that means you can run a **single Pleroma instance** on a **single server**. -1. The admin **password** entered when installing must **not** contain **special characters**. (See [issue #132](https://github.com/YunoHost-Apps/pleroma_ynh/issues/132)) +**Demo:** http://distsn.org/pleroma-instances.html ## Screenshots -![pleroma-screenshot1](https://user-images.githubusercontent.com/30271971/52231733-ff136500-28ba-11e9-902a-18f80e627db3.png) +![](./doc/screenshots/screenshot1.png) -## Demo +## Disclaimers / important information -* [List of instances](http://distsn.org/pleroma-instances.html) +* Any known limitations, constrains or stuff not working, such as (but not limited to): + * **Pleroma** require a dedicated **root domain**, eg. pleroma.domain.tld + * **Pleroma** require a valid **certificate** installed on the domain. Yunohost can **install Letsencrypt certificate** on the domain from **admin web-interface** or through **command-line**. + * This package is currently set to **single-instance** that means you can run a **single Pleroma instance** on a **single server**. + * The admin **password** entered when installing must **not** contain **special characters**. (See [issue #132](https://github.com/YunoHost-Apps/pleroma_ynh/issues/132)) + * requiring a full dedicated domain ? + * architectures not supported ? + * LDAP supported but HTTP auth not. + * the app requires an important amount of RAM / disk / .. to install or to work properly + * etc... + +* Other infos that people should be aware of, such as: + * any specific step to perform after installing (such as manually finishing the install, specific admin credentials, ...) + * how to configure / administrate the application if it ain't obvious + * upgrade process / specificities / things to be aware of ? + * security considerations ? ## Admin Tasks Go to **cd /var/www/pleroma/pleroma**. @@ -67,32 +71,14 @@ You can make users **moderators**. They will then be able to **delete any post** **--admin** option will **make the user moderator** and **--no-admin** will **take away the moderator privileges** from the user. -## Documentation +## Documentation and resources - * Official documentation: https://docs.pleroma.social/ - * Yunohost apps documentation: https://yunohost.org/#/app_pleroma - -## YunoHost specific features - -#### Multi-user support - -LDAP supported but HTTP auth not. - -The app can be used by multiple users. - -#### Supported architectures - -* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/pleroma.svg)](https://ci-apps.yunohost.org/ci/apps/pleroma/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/pleroma.svg)](https://ci-apps-arm.yunohost.org/ci/apps/pleroma/) - -## Links - - * Report a bug: https://github.com/YunoHost-Apps/pleroma_ynh/issues - * App website: https://pleroma.social/ - * Upstream app repository https://git.pleroma.social/pleroma/pleroma/ - * YunoHost website: https://yunohost.org/ - ---- +* Official app website: https://pleroma.social/ +* Official user documentation: https://yunohost.org/apps +* Official admin documentation: https://docs.pleroma.social/ +* Upstream app code repository: https://git.pleroma.social/pleroma/pleroma/ +* YunoHost documentation for this app: https://yunohost.org/app_pleroma +* Report a bug: https://github.com/YunoHost-Apps/pleroma_ynh/issues ## Developer info @@ -104,3 +90,5 @@ sudo yunohost app install https://github.com/YunoHost-Apps/pleroma_ynh/tree/test or sudo yunohost app upgrade pleroma -u https://github.com/YunoHost-Apps/pleroma_ynh/tree/testing --debug ``` + +**More info regarding app packaging:** https://yunohost.org/packaging_apps \ No newline at end of file diff --git a/README_fr.md b/README_fr.md new file mode 100644 index 0000000..15d919e --- /dev/null +++ b/README_fr.md @@ -0,0 +1,90 @@ +# Pleroma pour YunoHost + +[![Niveau d'intégration](https://dash.yunohost.org/integration/pleroma.svg)](https://dash.yunohost.org/appci/app/pleroma) ![](https://ci-apps.yunohost.org/ci/badges/pleroma.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/pleroma.maintain.svg) +[![Installer Pleroma avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=pleroma) + +*[Read this readme in english.](./README.md)* +*[Lire ce readme en français.](./README_fr.md)* + +> *Ce package vous permet d'installer Pleroma rapidement et simplement sur un serveur YunoHost. +Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.* + +## Vue d'ensemble + +Un serveur de réseautage social fédéré et gratuit basé sur des protocoles ouverts. + +**Version incluse :** 2.4.0~ynh2 + +**Démo :** http://distsn.org/pleroma-instances.html + +## Captures d'écran + +![](./doc/screenshots/screenshot1.png) + +## Avertissements / informations importantes + +* Any known limitations, constrains or stuff not working, such as (but not limited to): + * **Pleroma** require a dedicated **root domain**, eg. pleroma.domain.tld + * **Pleroma** require a valid **certificate** installed on the domain. Yunohost can **install Letsencrypt certificate** on the domain from **admin web-interface** or through **command-line**. + * This package is currently set to **single-instance** that means you can run a **single Pleroma instance** on a **single server**. + * The admin **password** entered when installing must **not** contain **special characters**. (See [issue #132](https://github.com/YunoHost-Apps/pleroma_ynh/issues/132)) + * requiring a full dedicated domain ? + * architectures not supported ? + * LDAP supported but HTTP auth not. + * the app requires an important amount of RAM / disk / .. to install or to work properly + * etc... + +* Other infos that people should be aware of, such as: + * any specific step to perform after installing (such as manually finishing the install, specific admin credentials, ...) + * how to configure / administrate the application if it ain't obvious + * upgrade process / specificities / things to be aware of ? + * security considerations ? + +## Admin Tasks +Go to **cd /var/www/pleroma/pleroma**. + +### Adding users + +**Run:** + + $ ( cd /var/www/pleroma/pleroma && sudo -u pleroma MIX_ENV=prod ./bin/pleroma_ctl user new ) + +### Password reset + +**Run:** + + $ ( cd /var/www/pleroma/pleroma && sudo -u pleroma MIX_ENV=prod ./bin/pleroma_ctl user reset_password ) + +This will generate a **password reset link** that you can then send to the user. + +### Moderators + +You can make users **moderators**. They will then be able to **delete any post**. + +**Run:** + + $ ( cd /var/www/pleroma/pleroma && sudo -u pleroma MIX_ENV=prod ./bin/pleroma_ctl user set --[no-]admin ) + +**--admin** option will **make the user moderator** and **--no-admin** will **take away the moderator privileges** from the user. + +## Documentations et ressources + +* Site officiel de l'app : https://pleroma.social/ +* Documentation officielle utilisateur : https://yunohost.org/apps +* Documentation officielle de l'admin : https://docs.pleroma.social/ +* Dépôt de code officiel de l'app : https://git.pleroma.social/pleroma/pleroma/ +* Documentation YunoHost pour cette app : https://yunohost.org/app_pleroma +* Signaler un bug : https://github.com/YunoHost-Apps/pleroma_ynh/issues + +## Informations pour les développeurs + +Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/pleroma_ynh/tree/testing). + +Pour essayer la branche testing, procédez comme suit. +``` +sudo yunohost app install https://github.com/YunoHost-Apps/pleroma_ynh/tree/testing --debug +ou +sudo yunohost app upgrade pleroma -u https://github.com/YunoHost-Apps/pleroma_ynh/tree/testing --debug +``` + +**Plus d'infos sur le packaging d'applications :** https://yunohost.org/packaging_apps \ No newline at end of file diff --git a/check_process b/check_process index b4f3cf5..e997daa 100644 --- a/check_process +++ b/check_process @@ -1,12 +1,12 @@ ;; Test complet ; Manifest - domain="domain.tld" (DOMAIN) - admin="john" (USER) - is_public=1 (PUBLIC|public=1|private=0) - password="pass" + domain="domain.tld" + admin="john" + is_public=1 + password="1Strong-Password" name="My_Pleroma" - registration=0 (BOOLEAN) - cache=1 (BOOLEAN) + registration=0 + cache=1 size="5g" ; Checks pkg_linter=1 @@ -16,32 +16,6 @@ setup_private=1 setup_public=1 upgrade=1 - # 0.9.99999 - # upgrade=1 from_commit=9ec87c36793780f74365d3059d7b9d12885fbfcb - # 1.1.7 - # upgrade=1 from_commit=3e88dd59d8e5593fb60a86ab955aafde76abdf2e - # 1.1.8 - # upgrade=1 from_commit=0a839da33898b7a58f12a27b5b51799694021353 - # 1.1.9 - # upgrade=1 from_commit=eedad6977760c31d7fb94ced247b9136824da580 - # 2.0.0 - # upgrade=1 from_commit=0693dd5efd5ab2a06267993cc7106ed2efc26ea2 - # 2.0.1~ynh1 - # upgrade=1 from_commit=7c3680c82b9c3f2449c6dbb346a5729a18636ac1 - # 2.0.1~ynh2 - # upgrade=1 from_commit=723df4423d80baa31e9717628bc5b5fd50114bc8 - # 2.0.2~ynh1 - # upgrade=1 from_commit=8f418ba020cee267f76bb781b03a41d384707a5b - # 2.0.2~ynh2 - # upgrade=1 from_commit=251a08383f59be006803fd12013baa92b03c1ef7 - # 2.0.5~ynh1 - # upgrade=1 from_commit=06f0005707e77fae566fedbd6e5e37f390df5173 - # 2.0.5~ynh2 - # upgrade=1 from_commit=30696599937984e9879da22220253f005e290cd0 - # 2.0.7~ynh1 - # upgrade=1 from_commit=e13745923a2e06e780e7b9d34ae084f600a9a2a2 - # 2.1.2~ynh1 - # upgrade=1 from_commit=ade89203b611fd178bc9d1cf35804bc08ea3a78b # 2.2.0~ynh1 upgrade=1 from_commit=059ddc457aabe6962f5960612ed2dc1db53daeeb # 2.2.2~ynh1 @@ -52,6 +26,8 @@ upgrade=1 from_commit=4757df265b0c3e8d1fc5280190ccfe5705dcb691 # 2.3.0~ynh3 upgrade=1 from_commit=28ed2fd7ab7b5e55154991c990d8e780560a56db + # 2.4.0~ynh1 + upgrade=1 from_commit=2c4a57afdc92a6428ccfea3ccb74c7e33dc9b9ff backup_restore=1 multi_instance=0 port_already_use=0 @@ -60,32 +36,6 @@ Email=anmol@datamol.org;yalh@yahoo.com Notification=yes ;;; Upgrade options - ; commit=9ec87c36793780f74365d3059d7b9d12885fbfcb - name=0.9.99999 - ; commit=3e88dd59d8e5593fb60a86ab955aafde76abdf2e - name=1.1.7 - ; commit=0a839da33898b7a58f12a27b5b51799694021353 - name=1.1.8 - ; commit=eedad6977760c31d7fb94ced247b9136824da580 - name=1.1.9 - ; commit=0693dd5efd5ab2a06267993cc7106ed2efc26ea2 - name=2.0.0 - ; commit=7c3680c82b9c3f2449c6dbb346a5729a18636ac1 - name=2.0.1~ynh1 - ; commit=723df4423d80baa31e9717628bc5b5fd50114bc8 - name=2.0.1~ynh2 - ; commit=8f418ba020cee267f76bb781b03a41d384707a5b - name=2.0.2~ynh1 - ; commit=251a08383f59be006803fd12013baa92b03c1ef7 - name=2.0.2~ynh2 - ; commit=06f0005707e77fae566fedbd6e5e37f390df5173 - name=2.0.5~ynh1 - ; commit=30696599937984e9879da22220253f005e290cd0 - name=2.0.5~ynh2 - ; commit=e13745923a2e06e780e7b9d34ae084f600a9a2a2 - name=2.0.7~ynh1 - ; commit=ade89203b611fd178bc9d1cf35804bc08ea3a78b - name=2.1.2~ynh1 ; commit=059ddc457aabe6962f5960612ed2dc1db53daeeb name=2.2.0~ynh1 ; commit=63723f18af5b035a41e967078cc3128423b1f9ae @@ -96,3 +46,5 @@ Notification=yes name=2.3.0~ynh2 ; commit=28ed2fd7ab7b5e55154991c990d8e780560a56db name=2.3.0~ynh3 + ; commit=2c4a57afdc92a6428ccfea3ccb74c7e33dc9b9ff + name=2.4.0~ynh1 diff --git a/doc/.gitkeep b/doc/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md new file mode 100644 index 0000000..24a6030 --- /dev/null +++ b/doc/DISCLAIMER.md @@ -0,0 +1,43 @@ +* Any known limitations, constrains or stuff not working, such as (but not limited to): + * **Pleroma** require a dedicated **root domain**, eg. pleroma.domain.tld + * **Pleroma** require a valid **certificate** installed on the domain. Yunohost can **install Letsencrypt certificate** on the domain from **admin web-interface** or through **command-line**. + * This package is currently set to **single-instance** that means you can run a **single Pleroma instance** on a **single server**. + * The admin **password** entered when installing must **not** contain **special characters**. (See [issue #132](https://github.com/YunoHost-Apps/pleroma_ynh/issues/132)) + * requiring a full dedicated domain ? + * architectures not supported ? + * LDAP supported but HTTP auth not. + * the app requires an important amount of RAM / disk / .. to install or to work properly + * etc... + +* Other infos that people should be aware of, such as: + * any specific step to perform after installing (such as manually finishing the install, specific admin credentials, ...) + * how to configure / administrate the application if it ain't obvious + * upgrade process / specificities / things to be aware of ? + * security considerations ? + +## Admin Tasks +Go to **cd /var/www/pleroma/pleroma**. + +### Adding users + +**Run:** + + $ ( cd /var/www/pleroma/pleroma && sudo -u pleroma MIX_ENV=prod ./bin/pleroma_ctl user new ) + +### Password reset + +**Run:** + + $ ( cd /var/www/pleroma/pleroma && sudo -u pleroma MIX_ENV=prod ./bin/pleroma_ctl user reset_password ) + +This will generate a **password reset link** that you can then send to the user. + +### Moderators + +You can make users **moderators**. They will then be able to **delete any post**. + +**Run:** + + $ ( cd /var/www/pleroma/pleroma && sudo -u pleroma MIX_ENV=prod ./bin/pleroma_ctl user set --[no-]admin ) + +**--admin** option will **make the user moderator** and **--no-admin** will **take away the moderator privileges** from the user. diff --git a/doc/screenshots/.gitkeep b/doc/screenshots/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/doc/screenshots/screenshot1.png b/doc/screenshots/screenshot1.png new file mode 100644 index 0000000..0dd7b1c Binary files /dev/null and b/doc/screenshots/screenshot1.png differ diff --git a/manifest.json b/manifest.json index 7d1af0a..639d2c3 100644 --- a/manifest.json +++ b/manifest.json @@ -6,8 +6,16 @@ "en": "A free, federated social networking server built on open protocols.", "fr": "Un serveur de réseautage social fédéré et gratuit basé sur des protocoles ouverts." }, - "version": "2.4.0~ynh1", - "url": "https://git.pleroma.social/pleroma/pleroma", + "version": "2.4.0~ynh2", + "url": "https://pleroma.social/", + "upstream": { + "license": "AGPL-3.0-only", + "website": "https://pleroma.social/", + "demo": "http://distsn.org/pleroma-instances.html", + "admindoc": "https://docs.pleroma.social/", + "userdoc": "https://yunohost.org/apps", + "code": "https://git.pleroma.social/pleroma/pleroma/" + }, "license": "AGPL-3.0-only", "maintainer": [ { @@ -65,7 +73,7 @@ }, "default": false }, - { + { "name": "cache", "type": "boolean", "ask": { @@ -73,7 +81,7 @@ "fr": "Activer le cache média pour votre instance" }, "default": true - }, + }, { "name": "size", "type": "string", @@ -83,7 +91,7 @@ }, "choices": ["2g","5g","10g","20g","40g","80g"], "default": "5g" - } + } ] } } diff --git a/scripts/backup b/scripts/backup index 3c1d6fc..b833944 100755 --- a/scripts/backup +++ b/scripts/backup @@ -44,6 +44,12 @@ ynh_print_info --message="Declaring files to be backed up..." ynh_backup --src_path="$final_path" +#================================================= +# BACKUP THE DATA DIR +#================================================= + +ynh_backup --src_path="$datadir" --is_big + #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= @@ -69,8 +75,6 @@ ynh_backup --src_path="/etc/systemd/system/$app.service" ynh_backup --src_path="/etc/$app/config.exs" -ynh_backup --src_path="$datadir" --is_big - #================================================= # BACKUP THE POSTGRESQL DATABASE #================================================= diff --git a/scripts/change_url b/scripts/change_url index a50bb7d..5b9feb2 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -30,6 +30,11 @@ ynh_script_progression --message="Loading installation settings..." final_path=$(ynh_app_setting_get --app=$app --key=final_path) port=$(ynh_app_setting_get --app=$app --key=port) +# Add settings here as needed by your application +#db_name=$(ynh_app_setting_get --app=$app --key=db_name) +#db_user=$db_name +#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) + #================================================= # BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP #================================================= diff --git a/scripts/install b/scripts/install index c79d09f..bea78bc 100755 --- a/scripts/install +++ b/scripts/install @@ -87,7 +87,7 @@ ynh_app_setting_set --app=$app --key=port --value=$port #================================================= ynh_script_progression --message="Installing dependencies..." -ynh_install_app_dependencies $pkg_dependencies +ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies #================================================= # CREATE DEDICATED USER @@ -95,7 +95,7 @@ ynh_install_app_dependencies $pkg_dependencies ynh_script_progression --message="Configuring system user..." # Create a system user -ynh_system_user_create --username=$app --home_dir="$final_path" +ynh_system_user_create --username=$app --home_dir=$final_path #================================================= # CREATE A POSTGRESQL DATABASE @@ -149,17 +149,14 @@ fi #================================================= # SPECIFIC SETUP #================================================= -# CREATE THE DATA DIRECTORY +# CREATE DATA DIRECTORY #================================================= -ynh_script_progression --message="Creating the data directory..." +ynh_script_progression --message="Creating a data directory..." -# Define app's data directory -datadir="/home/yunohost.app/${app}" +datadir=/home/yunohost.app/$app +ynh_app_setting_set --app=$app --key=datadir --value=$datadir -ynh_app_setting_set --app=$app --key=datadir --value="$datadir" - -# Create app folders -mkdir -p "$datadir/" +mkdir -p $datadir mkdir -p "$datadir/uploads/" mkdir -p "$datadir/static/" mkdir -p "$datadir/static/emoji/" @@ -169,9 +166,9 @@ chmod -R o-rwx "$datadir" chown -R $app:$app "$datadir" #================================================= -# CREATE THE CONFIG DIRECTORY +# ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Creating the config directory..." +ynh_script_progression --message="Adding a configuration file..." mkdir -p /etc/$app chown -R $app /etc/$app @@ -191,9 +188,6 @@ ynh_add_systemd_config #================================================= ynh_script_progression --message="Making setup..." -# Give permission to the final_path -chown -R "$app":"$app" "$final_path" - pushd $final_path/$app #Generate instance su "$app" -s $SHELL -lc "$final_path/$app/bin/pleroma_ctl instance gen --force \ @@ -261,6 +255,9 @@ then ynh_permission_update --permission="main" --add="visitors" fi +# Everyone can access to the api part +# We don't want to display the tile in the sso so we put --show_tile="false" +# And we don't want that the YunoHost Admin can remove visitors group to this permission, so we put --protected="true" ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --auth_header="false" --show_tile="false" --protected="true" #================================================= diff --git a/scripts/remove b/scripts/remove index 08946d4..d337e43 100755 --- a/scripts/remove +++ b/scripts/remove @@ -36,19 +36,14 @@ then fi #================================================= -# STOP ALL PLEROMA SERVICES +# STOP AND REMOVE SERVICE #================================================= -ynh_script_progression --message="Stopping all pleroma services..." +ynh_script_progression --message="Stopping and removing the systemd service..." ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd --line_match="Stopped $app" pkill -u $app -#================================================= -# STOP AND REMOVE SERVICE -#================================================= -ynh_script_progression --message="Stopping and removing the systemd service..." - # Remove the dedicated systemd config ynh_remove_systemd_config @@ -98,9 +93,9 @@ fi #================================================= # SPECIFIC REMOVE #================================================= -# REMOVE CONFIGURATION +# REMOVE VARIOUS FILES #================================================= -ynh_script_progression --message="Removing configuration..." +ynh_script_progression --message="Removing various files..." # Remove the config directory securely ynh_secure_remove --file="/etc/$app" diff --git a/scripts/restore b/scripts/restore index a0372ad..f310611 100755 --- a/scripts/restore +++ b/scripts/restore @@ -67,7 +67,7 @@ fi ynh_script_progression --message="Recreating the dedicated system user..." # Create the dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir="$final_path" +ynh_system_user_create --username=$app --home_dir=$final_path #================================================= # RESTORE THE APP MAIN DIR @@ -81,17 +81,14 @@ chmod -R o-rwx "$final_path" chown -R $app:$app "$final_path" #================================================= -# SPECIFIC RESTORATION +# RESTORE THE DATA DIRECTORY #================================================= -# RECREATE THE DATA DIRECTORY -#================================================= -ynh_script_progression --message="Recreating the data directory..." +ynh_script_progression --message="Restoring the data directory..." -# Use --not_mandatory for the data directory, because if the backup has been made with BACKUP_CORE_ONLY, there's no data into the backup. ynh_restore_file --origin_path="$datadir" --not_mandatory # Create app folders -mkdir -p "$datadir/" +mkdir -p $datadir mkdir -p "$datadir/uploads/" mkdir -p "$datadir/static/" mkdir -p "$datadir/static/emoji/" @@ -101,22 +98,14 @@ chmod -R o-rwx "$datadir" chown -R $app:$app "$datadir" #================================================= -# RESTORE THE CONFIG FILE -#================================================= -ynh_script_progression --message="Restoring the config file..." - -ynh_restore_file --origin_path="/etc/$app/config.exs" - -chmod 400 "/etc/$app/config.exs" -chown $app:$app "/etc/$app/config.exs" - +# SPECIFIC RESTORATION #================================================= # REINSTALL DEPENDENCIES #================================================= ynh_script_progression --message="Reinstalling dependencies..." # Define and install dependencies -ynh_install_app_dependencies $pkg_dependencies +ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies #================================================= # RESTORE THE POSTGRESQL DATABASE @@ -131,6 +120,16 @@ ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS citext;" --databa ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";" --database=$db_name ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name" +#================================================= +# RESTORE VARIOUS FILES +#================================================= +ynh_script_progression --message="Restoring various files..." + +ynh_restore_file --origin_path="/etc/$app/config.exs" + +chmod 400 "/etc/$app/config.exs" +chown $app:$app "/etc/$app/config.exs" + #================================================= # RESTORE SYSTEMD #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 2d5cb99..c31144e 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -40,48 +40,6 @@ ynh_script_progression --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) -#================================================= -# ENSURE DOWNWARD COMPATIBILITY -#================================================= -ynh_script_progression --message="Ensuring downward compatibility..." - -# Cleaning legacy permissions -if ynh_legacy_permissions_exists; then - ynh_legacy_permissions_delete_all - - ynh_app_setting_delete --app=$app --key=is_public -fi - -# Create a permission if needed -if ! ynh_permission_exists --permission="api"; then - ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --auth_header="false" --show_tile="false" --protected="true" -fi - -#Switch variables name -psql_db=$(ynh_app_setting_get --app=$app --key=psql_db) - -if [ -n "$psql_db" ] -then - db_name=$(ynh_app_setting_get --app=$app --key=psql_db) - db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) - ynh_app_setting_set --app=$app --key=db_name --value=$db_name - ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd - ynh_app_setting_delete --app=$app --key=psql_db - ynh_app_setting_delete --app=$app --key=psqlpwd -fi - -#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 - -# Remove old repository -ynh_secure_remove --file="/etc/apt/sources.list.d/erlang-solutions.list" -apt-key del A14F4FCA - #================================================= # CHECK VERSION NUMBER #================================================= @@ -122,13 +80,54 @@ if ynh_version_gt "${previous_version}" "1.1.1~ynh1" ; then pkill -u $app fi +#================================================= +# ENSURE DOWNWARD COMPATIBILITY +#================================================= +ynh_script_progression --message="Ensuring downward compatibility..." + +# Cleaning legacy permissions +if ynh_legacy_permissions_exists; then + ynh_legacy_permissions_delete_all + + ynh_app_setting_delete --app=$app --key=is_public +fi + +# Create a permission if needed +if ! ynh_permission_exists --permission="api"; then + ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --auth_header="false" --show_tile="false" --protected="true" +fi + +#Switch variables name +psql_db=$(ynh_app_setting_get --app=$app --key=psql_db) + +if [ -n "$psql_db" ] +then + db_name=$(ynh_app_setting_get --app=$app --key=psql_db) + db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) + ynh_app_setting_set --app=$app --key=db_name --value=$db_name + ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd + ynh_app_setting_delete --app=$app --key=psql_db + ynh_app_setting_delete --app=$app --key=psqlpwd +fi + +#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 + +# Remove old repository +ynh_secure_remove --file="/etc/apt/sources.list.d/erlang-solutions.list" +apt-key del A14F4FCA + #================================================= # CREATE DEDICATED USER #================================================= ynh_script_progression --message="Making sure dedicated system user exists..." # Create a dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir="$final_path" +ynh_system_user_create --username=$app --home_dir=$final_path #================================================= # UPGRADE TO OTP RELEASE @@ -217,19 +216,10 @@ fi #================================================= ynh_script_progression --message="Upgrading dependencies..." -ynh_install_app_dependencies $pkg_dependencies +ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies #================================================= # SPECIFIC UPGRADE -#================================================= -# UPDATE A CONFIG FILE -#================================================= -ynh_script_progression --message="Updating a config file..." - -config="/etc/$app/config.exs" - -ynh_backup_if_checksum_is_different --file="$config" - #================================================= # MAKE UPGRADE #================================================= @@ -240,12 +230,13 @@ pushd $final_path/$app popd #================================================= -# STORE THE CONFIG FILE CHECKSUM +# UPDATE A CONFIG FILE #================================================= -ynh_script_progression --message="Storing the config file checksum..." +ynh_script_progression --message="Updating a configuration file..." -# Recalculate and store the checksum of the file for the next upgrade. -ynh_store_file_checksum --file="$config" +config="/etc/$app/config.exs" + +ynh_backup_if_checksum_is_different --file="$config" chmod 400 "$config" chown $app:$app "$config"