diff options
| -rw-r--r-- | README.md | 90 | ||||
| -rw-r--r-- | README_fr.md | 103 | ||||
| -rw-r--r-- | conf/app-mastodon.src | 4 | ||||
| -rw-r--r-- | conf/app-ruby-build.src | 4 | ||||
| -rw-r--r-- | manifest.json | 8 | ||||
| -rw-r--r-- | scripts/_common.sh | 18 | ||||
| -rw-r--r-- | scripts/backup | 14 | ||||
| -rw-r--r-- | scripts/install | 33 | ||||
| -rw-r--r-- | scripts/remove | 49 | ||||
| -rw-r--r-- | scripts/restore | 21 | ||||
| -rw-r--r-- | scripts/upgrade | 91 |
11 files changed, 334 insertions, 101 deletions
@@ -1,5 +1,13 @@ # Mastodon for YunoHost +[](https://dash.yunohost.org/appci/app/mastodon) +[](https://install-app.yunohost.org/?app=mastodon) + +*[Lire ce readme en français.](./README_fr.md)* + +> *This package allow you to install mastodon quickly and simply on a YunoHost server. +If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.* + [](https://github.com/YunoHost-Apps/mastodon_ynh/releases) [](https://github.com/YunoHost-Apps/mastodon_ynh/milestones) [](https://github.com/YunoHost-Apps/mastodon_ynh#dependencies) @@ -7,59 +15,22 @@ [](https://github.com/YunoHost/yunohost) [](https://github.com/YunoHost-Apps/mastodon_ynh/issues) -[](https://install-app.yunohost.org/?app=mastodon) - -:warning: MAJ 05/06/17 :Cette application peut maintenant fonctionner sur ARM, mais l'installation prend plusieurs heures et il faut ajouter un swapfile de 1Go. - -:warning: Cette application utilise les packages backports de Debian, nous vous recommendons de ne pas installer cette application directement en production - :warning: UPDATE 05/06/17 :This app can work now on ARM, but installation takes several hours and you must add a swapfile of 1GB. :warning: This application uses the Debian backports packages, do not install this application directly in production -## Mastodon c'est quoi ? - -Mastodon est un réseau social gratuit et open source. Une alternative décentralisée aux plates-formes commerciales, elle évite les risques d'une seule société qui monopolise votre communication. Choisissez un serveur sur lequel vous faites confiance - selon votre choix, vous pouvez interagir avec tous les autres. N'importe qui peut exécuter sa propre instance de Mastodon et participer au réseau social de façon transparente. - -[Source code](https://github.com/tootsuite/mastodon) - -#### Ajout d'un "swapfile" si vous avez moins de 2Go de RAM -``` -sudo dd if=/dev/zero of=/swapfile bs=1024 count=1024000 -sudo chmod 600 /swapfile -sudo mkswap /swapfile -sudo swapon /swapfile -``` -ajouter cette ligne dans /etc/fstab -``` -/swapfile none swap sw 0 0 -``` - -### Installation +## Overview -#### Utilisation de __screen__ en cas de déconnection -``` -$ sudo apt-get install screen -$ screen -$ sudo yunohost app install https://github.com/YunoHost-Apps/mastodon_ynh.git -``` -Récuperer l'installation après une deconnection: -``` -$ screen -d -$ screen -r -``` -L'utilisateur admin est crée automatiquement comme: user@domain.tld +**Shipped version:** 2.7.4 -### Mise à jour -#### Utilisation de __screen__ fortement recommandé +## Screenshots -`$ sudo yunohost app upgrade --verbose mastodon -u https://github.com/YunoHost-Apps/mastodon_ynh.git` + -## Recommandations -Vous ne pouvez pas installer Mastodon en subdirectory, vous devez obligatoirement utiliser un domaine ou un sous-domaine pour cette application. +[Source code](https://github.com/tootsuite/mastodon) -Il semble important de fermer les inscriptions pour votre Mastodon, pour que ça reste une instance privé. Nous vous invitons à bloquer les instances distantes malfaisantes depuis l'interface d'administration. Vous pouvez également ajouter un texte sur votre page d'accueil dans l'administration. +## Configuration ## What is Mastodon? @@ -103,3 +74,36 @@ The admin user is automatically created as: user@domain.tld You can't install Mastodon in subdirectory, you must use a domain or subdomain for this application. It seems important to close the inscriptions for your Mastodon, so that it remains a private body. We invite you to block remote malicious instances from the administration interface. You can also add text on your home page. + +## Documentation + + * Official documentation: https://docs.joinmastodon.org/ + +## YunoHost specific features + +#### Supported architectures + +* x86-64b - [](https://ci-apps.yunohost.org/ci/apps/mastodon/) +* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/mastodon/) +* Jessie x86-64b - [](https://ci-stretch.nohost.me/ci/apps/mastodon/) + +## Links + + * Report a bug: https://github.com/YunoHost-Apps/mastodon_ynh/issues + * App website: Link to the official website of this app + * YunoHost website: https://yunohost.org/ + +--- + +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/mastodon_ynh/tree/testing). + +To try the testing branch, please proceed like that. +``` +sudo yunohost app install https://github.com/YunoHost-Apps/mastodon_ynh/tree/testing --debug +or +sudo yunohost app upgrade mastodon -u https://github.com/YunoHost-Apps/mastodon_ynh/tree/testing --debug +``` diff --git a/README_fr.md b/README_fr.md new file mode 100644 index 0000000..4f753ea --- /dev/null +++ b/README_fr.md @@ -0,0 +1,103 @@ +# Mastodon pour YunoHost + +[](https://dash.yunohost.org/appci/app/mastodon) +[](https://install-app.yunohost.org/?app=mastodon) + +*[Read this readme in english.](./README.md)* + +> *Ce package vous permet d'installer mastodon 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.* + +[](https://github.com/YunoHost-Apps/mastodon_ynh/releases) +[](https://github.com/YunoHost-Apps/mastodon_ynh/milestones) +[](https://github.com/YunoHost-Apps/mastodon_ynh#dependencies) +[](https://raw.githubusercontent.com/YunoHost-Apps/mastodon_ynh/master/LICENSE) +[](https://github.com/YunoHost/yunohost) +[](https://github.com/YunoHost-Apps/mastodon_ynh/issues) + +:warning: MAJ 05/06/17 :Cette application peut maintenant fonctionner sur ARM, mais l'installation prend plusieurs heures et il faut ajouter un swapfile de 1Go. + +:warning: Cette application utilise les packages backports de Debian, nous vous recommendons de ne pas installer cette application directement en production + +## Vue d'ensemble +Mastodon est un réseau social gratuit et open source. Une alternative décentralisée aux plates-formes commerciales, elle évite les risques d'une seule société qui monopolise votre communication. Choisissez un serveur sur lequel vous faites confiance - selon votre choix, vous pouvez interagir avec tous les autres. N'importe qui peut exécuter sa propre instance de Mastodon et participer au réseau social de façon transparente. + +**Version incluse:** 2.7.4 + +## Captures d'écran + + + +## Configuration + +#### Ajout d'un "swapfile" si vous avez moins de 2Go de RAM +``` +sudo dd if=/dev/zero of=/swapfile bs=1024 count=1024000 +sudo chmod 600 /swapfile +sudo mkswap /swapfile +sudo swapon /swapfile +``` +ajouter cette ligne dans /etc/fstab +``` +/swapfile none swap sw 0 0 +``` + +### Installation + +#### Utilisation de __screen__ en cas de déconnection +``` +$ sudo apt-get install screen +$ screen +$ sudo yunohost app install https://github.com/YunoHost-Apps/mastodon_ynh.git +``` +Récuperer l'installation après une deconnection: +``` +$ screen -d +$ screen -r +``` +L'utilisateur admin est crée automatiquement comme: user@domain.tld + +### Mise àjour +#### Utilisation de __screen__ fortement recommandé + +`$ sudo yunohost app upgrade --verbose mastodon -u https://github.com/YunoHost-Apps/mastodon_ynh.git` + +## Recommandations + +Vous ne pouvez pas installer Mastodon en subdirectory, vous devez obligatoirement utiliser un domaine ou un sous-domaine pour cette application. + +Il semble important de fermer les inscriptions pour votre Mastodon, pour que ça reste une instance privé. Nous vous invitons àbloquer les instances distantes malfaisantes depuis l'interface d'administration. Vous pouvez également ajouter un texte sur votre page d'accueil dans l'administration. + +## Documentation + + * Documentation officielle: https://docs.joinmastodon.org/ + * Documentation YunoHost: Si une documentation spécifique est nécessaire, n'hésitez pas à contribuer. + +## Caractéristiques spécifiques YunoHost + +#### Supported architectures + +* x86-64b - [](https://ci-apps.yunohost.org/ci/apps/mastodon/) +* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/mastodon/) +* Jessie x86-64b - [](https://ci-stretch.nohost.me/ci/apps/mastodon/) + +## Links + + * Signaler un bug: https://github.com/YunoHost-Apps/mastodon_ynh/issues + * Site de l'application: Lien vers le site officiel de cette application + * Site web YunoHost: https://yunohost.org/ + +--- + +Informations pour les développeurs +---------------- + +**Seulement si vous voulez utiliser une branche de test pour le codage, au lieu de fusionner directement dans la banche principale.** +Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/mastodon_ynh/tree/testing). + +Pour essayer la branche testing, procédez comme suit. +``` +sudo yunohost app install https://github.com/YunoHost-Apps/mastodon_ynh/tree/testing --debug +ou +sudo yunohost app upgrade mastodon -u https://github.com/YunoHost-Apps/mastodon_ynh/tree/testing --debug +``` diff --git a/conf/app-mastodon.src b/conf/app-mastodon.src index 4c68e9c..9d7227b 100644 --- a/conf/app-mastodon.src +++ b/conf/app-mastodon.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/tootsuite/mastodon/archive/v2.7.1.tar.gz -SOURCE_SUM=d0a9d6f4514f78fcdc76943ce2518ce5008378c65b5ecbb3644026dc97c18ec1 +SOURCE_URL=https://github.com/tootsuite/mastodon/archive/v2.7.4.tar.gz +SOURCE_SUM=0e542c57228d482a068b05f639d8fe53dd9d413f7e7ce93cd1a088bd4d8d8366 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/conf/app-ruby-build.src b/conf/app-ruby-build.src index b32b7b9..5df8367 100644 --- a/conf/app-ruby-build.src +++ b/conf/app-ruby-build.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/rbenv/ruby-build/archive/v20181225.tar.gz -SOURCE_SUM=5ace4787ace47384dc419b20f5eb5a59f1174e00bfabcfed74a175033cd0b18a +SOURCE_URL=https://github.com/rbenv/ruby-build/archive/v20190314.tar.gz +SOURCE_SUM=2cc0f9fdb232042e71edad93a5c3ae108bcd090ea0b6db4e5bb6325547e07968 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index 3c06f54..db8924e 100644 --- a/manifest.json +++ b/manifest.json @@ -2,20 +2,20 @@ "name": "Mastodon", "id": "mastodon", "packaging_format": 1, - "requirements": { - "yunohost": ">= 2.7.1" - }, "description": { "en": "Mastodon is a free, open-source social network.", "fr": "Mastodon est un réseau social gratuit et open source." }, - "version": "2.6.5", + "version": "2.7.4", "url": "https://github.com/tootsuite/mastodon", "license": "AGPL-3.0-or-later", "maintainer": { "name": "cyp, nemsia", "email": "cyp@rouquin.me, nemsia@nemsia.org" }, + "requirements": { + "yunohost": ">= 3.4" + }, "multi_instance": false, "services": [ "nginx" diff --git a/scripts/_common.sh b/scripts/_common.sh index 7def11e..4e04181 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,5 +1,23 @@ #!/bin/bash +#================================================= +# COMMON VARIABLES +#================================================= + +# dependencies used by the app +pkg_dependencies="deb1 deb2" + +#================================================= +# PERSONAL HELPERS +#================================================= + +#================================================= +# EXPERIMENTAL HELPERS +#================================================= + +#================================================= +# FUTURE OFFICIAL HELPERS +#================================================= # Execute a command as another user # usage: exec_as USER COMMAND [ARG ...] diff --git a/scripts/backup b/scripts/backup index eeee720..5e57cd7 100644 --- a/scripts/backup +++ b/scripts/backup @@ -26,8 +26,8 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= +ynh_print_info "Loading installation settings..." -# Get multi-instances specific variables app=$YNH_APP_INSTANCE_NAME # Retrieve app settings @@ -47,18 +47,21 @@ yunohost service stop "$app-streaming" #================================================= # BACKUP THE APP MAIN DIR #================================================= +ynh_print_info "Backing up the main app directory..." ynh_backup "$final_path" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= +ynh_print_info "Backing up nginx web server configuration..." ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= -# BACKUP THE MYSQL DATABASE +# BACKUP THE POSTGRESQL DATABASE #================================================= +ynh_print_info "Backing up the PostgreSQL database..." ynh_psql_dump_db "$db_name" > db.sql ynh_backup "db.sql" @@ -68,6 +71,7 @@ ynh_backup "db.sql" #================================================= # BACKUP SYSTEMD #================================================= +ynh_print_info "Backing up systemd configuration..." ynh_backup "/etc/systemd/system/$app-web.service" ynh_backup "/etc/systemd/system/$app-sidekiq.service" @@ -97,3 +101,9 @@ sleep 30 #================================================= systemctl reload nginx + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/install b/scripts/install index 3680b03..026737e 100644 --- a/scripts/install +++ b/scripts/install @@ -17,25 +17,26 @@ source _future.sh # Exit if an error occurs during the execution of the script ynh_abort_if_errors - #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST -#================================================ +#================================================= domain=$YNH_APP_ARG_DOMAIN +path_url="/" admin_mastodon=$YNH_APP_ARG_ADMIN -admin_mastodon_mail=$(ynh_user_get_info $admin_mastodon 'mail') language=$YNH_APP_ARG_LANGUAGE + +admin_mastodon_mail=$(ynh_user_get_info $admin_mastodon 'mail') port_web=$(ynh_find_port 3000) port_stream=$(ynh_find_port 4000) -path_url="/" app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= +ynh_print_info "Validating installation parameters..." final_path=/var/www/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" @@ -51,6 +52,7 @@ ynh_webpath_register $app $domain $path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= +ynh_print_info "Storing installation settings..." ynh_app_setting_set $app domain $domain ynh_app_setting_set $app admin $admin_mastodon @@ -67,6 +69,7 @@ ynh_app_setting_set $app port_stream $port_stream #================================================= # INSTALL DEPENDENCIES #================================================= +ynh_print_info "Installing dependencies..." # TODO: add in a clean way backports and yarn @@ -103,9 +106,11 @@ ynh_install_app_dependencies \ `# Yarn ` \ yarn + #================================================= -# DATABASE SETUP +# CREATE A POSTGRESQL DATABASE #================================================= +ynh_print_info "Creating a PostgreSQL database..." # Create postgresql database db_name="${app}_production" @@ -120,6 +125,7 @@ ynh_psql_execute_as_root \ #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +ynh_print_info "Setting up source files..." # Creates the destination directory and stores its location. ynh_app_setting_set "$app" final_path "$final_path" @@ -132,6 +138,7 @@ ynh_setup_source "$final_path/live" "app-mastodon" #================================================= # NGINX CONFIGURATION #================================================= +ynh_print_info "Configuring nginx web server..." # Create a dedicated nginx config ynh_replace_string "__PORT_WEB__" "$port_web" "../conf/nginx.conf" @@ -141,12 +148,19 @@ ynh_add_nginx_config #================================================= # CREATE DEDICATED USER #================================================= +ynh_print_info "Configuring system user..." # Create a system user adduser $app --home $final_path --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --disabled-password chown -R "$app": "$final_path" +#================================================= +# SPECIFIC SETUP +#================================================= +# ... +#================================================= + # TODO: try to use ynh_install_ruby from https://github.com/YunoHost-Apps/Experimental_helpers # Install de rbenv ( @@ -242,6 +256,7 @@ SETADMIN admin_pass=$( cd $final_path/live && tail -1 acc.txt | head -1 | cut -c 15- ) (cd $final_path/live && rm -f acc.txt) + #================================================= # GENERIC FINALIZATION #================================================= @@ -268,6 +283,7 @@ sudo cp -f ../conf/cron /etc/cron.d/$app #================================================= # SETUP SSOWAT #================================================= +ynh_print_info "Configuring SSOwat..." # TODO: all private install # Unprotected url @@ -276,6 +292,7 @@ ynh_app_setting_set "$app" unprotected_uris "/" #================================================= # RELOAD NGINX #================================================= +ynh_print_info "Reloading nginx web server..." # Reload Nginx systemctl reload nginx @@ -291,3 +308,9 @@ The admin password is: $admin_pass If you facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/mastodon_ynh" ynh_send_readme_to_admin "$message" "$admin_mastodon" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index 6d6679b..13f9775 100644 --- a/scripts/remove +++ b/scripts/remove @@ -15,6 +15,7 @@ source _future.sh #================================================= # LOAD SETTINGS #================================================= +ynh_print_info "Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -26,16 +27,8 @@ final_path=$(ynh_app_setting_get "$app" final_path) #================================================= # STANDARD REMOVE #================================================= -# STOP AND REMOVE SERVICE -#================================================= - -ynh_remove_systemd_config "$app-web" -ynh_remove_systemd_config "$app-sidekiq" -ynh_remove_systemd_config "$app-streaming" - -#================================================= # REMOVE SERVICE FROM ADMIN PANEL -#============================================== +#================================================= if yunohost service status | grep -q "$app-web" then @@ -56,22 +49,36 @@ then fi #================================================= -# REMOVE DEPENDENCIES +# STOP AND REMOVE SERVICE #================================================= +ynh_print_info "Stopping and removing the systemd service" + +# Remove the dedicated systemd config +ynh_remove_systemd_config "$app-web" +ynh_remove_systemd_config "$app-sidekiq" +ynh_remove_systemd_config "$app-streaming" -# Remove metapackage and its dependencies -ynh_remove_app_dependencies -ynh_remove_nodejs #================================================= -# REMOVE THE PostgreSQL DATABASE +# REMOVE THE POSTGRESQL DATABASE #================================================= +ynh_print_info "Removing the PostgreSQL database" # delete postgresql database & user ynh_psql_remove_db "$db_name" "$app" #================================================= +# REMOVE DEPENDENCIES +#================================================= +ynh_print_info "Removing dependencies" + +# Remove metapackage and its dependencies +ynh_remove_app_dependencies +ynh_remove_nodejs + +#================================================= # REMOVE APP MAIN DIR #================================================= +ynh_print_info "Removing app main directory" # Remove the app directory securely ynh_secure_remove "$final_path" @@ -79,11 +86,16 @@ ynh_secure_remove "$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= +ynh_print_info "Removing nginx web server configuration" + +# Remove the dedicated nginx config ynh_remove_nginx_config #================================================= # SPECIFIC REMOVE #================================================= +# REMOVE THE CRON FILE +#================================================= # Remove a cron file ynh_secure_remove "/etc/cron.d/$app" @@ -96,4 +108,13 @@ ynh_secure_remove "/etc/cron.d/$app" #================================================= # REMOVE DEDICATED USER #================================================= +ynh_print_info "Removing the dedicated system user" + +# Delete a system user ynh_system_user_delete $app + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index 822f8fc..1b9537c 100644 --- a/scripts/restore +++ b/scripts/restore @@ -26,10 +26,10 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= +ynh_print_info "Loading settings..." app=$YNH_APP_INSTANCE_NAME -# Get old parameter of the app domain=$(ynh_app_setting_get $app domain) path_url=$(ynh_app_setting_get $app path) is_public=$(ynh_app_setting_get $app is_public) @@ -38,6 +38,7 @@ final_path=$(ynh_app_setting_get "$app" final_path) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= +ynh_print_info "Validating restoration parameters..." ynh_webpath_available $domain $path_url \ || ynh_die "Path not available: ${domain}${path_url}" @@ -55,12 +56,14 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE APP MAIN DIR #================================================= +ynh_print_info "Restoring the app main directory..." ynh_restore_file "$final_path" #================================================= # RECREATE THE DEDICATED USER #================================================= +ynh_print_info "Recreating the dedicated system user..." adduser $app --home $final_path --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --disabled-password @@ -76,6 +79,7 @@ chown -R $app: $final_path #================================================= # REINSTALL DEPENDENCIES #================================================= +ynh_print_info "Reinstalling dependencies..." # TODO: add in a clean way backports and yarn @@ -113,10 +117,9 @@ ynh_install_app_dependencies \ yarn #================================================= -# RESTORE THE PostgreSQL DATABASE +# RESTORE THE POSTGRESQL DATABASE #================================================= - -# Restore PostgreSQL database +ynh_print_info "Restoring the PostgreSQL database..." db_name=$(ynh_app_setting_get "$app" db_name) db_pwd=$(ynh_app_setting_get "$app" db_pwd) @@ -132,6 +135,7 @@ ynh_psql_execute_file_as_root ./db.sql "$db_name" #================================================= # RESTORE SYSTEMD #================================================= +ynh_print_info "Restoring the systemd configuration..." ynh_restore_file "/etc/systemd/system/$app-web.service" ynh_restore_file "/etc/systemd/system/$app-sidekiq.service" @@ -155,10 +159,17 @@ ynh_restore_file "/etc/cron.d/$app" #================================================= # GENERIC FINALIZATION #================================================= -# RELOAD NGINX AND services +# RELOAD NGINX AND SERVICES #================================================= +ynh_print_info "Reloading nginx web server and services..." systemctl restart "$app-web" "$app-sidekiq" "$app-streaming" # Waiting start all services sleep 30 systemctl reload nginx + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index 85fb1f4..d9e4cac 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= +ynh_print_info "Loading installation settings..." # See comments in install script app=$YNH_APP_INSTANCE_NAME @@ -31,6 +32,7 @@ port_stream=$(ynh_app_setting_get "$app" port_stream) #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= +ynh_print_info "Ensuring downward compatibility..." # If db_name doesn't exist, create it if [ -z "$db_name" ]; then @@ -62,6 +64,7 @@ fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= +ynh_print_info "Backing up the app before upgrading (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade @@ -85,27 +88,6 @@ fi echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list #================================================= -# INSTALL DEPENDENCIES -#================================================= - -ynh_install_nodejs 8 - -# TODO: use the same mecanism with other files -ynh_install_app_dependencies \ - `# debian packages ` \ - imagemagick libpq-dev libxml2-dev libxslt1-dev file curl apt-transport-https pkg-config libprotobuf-dev protobuf-compiler libicu-dev libidn11-dev \ - `# redis ` \ - redis-server redis-tools \ - `# postgresql ` \ - postgresql postgresql-contrib \ - `# Ruby ` \ - autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev \ - `# ffmpeg from backports ` \ - ffmpeg \ - `# Yarn ` \ - yarn - -#================================================= # STANDARD UPGRADE STEPS #================================================= @@ -116,6 +98,11 @@ yunohost service stop "$app-web" yunohost service stop "$app-sidekiq" yunohost service stop "$app-streaming" +#================================================= +# DOWNLOAD, CHECK AND UNPACK SOURCE +#================================================= +ynh_print_info "Upgrading source files..." + # Download Mastodon mv "$final_path/live" "$final_path/live_back" ynh_setup_source "$final_path/live" "app-mastodon" @@ -131,6 +118,8 @@ ynh_secure_remove $final_path/live/config/initializers/timeout.rb #================================================= # NGINX CONFIGURATION #================================================= +ynh_print_info "Upgrading nginx web server configuration..." + ynh_replace_string "__PORT_WEB__" "$port_web" "../conf/nginx.conf" ynh_replace_string "__PORT_STREAM__" "$port_stream" "../conf/nginx.conf" ynh_add_nginx_config @@ -142,6 +131,42 @@ ynh_setup_source "$final_path/.rbenv/plugins/ruby-build" "app-ruby-build" chown -R "$app": "$final_path" +#================================================= +# UPGRADE DEPENDENCIES +#================================================= +ynh_print_info "Upgrading dependencies..." + +ynh_install_nodejs 8 + +# TODO: use the same mecanism with other files +ynh_install_app_dependencies \ + `# debian packages ` \ + imagemagick libpq-dev libxml2-dev libxslt1-dev file curl apt-transport-https pkg-config libprotobuf-dev protobuf-compiler libicu-dev libidn11-dev \ + `# redis ` \ + redis-server redis-tools \ + `# postgresql ` \ + postgresql postgresql-contrib \ + `# Ruby ` \ + autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev \ + `# ffmpeg from backports ` \ + ffmpeg \ + `# Yarn ` \ + yarn + +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_print_info "Making sure dedicated system user exists..." + +# Create a dedicated user (if not existing) +ynh_system_user_create $app + +#================================================= +# SPECIFIC UPGRADE +#================================================= +# ... +#================================================= + # Install ruby 2.6.0 ( exec_as "$app" $final_path/.rbenv/bin/rbenv install -s 2.6.0 || true @@ -193,6 +218,7 @@ chown -R "$app": "$final_path" #================================================= # SETUP SYSTEMD #================================================= +ynh_print_info "Upgrading systemd configuration..." # Create a dedicated systemd config ynh_replace_string "__PORT_WEB__" "$port_web" "../conf/mastodon-web.service" @@ -225,19 +251,36 @@ ynh_replace_string "__USER__" "$app" ../conf/cron sudo cp -f ../conf/cron /etc/cron.d/$app #================================================= -# RELOAD NGINX +# GENERIC FINALIZATION +#================================================= +# SECURE FILES AND DIRECTORIES #================================================= -systemctl reload nginx +# Set permissions on app files +#chown -R root: $final_path #================================================= # SETUP SSOWAT #================================================= +ynh_print_info "Upgrading SSOwat configuration..." ynh_app_setting_set "$app" unprotected_uris "/" #================================================= -# RELOAD ssowatconf +# RELOAD SSOWATCONF #================================================= sudo yunohost app ssowatconf + +#================================================= +# RELOAD NGINX +#================================================= +ynh_print_info "Reloading nginx web server..." + +systemctl reload nginx + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Upgrade of $app completed" |
