diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh deleted file mode 100644 index 1aeb2f1..0000000 --- a/.github/workflows/updater.sh +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/bash - -#================================================= -# PACKAGE UPDATING HELPER -#================================================= - -# This script is meant to be run by GitHub Actions -# The YunoHost-Apps organisation offers a template Action to run this script periodically -# Since each app is different, maintainers can adapt its contents so as to perform -# automatic actions when a new upstream release is detected. - -#================================================= -# FETCHING LATEST RELEASE AND ITS ASSETS -#================================================= - -# Fetching information -current_version=$(cat manifest.json | jq -j '.version|split("~")[0]') -repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]') -# Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions) -version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1) -version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .tag_name | contains("v") | not ) | .tag_name' | sort -V | tail -1) - -# Later down the script, we assume the version has only digits and dots -# Sometimes the release name starts with a "v", so let's filter it out. -# You may need more tweaks here if the upstream repository has different naming conventions. -if [[ ${version:0:1} == "v" || ${version:0:1} == "V" ]]; then - version=${version:1} -fi - -# Setting up the environment variables -echo "Current version: $current_version" -echo "Latest release from upstream: $version" -echo "VERSION=$version" >> $GITHUB_ENV -echo "REPO=$repo" >> $GITHUB_ENV -# For the time being, let's assume the script will fail -echo "PROCEED=false" >> $GITHUB_ENV - -# Proceed only if the retrieved version is greater than the current one -if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then - echo "::warning ::No new version available" - exit 0 -# Proceed only if a PR for this new version does not already exist -elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.git ci-auto-update-v$version ; then - echo "::warning ::A branch already exists for this update" - exit 0 -fi - -#================================================= -# SPECIFIC UPDATE STEPS -#================================================= - -# Any action on the app's source code can be done. -# The GitHub Action workflow takes care of committing all changes after this script ends. - -#================================================= -# GENERIC FINALIZATION -#================================================= - -# Replace new version in manifest -echo "$(jq -s --indent 4 ".[] | .version = \"$version~ynh1\"" manifest.json)" > manifest.json - -# No need to update the README, yunohost-bot takes care of it - -# The Action will proceed only if the PROCEED environment variable is set to true -echo "PROCEED=true" >> $GITHUB_ENV -exit 0 diff --git a/.github/workflows/updater.yml b/.github/workflows/updater.yml deleted file mode 100644 index fb72ba0..0000000 --- a/.github/workflows/updater.yml +++ /dev/null @@ -1,49 +0,0 @@ -# This workflow allows GitHub Actions to automagically update your app whenever a new upstream release is detected. -# You need to enable Actions in your repository settings, and fetch this Action from the YunoHost-Apps organization. -# This file should be enough by itself, but feel free to tune it to your needs. -# It calls updater.sh, which is where you should put the app-specific update steps. -name: Check for new upstream releases -on: - # Allow to manually trigger the workflow - workflow_dispatch: - # Run it every day at 6:00 UTC - schedule: - - cron: '0 6 * * *' -jobs: - updater: - runs-on: ubuntu-latest - steps: - - name: Fetch the source code - uses: actions/checkout@v2 - with: - token: ${{ secrets.GITHUB_TOKEN }} - - name: Run the updater script - id: run_updater - run: | - # Setting up Git user - git config --global user.name 'yunohost-bot' - git config --global user.email 'yunohost-bot@users.noreply.github.com' - # Run the updater script - /bin/bash .github/workflows/updater.sh - - name: Commit changes - id: commit - if: ${{ env.PROCEED == 'true' }} - run: | - git commit -am "Upgrade to v$VERSION" - - name: Create Pull Request - id: cpr - if: ${{ env.PROCEED == 'true' }} - uses: peter-evans/create-pull-request@v3 - with: - token: ${{ secrets.GITHUB_TOKEN }} - commit-message: Update to version ${{ env.VERSION }} - committer: 'yunohost-bot ' - author: 'yunohost-bot ' - signoff: false - base: testing - branch: ci-auto-update-v${{ env.VERSION }} - delete-branch: true - title: 'Upgrade to version ${{ env.VERSION }}' - body: | - Upgrade to v${{ env.VERSION }} - draft: false diff --git a/README.md b/README.md index 5a4fe84..fcc2648 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,8 @@ It shall NOT be edited by hand. # Lemmy for YunoHost -[![Integration level](https://dash.yunohost.org/integration/lemmy.svg)](https://dash.yunohost.org/appci/app/lemmy) ![Working status](https://ci-apps.yunohost.org/ci/badges/lemmy.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/lemmy.maintain.svg) +[![Integration level](https://dash.yunohost.org/integration/lemmy.svg)](https://dash.yunohost.org/appci/app/lemmy) ![Working status](https://ci-apps.yunohost.org/ci/badges/lemmy.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/lemmy.maintain.svg) + [![Install Lemmy with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=lemmy) *[Lire ce readme en français.](./README_fr.md)* @@ -15,23 +16,17 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in ## Overview -[Lemmy](https://github.com/LemmyNet/lemmy) is similar to sites like [Reddit](https://reddit.com), [Lobste.rs](https://lobste.rs), or [Hacker News](https://news.ycombinator.com/): you subscribe to forums you're interested in, post links and discussions, then vote, and comment on them. Behind the scenes, it is very different; anyone can easily run a server, and all these servers are federated (think email), and connected to the same universe, called the [Fediverse](https://en.wikipedia.org/wiki/Fediverse). +Lemmy is similar to sites like Reddit, Lobste.rs, or Hacker News: you subscribe to forums you're interested in, post links and discussions, then vote, and comment on them. Behind the scenes, it is very different; anyone can easily run a server, and all these servers are federated (think email), and connected to the same universe, called the Fediverse. **Shipped version:** 0.16.7~ynh1 - **Demo:** https://lemmy.ml/ ## Screenshots ![Screenshot of Lemmy](./doc/screenshots/screenshot1.webp) -## Disclaimers / important information - -* Lemmy require full domain path to be installed. Eg. lemmy.domain.tld -* pict-rs image hosting service has been removed, it caused too much issue during compilation - ## Documentation and resources * Official app website: diff --git a/README_fr.md b/README_fr.md index 0d70934..a5565f9 100644 --- a/README_fr.md +++ b/README_fr.md @@ -5,38 +5,33 @@ It shall NOT be edited by hand. # Lemmy pour YunoHost -[![Niveau d'intégration](https://dash.yunohost.org/integration/lemmy.svg)](https://dash.yunohost.org/appci/app/lemmy) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/lemmy.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/lemmy.maintain.svg) +[![Niveau d’intégration](https://dash.yunohost.org/integration/lemmy.svg)](https://dash.yunohost.org/appci/app/lemmy) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/lemmy.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/lemmy.maintain.svg) + [![Installer Lemmy avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=lemmy) *[Read this readme in english.](./README.md)* -> *Ce package vous permet d'installer Lemmy 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.* +> *Ce package vous permet d’installer Lemmy 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 +## Vue d’ensemble -[Lemmy](https://github.com/LemmyNet/lemmy) is similar to sites like [Reddit](https://reddit.com), [Lobste.rs](https://lobste.rs), or [Hacker News](https://news.ycombinator.com/): you subscribe to forums you're interested in, post links and discussions, then vote, and comment on them. Behind the scenes, it is very different; anyone can easily run a server, and all these servers are federated (think email), and connected to the same universe, called the [Fediverse](https://en.wikipedia.org/wiki/Fediverse). +Lemmy is similar to sites like Reddit, Lobste.rs, or Hacker News: you subscribe to forums you're interested in, post links and discussions, then vote, and comment on them. Behind the scenes, it is very different; anyone can easily run a server, and all these servers are federated (think email), and connected to the same universe, called the Fediverse. -**Version incluse :** 0.16.7~ynh1 - +**Version incluse :** 0.16.7~ynh1 **Démo :** https://lemmy.ml/ -## Captures d'écran +## Captures d’écran -![Capture d'écran de Lemmy](./doc/screenshots/screenshot1.webp) - -## Avertissements / informations importantes - -* Lemmy require full domain path to be installed. Eg. lemmy.domain.tld -* pict-rs image hosting service has been removed, it caused too much issue during compilation +![Capture d’écran de Lemmy](./doc/screenshots/screenshot1.webp) ## Documentations et ressources -* Site officiel de l'app : -* Documentation officielle de l'admin : -* Dépôt de code officiel de l'app : +* Site officiel de l’app : +* Documentation officielle de l’admin : +* Dépôt de code officiel de l’app : * Documentation YunoHost pour cette app : * Signaler un bug : @@ -52,4 +47,4 @@ ou sudo yunohost app upgrade lemmy -u https://github.com/YunoHost-Apps/lemmy_ynh/tree/testing --debug ``` -**Plus d'infos sur le packaging d'applications :** +**Plus d’infos sur le packaging d’applications :** \ No newline at end of file diff --git a/check_process b/check_process deleted file mode 100644 index 3fe9751..0000000 --- a/check_process +++ /dev/null @@ -1,27 +0,0 @@ -;; Test complet - ; Manifest - domain="domain.tld" - path="/" - admin="john" - sitename="lemmy website" - ; Checks - pkg_linter=1 - setup_sub_dir=0 - setup_root=1 - setup_nourl=0 - setup_private=0 - setup_public=1 - upgrade=1 - # 0.15.2~ynh3 - upgrade=1 from_commit=206df4db0b99c52f07ea1a2d5daf799d4b8357fd - backup_restore=1 - multi_instance=0 - port_already_use=0 - change_url=0 -;;; Options -Email= -Notification=none -;;; Upgrade options - ; commit=206df4db0b99c52f07ea1a2d5daf799d4b8357fd - name=0.15.2~ynh3 - manifest_arg=domain=DOMAIN&admin=USER&sitename=lemmy_website& diff --git a/conf/docker-image-extract.src b/conf/docker-image-extract.src deleted file mode 100644 index 64fe1a1..0000000 --- a/conf/docker-image-extract.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://codeload.github.com/jjlin/docker-image-extract/tar.gz/a9e455e44bbbfba897bf3342d9661b182cee67a9 -SOURCE_SUM=9eb0c734e83a3fd7102fc7209af4977024ec467fbc819782491af47295675f67 -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= -SOURCE_EXTRACT=true diff --git a/conf/lemmy-translations.src b/conf/lemmy-translations.src deleted file mode 100644 index 87b40c6..0000000 --- a/conf/lemmy-translations.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://codeload.github.com/LemmyNet/lemmy-translations/tar.gz/00e4efbef6c3ac34cd2f5f444a95eddce9ec12d7 -SOURCE_SUM=0587c1867c785e6d229d1519a37fc9a280e78f356d919f868f21a896abddff71 -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= -SOURCE_EXTRACT=true diff --git a/conf/lemmy-ui.service b/conf/lemmy-ui.service index 45da3dc..0b0c0c6 100644 --- a/conf/lemmy-ui.service +++ b/conf/lemmy-ui.service @@ -1,16 +1,16 @@ [Unit] -Description=__APP__ UI Daemon +Description=Lemmy: UI Daemon After=network.target [Service] Type=simple User=__APP__ Group=__APP__ -Environment="LEMMY_INTERNAL_HOST=127.0.0.1:__PORT_LEMMY__" +Environment="LEMMY_INTERNAL_HOST=127.0.0.1:__PORT__" Environment="LEMMY_EXTERNAL_HOST=__DOMAIN__" Environment="LEMMY_HTTPS=true" Environment="LEMMY_UI_HOST=0.0.0.0:__PORT_UI__" -WorkingDirectory=__FINALPATH__/lemmy-ui/ +WorkingDirectory=__INSTALL_DIR__/lemmy-ui/ ExecStart=__YNH_NODE__ dist/js/server.js StandardOutput=append:/var/log/__APP__/__APP__-ui.log StandardError=inherit diff --git a/conf/lemmy.hjson b/conf/lemmy.hjson index 6e2ddcf..6923310 100644 --- a/conf/lemmy.hjson +++ b/conf/lemmy.hjson @@ -84,7 +84,7 @@ # Address where lemmy should listen for incoming requests bind: "0.0.0.0" # Port where lemmy should listen for incoming requests - port: __PORT_LEMMY__ + port: __PORT__ # Whether the site is available over TLS. Needs to be true for federation to work. tls_enabled: true # Address where pictrs is available (for image hosting) diff --git a/conf/lemmy.service b/conf/lemmy.service index 3cfc327..5e2a223 100644 --- a/conf/lemmy.service +++ b/conf/lemmy.service @@ -1,14 +1,14 @@ [Unit] -Description=__APP__ Daemon +Description=Lemmy: Link aggregator After=network.target [Service] Type=simple User=__APP__ Group=__APP__ -Environment="LEMMY_CONFIG_LOCATION=__FINALPATH__/config/config.hjson" -WorkingDirectory=__FINALPATH__/lemmy/ -ExecStart=__FINALPATH__/lemmy/lemmy +Environment="LEMMY_CONFIG_LOCATION=__INSTALL_DIR__/config/config.hjson" +WorkingDirectory=__INSTALL_DIR__/lemmy/ +ExecStart=__INSTALL_DIR__/lemmy/lemmy StandardOutput=append:/var/log/__APP__/__APP__.log StandardError=inherit diff --git a/conf/nginx.conf b/conf/nginx.conf index 219df32..1ec7d21 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -20,10 +20,10 @@ location / { set $proxpass "http://127.0.0.1:__PORT_UI__"; if ($http_accept ~ "^application/.*$") { - set $proxpass "http://127.0.0.1:__PORT_LEMMY__"; + set $proxpass "http://127.0.0.1:__PORT__"; } if ($request_method = POST) { - set $proxpass "http://127.0.0.1:__PORT_LEMMY__"; + set $proxpass "http://127.0.0.1:__PORT__"; } proxy_pass $proxpass; @@ -37,7 +37,7 @@ location / { # backend location ~ ^/(api|pictrs|feeds|nodeinfo|.well-known) { - proxy_pass http://127.0.0.1:__PORT_LEMMY__; + proxy_pass http://127.0.0.1:__PORT__; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md index 0fe3cc8..0c98e9b 100644 --- a/doc/DESCRIPTION.md +++ b/doc/DESCRIPTION.md @@ -1 +1 @@ -[Lemmy](https://github.com/LemmyNet/lemmy) is similar to sites like [Reddit](https://reddit.com), [Lobste.rs](https://lobste.rs), or [Hacker News](https://news.ycombinator.com/): you subscribe to forums you're interested in, post links and discussions, then vote, and comment on them. Behind the scenes, it is very different; anyone can easily run a server, and all these servers are federated (think email), and connected to the same universe, called the [Fediverse](https://en.wikipedia.org/wiki/Fediverse). +Lemmy is similar to sites like Reddit, Lobste.rs, or Hacker News: you subscribe to forums you're interested in, post links and discussions, then vote, and comment on them. Behind the scenes, it is very different; anyone can easily run a server, and all these servers are federated (think email), and connected to the same universe, called the Fediverse. diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md deleted file mode 100644 index ff56e98..0000000 --- a/doc/DISCLAIMER.md +++ /dev/null @@ -1,2 +0,0 @@ -* Lemmy require full domain path to be installed. Eg. lemmy.domain.tld -* pict-rs image hosting service has been removed, it caused too much issue during compilation diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 7a9cffe..0000000 --- a/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "name": "Lemmy", - "id": "lemmy", - "packaging_format": 1, - "description": { - "en": "Link aggregator/Reddit clone for the fediverse", - "fr": "Agrégateur de liens/clone Reddit pour le fedivers" - }, - "version": "0.16.7~ynh1", - "url": "https://join.lemmy.ml/", - "upstream": { - "license": "GPL-3.0", - "website": "https://join-lemmy.org/", - "demo": "https://lemmy.ml/", - "admindoc": "https://join-lemmy.org/docs/en/", - "code": "https://github.com/LemmyNet/lemmy" - }, - "license": "GPL-3.0", - "maintainer": { - "name": "", - "email": "" - }, - "requirements": { - "yunohost": ">= 4.3.0" - }, - "multi_instance": false, - "services": [ - "nginx" - ], - "arguments": { - "install": [ - { - "name": "domain", - "type": "domain" - } - ] - } -} diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..cf414d3 --- /dev/null +++ b/manifest.toml @@ -0,0 +1,62 @@ +packaging_format = 2 + +id = "lemmy" +name = "Lemmy" +description.en = "Link aggregator/Reddit clone for the fediverse" +description.fr = "Agrégateur de liens/clone Reddit pour le fedivers" + +version = "0.16.7~ynh1" + +maintainers = [] + +[upstream] +license = "GPL-3.0" +website = "https://join-lemmy.org/" +demo = "https://lemmy.ml/" +admindoc = "https://join-lemmy.org/docs/en/" +code = "https://github.com/LemmyNet/lemmy" + +[integration] +yunohost = ">= 11.1.19" +architectures = "all" +multi_instance = false +ldap = false +sso = false +disk = "50M" +ram.build = "100M" +ram.runtime = "50M" + + [install.domain] + type = "domain" + full_domain = true + +[resources] + [resources.sources] + + [resources.sources.main] + url = "https://codeload.github.com/jjlin/docker-image-extract/tar.gz/a9e455e44bbbfba897bf3342d9661b182cee67a9" + sha256 = "9eb0c734e83a3fd7102fc7209af4977024ec467fbc819782491af47295675f67" + + [resources.sources.lemmy-translations] + url = "https://codeload.github.com/LemmyNet/lemmy-translations/tar.gz/ddf0d3a4dcfba5eddbcdb702db2470b52abb3815" + sha256 = "7df72cdba8a6c23c9dca528d3fd71dce13f5263b7a59c8512253364d94797757" + + [resources.ports] + main.default = 8536 + ui.default = 8537 + + [resources.system_user] + + [resources.install_dir] + + [resources.data_dir] + subdirs = ["pictrs-data"] + + [resources.permissions] + main.url = "/" + + [resources.apt] + packages = "postgresql espeak" + + [resources.database] + type = "postgresql" diff --git a/scripts/_common.sh b/scripts/_common.sh index 07ff72a..702e69f 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,13 +4,7 @@ # COMMON VARIABLES #================================================= -# dependencies used by the app -lemmy_dependencies="postgresql postgresql-contrib" -lemmyui_dependencies="espeak" - -pkg_dependencies="$lemmy_dependencies $lemmyui_dependencies" - -NODEJS_VERSION=12 +NODEJS_VERSION=18 #================================================= # PERSONAL HELPERS diff --git a/scripts/backup b/scripts/backup index 4ddf8d0..e0ee696 100755 --- a/scripts/backup +++ b/scripts/backup @@ -10,28 +10,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -ynh_clean_setup () { - true -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_print_info --message="Loading installation settings..." - -app=$YNH_APP_INSTANCE_NAME - -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -domain=$(ynh_app_setting_get --app=$app --key=domain) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) - #================================================= # DECLARE DATA AND CONF FILES TO BACKUP #================================================= @@ -41,13 +19,13 @@ ynh_print_info --message="Declaring files to be backed up..." # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$final_path" +ynh_backup --src_path="$install_dir" #================================================= # BACKUP THE DATA DIR #================================================= -ynh_backup --src_path="$datadir" --is_big +ynh_backup --src_path="$data_dir" --is_big #================================================= # BACKUP THE NGINX CONFIGURATION diff --git a/scripts/change_url b/scripts/change_url new file mode 100644 index 0000000..f6b925a --- /dev/null +++ b/scripts/change_url @@ -0,0 +1,54 @@ +#!/bin/bash + +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh +source /usr/share/yunohost/helpers + +#================================================= +# STANDARD MODIFICATIONS +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Stopping a systemd service..." --weight=1 + +ynh_systemd_action --service_name=$app --action="stop" --line_match="Stopped" --log_path=systemd +ynh_systemd_action --service_name=$app-ui --action="stop" --line_match="Stopped" --log_path=systemd + +#================================================= +# MODIFY URL IN NGINX CONF +#================================================= +ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 + +ynh_change_url_nginx_config + +#================================================= +# ADD A CONFIGURATION +#================================================= +ynh_script_progression --message="Adding a configuration file..." --weight=1 + +mkdir -p "$install_dir/config/" +ynh_add_config --template="../conf/lemmy.hjson" --destination="$install_dir/config/config.hjson" + +chmod 400 "$install_dir/config/config.hjson" +chown $app:$app "$install_dir/config/config.hjson" + +#================================================= +# GENERIC FINALISATION +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." --weight=1 + +ynh_systemd_action --service_name=$app --action="start" --line_match="Starting http server at" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app-ui --action="start" --line_match="http://0.0.0.0" --log_path="/var/log/$app/$app-ui.log" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Change of URL completed for $app" --last diff --git a/scripts/install b/scripts/install index b50cbcc..e4dab13 100755 --- a/scripts/install +++ b/scripts/install @@ -9,87 +9,21 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -ynh_clean_setup () { - true -} -# 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="/" - -app=$YNH_APP_INSTANCE_NAME - -#================================================= -# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS -#================================================= -ynh_script_progression --message="Validating installation parameters..." --weight=1 - -final_path=/var/www/$app -test ! -e "$final_path" || ynh_die --message="This path already contains a folder" - -# Register (book) web path -ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url - -#================================================= -# STORE SETTINGS FROM MANIFEST -#================================================= -ynh_script_progression --message="Storing installation settings..." --weight=1 - -ynh_app_setting_set --app=$app --key=domain --value=$domain -ynh_app_setting_set --app=$app --key=path --value=$path_url - -#================================================= -# STANDARD MODIFICATIONS -#================================================= -# FIND AND OPEN A PORT -#================================================= -ynh_script_progression --message="Finding an available port..." --weight=1 - -# Find an available port -port_lemmy=$(ynh_find_port --port=8536) -ynh_app_setting_set --app=$app --key=port_lemmy --value=$port_lemmy -port_ui=$(ynh_find_port --port=1235) -ynh_app_setting_set --app=$app --key=port_ui --value=$port_ui - #================================================= # INSTALL DEPENDENCIES #================================================= ynh_script_progression --message="Installing dependencies..." --weight=1 -ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies ynh_install_nodejs --nodejs_version=$NODEJS_VERSION ynh_use_nodejs ln -fs /usr/lib/x86_64-linux-musl/libc.so /lib/libc.musl-x86_64.so.1 -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." --weight=1 - -# Create a system user -ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # CREATE A POSTGRESQL DATABASE #================================================= ynh_script_progression --message="Creating a PostgreSQL database..." --weight=1 -ynh_psql_test_if_first_run -db_name=$(ynh_sanitize_dbid --db_name=$app) -db_user=$db_name -db_pwd=$(ynh_string_random --length=30) -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_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pgcrypto;" --database="$db_name" #================================================= @@ -97,15 +31,13 @@ ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pgcrypto;" --data #================================================= ynh_script_progression --message="Setting up source files..." --weight=1 -ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$final_path/build-lemmy/" --source_id="docker-image-extract" -ynh_setup_source --dest_dir="$final_path/build-lemmy-ui/" --source_id="docker-image-extract" -ynh_setup_source --dest_dir="$final_path/lemmy-ui/lemmy-translations/" --source_id="lemmy-translations" +ynh_setup_source --dest_dir="$install_dir/build-lemmy/" +ynh_setup_source --dest_dir="$install_dir/build-lemmy-ui/" +ynh_setup_source --dest_dir="$install_dir/lemmy-ui/lemmy-translations/" --source_id="lemmy-translations" -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:$app "$final_path" +chmod -R o-rwx "$install_dir" +chown -R $app:$app "$install_dir" #================================================= # NGINX CONFIGURATION @@ -115,57 +47,41 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# SPECIFIC SETUP -#================================================= -# CREATE DATA DIRECTORY -#================================================= -ynh_script_progression --message="Creating a data directory..." --weight=1 - -datadir=/home/yunohost.app/$app -ynh_app_setting_set --app=$app --key=datadir --value=$datadir - -mkdir -p $datadir/pictrs-data - -chmod 750 "$datadir" -chmod -R o-rwx "$datadir" -chown -R $app:$app "$datadir" - #================================================= # MAKE INSTALL #================================================= ynh_script_progression --message="Making install..." --weight=1 # Install lemmy-ui -pushd $final_path/build-lemmy-ui +pushd $install_dir/build-lemmy-ui ./docker-image-extract dessalines/lemmy-ui:$(ynh_app_upstream_version) popd -mkdir -p "$final_path/lemmy-ui/" -rsync -a "$final_path/build-lemmy-ui/output/app/" "$final_path/lemmy-ui/" -ynh_secure_remove --file="$final_path/build-lemmy-ui" +mkdir -p "$install_dir/lemmy-ui/" +rsync -a "$install_dir/build-lemmy-ui/output/app/" "$install_dir/lemmy-ui/" +ynh_secure_remove --file="$install_dir/build-lemmy-ui" # Install lemmy -pushd $final_path/build-lemmy +pushd $install_dir/build-lemmy ./docker-image-extract dessalines/lemmy:$(ynh_app_upstream_version) popd -mkdir -p "$final_path/lemmy/" -mv -f "$final_path/build-lemmy/output/app/lemmy" "$final_path/lemmy/lemmy" -ynh_secure_remove --file="$final_path/build-lemmy" +mkdir -p "$install_dir/lemmy/" +mv -f "$install_dir/build-lemmy/output/app/lemmy" "$install_dir/lemmy/lemmy" +ynh_secure_remove --file="$install_dir/build-lemmy" -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:$app "$final_path" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R $app:$app "$install_dir" #================================================= # ADD A CONFIGURATION #================================================= ynh_script_progression --message="Adding a configuration file..." --weight=1 -mkdir -p "$final_path/config/" -ynh_add_config --template="../conf/lemmy.hjson" --destination="$final_path/config/config.hjson" +mkdir -p "$install_dir/config/" +ynh_add_config --template="../conf/lemmy.hjson" --destination="$install_dir/config/config.hjson" -chmod 400 "$final_path/config/config.hjson" -chown $app:$app "$final_path/config/config.hjson" +chmod 400 "$install_dir/config/config.hjson" +chown $app:$app "$install_dir/config/config.hjson" #================================================= # SETUP SYSTEMD @@ -208,21 +124,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="start" --line_match="Starting http server at" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name=$app-ui --action="start" --line_match="http://0.0.0.0" --log_path="/var/log/$app/$app-ui.log" -#================================================= -# SETUP SSOWAT -#================================================= -ynh_script_progression --message="Configuring permissions..." --weight=1 - -# Make app public -ynh_permission_update --permission="main" --add="visitors" - -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/remove b/scripts/remove index e9f6065..4d8e799 100755 --- a/scripts/remove +++ b/scripts/remove @@ -9,19 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 - -app=$YNH_APP_INSTANCE_NAME - -domain=$(ynh_app_setting_get --app=$app --key=domain) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$db_name -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) - #================================================= # STANDARD REMOVE #================================================= @@ -57,33 +44,6 @@ ynh_script_progression --message="Removing logrotate configuration..." --weight= # Remove the app-specific logrotate config ynh_remove_logrotate -#================================================= -# REMOVE THE POSTGRESQL DATABASE -#================================================= -ynh_script_progression --message="Removing the PostgreSQL database..." --weight=1 - -# Remove a database if it exists, along with the associated user -ynh_psql_remove_db --db_user=$db_user --db_name=$db_name - -#================================================= -# REMOVE APP MAIN DIR -#================================================= -ynh_script_progression --message="Removing app main directory..." --weight=1 - -# Remove the app directory securely -ynh_secure_remove --file="$final_path" - -#================================================= -# REMOVE DATA DIR -#================================================= - -# Remove the data directory if --purge option is used -if [ "${YNH_APP_PURGE:-0}" -eq 1 ] -then - ynh_script_progression --message="Removing app data directory..." --weight=1 - ynh_secure_remove --file="$datadir" -fi - #================================================= # REMOVE NGINX CONFIGURATION #================================================= @@ -99,7 +59,6 @@ ynh_script_progression --message="Removing dependencies..." --weight=1 # Remove metapackage and its dependencies ynh_remove_nodejs -ynh_remove_app_dependencies ynh_secure_remove --file="/lib/libc.musl-x86_64.so.1" #================================================= @@ -112,16 +71,6 @@ ynh_script_progression --message="Removing various files..." --weight=1 # Remove the log files ynh_secure_remove --file="/var/log/$app" -#================================================= -# GENERIC FINALIZATION -#================================================= -# REMOVE DEDICATED USER -#================================================= -ynh_script_progression --message="Removing the dedicated system user..." --weight=1 - -# Delete a system user -ynh_system_user_delete --username=$app - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index 2e62c14..10048d1 100755 --- a/scripts/restore +++ b/scripts/restore @@ -10,72 +10,24 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -ynh_clean_setup () { - true -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 - -app=$YNH_APP_INSTANCE_NAME - -domain=$(ynh_app_setting_get --app=$app --key=domain) -path_url=$(ynh_app_setting_get --app=$app --key=path) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -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) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) - -#================================================= -# CHECK IF THE APP CAN BE RESTORED -#================================================= -ynh_script_progression --message="Validating restoration parameters..." --weight=1 - -test ! -d $final_path \ - || ynh_die --message="There is already a directory: $final_path " - -#================================================= -# STANDARD RESTORATION STEPS -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 - -# Create the dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir="$final_path" - #================================================= # RESTORE THE APP MAIN DIR #================================================= ynh_script_progression --message="Restoring the app main directory..." --weight=1 -ynh_restore_file --origin_path="$final_path" +ynh_restore_file --origin_path="$install_dir" -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:$app "$final_path" +chmod -R o-rwx "$install_dir" +chown -R $app:$app "$install_dir" #================================================= # RESTORE THE DATA DIRECTORY #================================================= ynh_script_progression --message="Restoring the data directory..." --weight=1 -ynh_restore_file --origin_path="$datadir" --not_mandatory +ynh_restore_file --origin_path="$data_dir" --not_mandatory -mkdir -p $datadir - -chmod 750 "$datadir" -chmod -R o-rwx "$datadir" -chown -R $app:$app "$datadir" +chown -R $app:$app "$data_dir" #================================================= # SPECIFIC RESTORATION @@ -85,7 +37,6 @@ chown -R $app:$app "$datadir" ynh_script_progression --message="Reinstalling dependencies..." --weight=1 # Define and install dependencies -ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies ynh_install_nodejs --nodejs_version=$NODEJS_VERSION ynh_use_nodejs ln -fs /usr/lib/x86_64-linux-musl/libc.so /lib/libc.musl-x86_64.so.1 @@ -102,8 +53,6 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1 -ynh_psql_test_if_first_run -ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name" ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pgcrypto;" --database="$db_name" diff --git a/scripts/upgrade b/scripts/upgrade index 20b91df..06a9d25 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,45 +9,12 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 - -app=$YNH_APP_INSTANCE_NAME - -domain=$(ynh_app_setting_get --app=$app --key=domain) -path_url=$(ynh_app_setting_get --app=$app --key=path) -admin=$(ynh_app_setting_get --app=$app --key=admin) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -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) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) -port_lemmy=$(ynh_app_setting_get --app=$app --key=port_lemmy) -port_ui=$(ynh_app_setting_get --app=$app --key=port_ui) - #================================================= # CHECK VERSION #================================================= -ynh_script_progression --message="Checking version..." --weight=1 upgrade_type=$(ynh_check_app_version_changed) -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1 - -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - # Restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - #================================================= # STANDARD UPGRADE STEPS #================================================= @@ -63,13 +30,6 @@ ynh_systemd_action --service_name=$app-ui --action="stop" --line_match="Stopped" #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 -# Cleaning legacy permissions -if ynh_legacy_permissions_exists; then - ynh_legacy_permissions_delete_all - - ynh_app_setting_delete --app=$app --key=is_public -fi - # Removing previously installed iframely if ynh_exec_warn_less yunohost service status $app-iframely >/dev/null then @@ -87,17 +47,9 @@ then yunohost service remove $app-pict-rs fi ynh_remove_systemd_config --service=$app-pict-rs -ynh_secure_remove --file="$final_path/pict-rs" +ynh_secure_remove --file="$install_dir/pict-rs" ynh_app_setting_delete --app=$app --key=port_pictrs -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir="$final_path" - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -107,21 +59,20 @@ then ynh_script_progression --message="Upgrading source files..." --weight=1 # Download, check integrity, uncompress the source of lemmy from app.src to his build directory - ynh_setup_source --dest_dir="$final_path/build-lemmy/" --source_id="docker-image-extract" - ynh_setup_source --dest_dir="$final_path/build-lemmy-ui/" --source_id="docker-image-extract" - ynh_setup_source --dest_dir="$final_path/lemmy-ui/lemmy-translations/" --source_id="lemmy-translations" + ynh_setup_source --dest_dir="$install_dir/build-lemmy/" + ynh_setup_source --dest_dir="$install_dir/build-lemmy-ui/" + ynh_setup_source --dest_dir="$install_dir/lemmy-ui/lemmy-translations/" --source_id="lemmy-translations" fi -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:$app "$final_path" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R $app:$app "$install_dir" #================================================= # UPGRADE DEPENDENCIES #================================================= ynh_script_progression --message="Upgrading dependencies..." --weight=1 -ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies ynh_install_nodejs --nodejs_version=$NODEJS_VERSION ynh_use_nodejs ln -fs /usr/lib/x86_64-linux-musl/libc.so /lib/libc.musl-x86_64.so.1 @@ -144,36 +95,36 @@ ynh_script_progression --message="Making upgrade..." --weight=1 if [ "$upgrade_type" == "UPGRADE_APP" ] then # Install lemmy-ui - pushd $final_path/build-lemmy-ui + pushd $install_dir/build-lemmy-ui ./docker-image-extract dessalines/lemmy-ui:$(ynh_app_upstream_version) popd - mkdir -p "$final_path/lemmy-ui/" - rsync -a "$final_path/build-lemmy-ui/output/app/" "$final_path/lemmy-ui/" - ynh_secure_remove --file="$final_path/build-lemmy-ui" + mkdir -p "$install_dir/lemmy-ui/" + rsync -a "$install_dir/build-lemmy-ui/output/app/" "$install_dir/lemmy-ui/" + ynh_secure_remove --file="$install_dir/build-lemmy-ui" # Install lemmy - pushd $final_path/build-lemmy + pushd $install_dir/build-lemmy ./docker-image-extract dessalines/lemmy:$(ynh_app_upstream_version) popd - mkdir -p "$final_path/lemmy/" - mv -f "$final_path/build-lemmy/output/app/lemmy" "$final_path/lemmy/lemmy" - ynh_secure_remove --file="$final_path/build-lemmy" + mkdir -p "$install_dir/lemmy/" + mv -f "$install_dir/build-lemmy/output/app/lemmy" "$install_dir/lemmy/lemmy" + ynh_secure_remove --file="$install_dir/build-lemmy" fi -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:$app "$final_path" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R $app:$app "$install_dir" #================================================= # UPDATE A CONFIG FILE #================================================= ynh_script_progression --message="Updating a configuration file..." --weight=1 -mkdir -p "$final_path/lemmy/" -ynh_add_config --template="../conf/lemmy.hjson" --destination="$final_path/config/config.hjson" +mkdir -p "$install_dir/lemmy/" +ynh_add_config --template="../conf/lemmy.hjson" --destination="$install_dir/config/config.hjson" -chmod 400 "$final_path/config/config.hjson" -chown $app:$app "$final_path/config/config.hjson" +chmod 400 "$install_dir/config/config.hjson" +chown $app:$app "$install_dir/config/config.hjson" #================================================= # CREATE EXTENSION IF NOT EXISTS pgcrypto @@ -222,13 +173,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="start" --line_match="Starting http server at" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name=$app-ui --action="start" --line_match="http://0.0.0.0" --log_path="/var/log/$app/$app-ui.log" -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #================================================= diff --git a/tests.toml b/tests.toml new file mode 100644 index 0000000..524d6d3 --- /dev/null +++ b/tests.toml @@ -0,0 +1,17 @@ +test_format = 1.0 + +[default] + + # ------------------------------- + # Default args to use for install + # ------------------------------- + + args.admin = "john" + args.sitename = "lemmy website" + + + # ------------------------------- + # Commits to test upgrade from + # ------------------------------- + + test_upgrade_from.206df4db0b99c52f07ea1a2d5daf799d4b8357fd.name = "Upgrade from 0.15.2~ynh3" \ No newline at end of file