diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh deleted file mode 100644 index 76b7599..0000000 --- a/.github/workflows/updater.sh +++ /dev/null @@ -1,122 +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]') -# Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions) -latest_release_json=$(curl --silent "https://git.pleroma.social/api/v4/projects/2/releases" | jq -r '[.[] | select( .upcoming_release != true )][0]') -version=$(echo $latest_release_json | jq -r '.tag_name') -assets=$(echo $latest_release_json | jq -r '[ .assets.sources[].url ] | join(" ") | @sh' | tr -d "'") -release=$(echo $latest_release_json | jq -r '[ ._links.self ] | join(" ")' | tr -d "'") -description=$(echo $latest_release_json | jq -r '[ .description ] | join(" ")' | tr -d "'") -commit_id=$(echo $latest_release_json | jq -r '[ .commit.id ] | join(" ")' | tr -d "'") -pipeline_id=$(curl --silent "https://git.pleroma.social/api/v4/projects/2/pipelines?sha=$commit_id&ref=stable" | jq -r '[ .[] | .id|tostring ] | join(" ") ' | tr -d "'") - -# 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 "RELEASE=$release" >> $GITHUB_ENV -echo "DESCRIPTION<> $GITHUB_ENV -echo "$description" >> $GITHUB_ENV -echo "EOF" >> $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 - -#================================================= -# UPDATE SOURCE FILES -#================================================= - -# Let's loop over the available architectures -architectures=("amd64" "arm64" "arm") -for arch in ${architectures[@]}; do - - echo "Processing $arch release" - - job_url=$(curl --silent "https://git.pleroma.social/api/v4/projects/2/pipelines/$pipeline_id/jobs" | jq -r '.[] | select((.status=="success") and (.stage=="release") and (.name=="'$arch'")) | .web_url') - - if [ ! -z "$job_url" ]; then - - asset_url="$job_url/artifacts/download?file_type=archive" - - # Create the temporary directory - tempdir="$(mktemp -d)" - - # Download sources and calculate checksum - filename="asset-$arch.zip" - curl --silent -4 -L $asset_url -o "$tempdir/$filename" - checksum=$(sha256sum "$tempdir/$filename" | head -c 64) - - # Delete temporary directory - rm -rf $tempdir - - if [ $arch == "arm" ]; then - arch="armhf" - fi - - # Rewrite source file - cat < conf/$arch.src -SOURCE_URL=$asset_url -SOURCE_SUM=$checksum -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=zip -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= -EOT - echo "... conf/$arch.src updated" - - else - echo "... artifact ignored" - echo "::warning ::Artifact for $arch was not updated" - fi - -done - -#================================================= -# 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 64f2a2f..0000000 --- a/.github/workflows/updater.yml +++ /dev/null @@ -1,52 +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@v3 - 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@v4 - 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 }} - [See upstream release page](${{ env.RELEASE }}) - Provided description: - ${{ env.DESCRIPTION }} - draft: false diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 6133a24..0000000 --- a/.travis.yml +++ /dev/null @@ -1,7 +0,0 @@ -language: python - -before_install: - - git clone https://github.com/YunoHost/package_linter /tmp/package_linter - -script: -- /tmp/package_linter/package_linter.py ./ \ No newline at end of file diff --git a/conf/nginx.conf b/conf/nginx.conf index 748f7f1..4e2a59d 100755 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,14 +1,13 @@ -location / { +#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; +location __PATH__/ { - # Standard nginx configuration + proxy_pass http://127.0.0.1:__PORT__; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $http_host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_pass http://127.0.0.1:__PORT__; - client_max_body_size 50M; more_set_headers "Access-Control-Allow-Origin : *"; @@ -31,7 +30,6 @@ location / { # Uncomment this only after you get HTTPS working. # more_set_headers "Strict-Transport-Security : max-age=31536000; includeSubDomains"; - # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; } diff --git a/doc/DISCLAIMER.md b/doc/ADMIN.md similarity index 100% rename from doc/DISCLAIMER.md rename to doc/ADMIN.md diff --git a/doc/DISCLAIMER_fr.md b/doc/ADMIN_fr.md similarity index 100% rename from doc/DISCLAIMER_fr.md rename to doc/ADMIN_fr.md diff --git a/manifest.json b/manifest.json deleted file mode 100644 index d34f590..0000000 --- a/manifest.json +++ /dev/null @@ -1,100 +0,0 @@ -{ - "name": "Pleroma", - "id": "pleroma", - "packaging_format": 1, - "description": { - "en": "Federated social networking server built on open protocols", - "fr": "Serveur de réseautage social fédéré basé sur des protocoles ouverts" - }, - "version": "2.5.2~ynh1", - "url": "https://pleroma.social/", - "upstream": { - "license": "AGPL-3.0-only", - "website": "https://pleroma.social/", - "admindoc": "https://docs.pleroma.social/", - "code": "https://git.pleroma.social/pleroma/pleroma/" - }, - "license": "AGPL-3.0-only", - "maintainer": [ - { - "name": "Anmol Sharma", - "email": "anmol@datamol.org" - }, - { - "name": "yalh76" - } - ], - "requirements": { - "yunohost": ">= 4.3.1.8" - }, - "multi_instance": false, - "services": [ - "nginx" - ], - "arguments": { - "install": [ - { - "name": "domain", - "type": "domain" - }, - { - "name": "is_public", - "type": "boolean", - "default": true - }, - { - "name": "admin", - "type": "user" - }, - { - "name": "password", - "type": "password" - }, - { - "name": "name", - "type": "string", - "ask": { - "en": "Choose a name for your Pleroma instance", - "fr": "Choisissez un nom pour votre instance Pleroma" - }, - "example": "My_Pleroma", - "default": "My_Pleroma" - }, - { - "name": "registration", - "type": "boolean", - "ask": { - "en": "Should registration be open to users who do not have a YunoHost account on the system?", - "fr": "L'inscription doit-elle être ouverte aux utilisateurs qui n'ont pas de compte YunoHost sur le système ?" - }, - "default": false - }, - { - "name": "cache", - "type": "boolean", - "ask": { - "en": "Enable media-cache for your instance", - "fr": "Activer le cache média pour votre instance" - }, - "default": true - }, - { - "name": "size", - "type": "string", - "ask": { - "en": "Select the cache size. If you did not enabled media-cache in above option then this option will have no effect", - "fr": "Sélectionner la taille du cache. Si vous n'avez pas activé le cache média ci-dessus, cette option n'aura aucun effet" - }, - "choices": [ - "2g", - "5g", - "10g", - "20g", - "40g", - "80g" - ], - "default": "5g" - } - ] - } -} diff --git a/manifest.toml b/manifest.toml index 241c5b9..2b670f0 100644 --- a/manifest.toml +++ b/manifest.toml @@ -14,22 +14,18 @@ license = "AGPL-3.0-only" website = "https://pleroma.social/" admindoc = "https://docs.pleroma.social/" code = "https://git.pleroma.social/pleroma/pleroma/" -cpe = "???" # FIXME: optional but recommended if relevant, this is meant to contain the Common Platform Enumeration, which is sort of a standard id for applications defined by the NIST. In particular, Yunohost may use this is in the future to easily track CVE (=security reports) related to apps. The CPE may be obtained by searching here: https://nvd.nist.gov/products/cpe/search. For example, for Nextcloud, the CPE is 'cpe:2.3:a:nextcloud:nextcloud' (no need to include the version number) -fund = "???" # FIXME: optional but recommended (or remove if irrelevant / not applicable). This is meant to be an URL where people can financially support this app, especially when its development is based on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin. -[integration] -yunohost = ">= 4.3.1.8" -architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"] +yunohost = ">= 11.1.19" +architectures = "all" multi_instance = false -ldap = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "sso" key : the "ldap" key corresponds to wether or not a user *can* login on the app using its YunoHost credentials. -sso = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "ldap" key : the "sso" key corresponds to wether or not a user is *automatically logged-in* on the app when logged-in on the YunoHost portal. -disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ... -ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... -ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... +ldap = true +sso = true +disk = "50M" +ram.build = "50M" +ram.runtime = "50M" [install] [install.domain] - # this is a generic question - ask strings are automatically handled by Yunohost's core type = "domain" full_domain = true @@ -38,11 +34,9 @@ ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requiremen default = "visitors" [install.admin] - # this is a generic question - ask strings are automatically handled by Yunohost's core type = "user" [install.password] - # this is a generic question - ask strings are automatically handled by Yunohost's core type = "password" [install.name] @@ -80,15 +74,25 @@ ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requiremen armhf.url = "https://git.pleroma.social/pleroma/pleroma/-/jobs/234449/artifacts/download?file_type=archive" armhf.sha256 = "abab2ad69704b999dbe1b995ce12aabc8069d9620ca332ecc621b20826d6db97" + [resources.ports] [resources.system_user] [resources.install_dir] [resources.data_dir] + subdirs = ["uploads", "static/emoji"] [resources.permissions] main.url = "/" + api.url = "/api" + api.allowed="visitors" + api.auth_header="false" + api.show_tile="false" + api.protected="true" + + [resources.apt] + packages = "curl unzip libncurses5 postgresql postgresql-contrib imagemagick ffmpeg exiftool libimage-exiftool-perl" [resources.database] type = "postgresql" diff --git a/scripts/_common.sh b/scripts/_common.sh index b0eb20c..3f994be 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,9 +4,6 @@ # COMMON VARIABLES #================================================= -# dependencies used by the app (must be on a single line) -#REMOVEME? pkg_dependencies="curl unzip libncurses5 postgresql postgresql-contrib imagemagick ffmpeg exiftool libimage-exiftool-perl" - #================================================= # PERSONAL HELPERS #================================================= @@ -18,3 +15,28 @@ #================================================= # FUTURE OFFICIAL HELPERS #================================================= + +read_json () { + sudo python3 -c "import sys, json;print(json.load(open('$1'))['$2'])" +} + +read_manifest () { + if [ -f '../manifest.json' ] ; then + read_json '../manifest.json' "$1" + else + read_json '../settings/manifest.json' "$1" + fi +} +abort_if_up_to_date () { + version=$(read_json "/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" 'version' 2> /dev/null || echo '20160501-7') + last_version=$(read_manifest 'version') + if [ "${version}" = "${last_version}" ] && [ "$YNH_APP_UPGRADE_TYPE" != "UPGRADE_FORCED" ]; then + ynh_print_info "Up-to-date, nothing to do" + ynh_die "" 0 + fi +} + +ynh_version_gt () +{ + dpkg --compare-versions "$1" gt "$2" +} diff --git a/scripts/backup b/scripts/backup index 85920ae..a1b75cc 100755 --- a/scripts/backup +++ b/scripts/backup @@ -10,29 +10,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -#REMOVEME? ynh_clean_setup () { - true -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_print_info --message="Loading settings..." - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) -#REMOVEME? cache=$(ynh_app_setting_get --app=$app --key=cache) -#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) - #================================================= # DECLARE DATA AND CONF FILES TO BACKUP #================================================= diff --git a/scripts/change_url b/scripts/change_url index 93ede17..852ef76 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -9,62 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# RETRIEVE ARGUMENTS -#================================================= - -#REMOVEME? old_domain=$YNH_APP_OLD_DOMAIN -#REMOVEME? old_path=$YNH_APP_OLD_PATH - -#REMOVEME? new_domain=$YNH_APP_NEW_DOMAIN -#REMOVEME? new_path="/" - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading settings..." --weight=1 - -#REMOVEME? # Needed for helper "ynh_add_nginx_config" -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) - -# Add settings here as needed by your application -#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port) - -#================================================= -# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP -#================================================= -#REMOVEME? ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1 - -# Backup the current version of the app -#REMOVEME? ynh_backup_before_upgrade -#REMOVEME? ynh_clean_setup () { - # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. -#REMOVEME? ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" - - # Restore it if the upgrade fails -#REMOVEME? ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - -#================================================= -# CHECK WHICH PARTS SHOULD BE CHANGED -#================================================= - -#REMOVEME? change_domain=0 -#REMOVEME? if [ "$old_domain" != "$new_domain" ] -then - #REMOVEME? change_domain=1 -fi - -#REMOVEME? change_path=0 -#REMOVEME? if [ "$old_path" != "$new_path" ] -then - #REMOVEME? change_path=1 -fi - #================================================= # STANDARD MODIFICATIONS #================================================= @@ -83,30 +27,6 @@ ynh_script_progression --message="Updating NGINX web server configuration..." -- ynh_change_url_nginx_config -#REMOVEME? nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf - -# Change the path in the NGINX config file -if [ $change_path -eq 1 ] -then - # Make a backup of the original NGINX config file if modified -#REMOVEME? ynh_backup_if_checksum_is_different --file="$nginx_conf_path" - # Set global variables for NGINX helper -#REMOVEME? domain="$old_domain" -#REMOVEME? path="$new_path" - # Create a dedicated NGINX config -#REMOVEME? ynh_add_nginx_config -fi - -# Change the domain for NGINX -if [ $change_domain -eq 1 ] -then - # Delete file checksum for the old conf file location -#REMOVEME? ynh_delete_file_checksum --file="$nginx_conf_path" -#REMOVEME? mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf - # Store file checksum for the new config file location -#REMOVEME? ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" -fi - #================================================= # SPECIFIC MODIFICATIONS #================================================= @@ -129,13 +49,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1 # Start a systemd service ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Access Pleroma.Web.Endpoint" -#================================================= -# RELOAD NGINX -#================================================= -#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -#REMOVEME? #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/install b/scripts/install index bb3f436..158f143 100755 --- a/scripts/install +++ b/scripts/install @@ -9,29 +9,10 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -#REMOVEME? ynh_clean_setup () { - true -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= -#REMOVEME? domain=$YNH_APP_ARG_DOMAIN -path="/" -#REMOVEME? is_public=$YNH_APP_ARG_IS_PUBLIC -#REMOVEME? admin=$YNH_APP_ARG_ADMIN -#REMOVEME? password=$YNH_APP_ARG_PASSWORD -#REMOVEME? name="${YNH_APP_ARG_NAME// /_}" -#REMOVEME? registration=$YNH_APP_ARG_REGISTRATION -#REMOVEME? cache=$YNH_APP_ARG_CACHE -#REMOVEME? size=$YNH_APP_ARG_SIZE random_key=$(ynh_string_random --length=64) signing_salt=$(ynh_string_random --length=8) admin_email=$(ynh_user_get_info --username=$admin --key="mail") @@ -41,71 +22,24 @@ if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then admin="test" fi -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#================================================= -# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS -#================================================= -#REMOVEME? ynh_script_progression --message="Validating installation parameters..." --weight=1 - -#REMOVEME? install_dir=/var/www/$app -#REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder" - -# Register (book) web path -#REMOVEME? ynh_webpath_register --app=$app --domain=$domain --path=$path - #================================================= # STORE SETTINGS FROM MANIFEST #================================================= #REMOVEME? ynh_script_progression --message="Storing installation settings..." --weight=1 -#REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain -#REMOVEME? ynh_app_setting_set --app=$app --key=path --value=$path -#REMOVEME? ynh_app_setting_set --app=$app --key=admin --value=$admin ynh_app_setting_set --app=$app --key=name --value=$name ynh_app_setting_set --app=$app --key=registration --value=$registration ynh_app_setting_set --app=$app --key=cache --value=$cache ynh_app_setting_set --app=$app --key=size --value=$size -#REMOVEME? ynh_app_setting_set --app=$app --key=admin_email --value=$admin_email +ynh_app_setting_set --app=$app --key=admin_email --value=$admin_email ynh_app_setting_set --app=$app --key=random_key --value=$random_key ynh_app_setting_set --app=$app --key=signing_salt --value=$signing_salt -#================================================= -# STANDARD MODIFICATIONS -#================================================= -# FIND AND OPEN A PORT -#================================================= -#REMOVEME? ynh_script_progression --message="Finding an available port..." --weight=1 - -# Find an available port -#REMOVEME? port=$(ynh_find_port --port=8095) -#REMOVEME? ynh_app_setting_set --app=$app --key=port --value=$port - -#================================================= -# INSTALL DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=1 - -#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# CREATE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Configuring system user..." --weight=1 - -# Create a system user -#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" - #================================================= # CREATE A POSTGRESQL DATABASE #================================================= -#REMOVEME? ynh_script_progression --message="Creating a PostgreSQL database..." --weight=1 +ynh_script_progression --message="Creating a PostgreSQL database..." --weight=1 -#REMOVEME? db_name=$(ynh_sanitize_dbid --db_name=$app) -#REMOVEME? db_user=$db_name -#REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name -#REMOVEME? ynh_psql_test_if_first_run -#REMOVEME? ynh_psql_setup_db --db_user=$db_user --db_name=$db_name ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS unaccent;" --database=$db_name ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --database=$db_name ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS citext;" --database=$db_name @@ -116,11 +50,9 @@ ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";" - #================================================= ynh_script_progression --message="Setting up source files..." --weight=1 -#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir/live" --source_id=$YNH_ARCH -chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" chown -R $app:$app "$install_dir" @@ -139,25 +71,6 @@ fi # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# SPECIFIC SETUP -#================================================= -# CREATE DATA DIRECTORY -#================================================= -ynh_script_progression --message="Creating a data directory..." --weight=1 - -#REMOVEME? data_dir=/home/yunohost.app/$app -#REMOVEME? ynh_app_setting_set --app=$app --key=data_dir --value=$data_dir - -mkdir -p $data_dir -mkdir -p "$data_dir/uploads/" -mkdir -p "$data_dir/static/" -mkdir -p "$data_dir/static/emoji/" - -chmod 750 "$data_dir" -chmod -R o-rwx "$data_dir" -chown -R $app:$app "$data_dir" - #================================================= # ADD A CONFIGURATION #================================================= @@ -247,31 +160,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1 # Start a systemd service ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Access Pleroma.Web.Endpoint" -#================================================= -# SETUP SSOWAT -#================================================= -#REMOVEME? ynh_script_progression --message="Configuring permissions..." --weight=1 - -# Make app public if necessary -#REMOVEME? if [ $is_public -eq 1 ] -then - # Everyone can access the app. - # The "main" permission is automatically created before the install script. -#REMOVEME? 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" -#REMOVEME? ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --auth_header="false" --show_tile="false" --protected="true" - -#================================================= -# RELOAD NGINX -#================================================= -#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload - #================================================= # POST INSTALL #================================================= diff --git a/scripts/remove b/scripts/remove index 5192fa3..550c17d 100755 --- a/scripts/remove +++ b/scripts/remove @@ -9,20 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading settings..." --weight=1 - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port) -#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) -#REMOVEME? db_user=$db_name -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) - #================================================= # STANDARD REMOVE #================================================= @@ -48,22 +34,6 @@ pkill -u $app || true # Remove the dedicated systemd config ynh_remove_systemd_config -#================================================= -# REMOVE THE POSTGRESQL DATABASE -#================================================= -#REMOVEME? ynh_script_progression --message="Removing the PostgreSQL database..." --weight=1 - -# Remove a database if it exists, along with the associated user -#REMOVEME? ynh_psql_remove_db --db_user=$db_user --db_name=$db_name - -#================================================= -# REMOVE APP MAIN DIR -#================================================= -#REMOVEME? ynh_script_progression --message="Removing app main directory..." --weight=1 - -# Remove the app directory securely -#REMOVEME? ynh_secure_remove --file="$install_dir" - #================================================= # REMOVE DATA DIR #================================================= @@ -84,24 +54,6 @@ ynh_script_progression --message="Removing NGINX web server configuration..." -- ynh_remove_nginx_config ynh_secure_remove --file="/etc/nginx/conf.d/$app-cache.conf" -#================================================= -# REMOVE DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Removing dependencies..." --weight=1 - -# Remove metapackage and its dependencies -#REMOVEME? ynh_remove_app_dependencies - -#================================================= -# CLOSE A PORT -#================================================= - -if yunohost firewall list | grep -q "\- $port$" -then - ynh_script_progression --message="Closing port $port..." --weight=1 - ynh_exec_warn_less yunohost firewall disallow TCP $port -fi - #================================================= # SPECIFIC REMOVE #================================================= @@ -112,16 +64,6 @@ ynh_script_progression --message="Removing various files..." --weight=1 # Remove a directory securely ynh_secure_remove --file="/etc/$app" -#================================================= -# GENERIC FINALIZATION -#================================================= -# REMOVE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Removing the dedicated system user..." --weight=1 - -# Delete a system user -#REMOVEME? ynh_system_user_delete --username=$app - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index 0a6c978..7816f3a 100755 --- a/scripts/restore +++ b/scripts/restore @@ -6,54 +6,9 @@ # IMPORT GENERIC HELPERS #================================================= -# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -#REMOVEME? ynh_clean_setup () { - true -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading settings..." --weight=1 - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) -#REMOVEME? db_user=$db_name -#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port) -#REMOVEME? cache=$(ynh_app_setting_get --app=$app --key=cache) -#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) - -#================================================= -# CHECK IF THE APP CAN BE RESTORED -#================================================= -#REMOVEME? ynh_script_progression --message="Validating restoration parameters..." --weight=1 - -#REMOVEME? test ! -d $install_dir \ - || ynh_die --message="There is already a directory: $install_dir " - -#================================================= -# STANDARD RESTORATION STEPS -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 - -# Create the dedicated user (if not existing) -#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" - #================================================= # RESTORE THE APP MAIN DIR #================================================= @@ -61,7 +16,6 @@ ynh_script_progression --message="Restoring the app main directory..." --weight= ynh_restore_file --origin_path="$install_dir" -chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" chown -R $app:$app "$install_dir" @@ -72,25 +26,8 @@ ynh_script_progression --message="Restoring the data directory..." --weight=1 ynh_restore_file --origin_path="$data_dir" --not_mandatory -mkdir -p $data_dir -mkdir -p "$data_dir/uploads/" -mkdir -p "$data_dir/static/" -mkdir -p "$data_dir/static/emoji/" - -chmod 750 "$data_dir" -chmod -R o-rwx "$data_dir" chown -R $app:$app "$data_dir" -#================================================= -# SPECIFIC RESTORATION -#================================================= -# REINSTALL DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=1 - -# Define and install dependencies -#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies - #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= @@ -106,11 +43,8 @@ fi #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= -#REMOVEME? ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1 +ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1 -#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) -#REMOVEME? ynh_psql_test_if_first_run -#REMOVEME? 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 unaccent;" --database=$db_name ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --database=$db_name ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS citext;" --database=$db_name diff --git a/scripts/upgrade b/scripts/upgrade index d7a51ee..b965dd7 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -7,35 +7,11 @@ #================================================= source _common.sh -source ynh_package_version source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading settings..." --weight=1 - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) -#REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin) -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) -#REMOVEME? db_user=$db_name -#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) -#REMOVEME? admin_email=$(ynh_app_setting_get --app=$app --key=admin_email) -#REMOVEME? random_key=$(ynh_app_setting_get --app=$app --key=random_key) -#REMOVEME? name=$(ynh_app_setting_get --app=$app --key=name) -#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port) -#REMOVEME? cache=$(ynh_app_setting_get --app=$app --key=cache) -#REMOVEME? size=$(ynh_app_setting_get --app=$app --key=size) -#REMOVEME? registration=$(ynh_app_setting_get --app=$app --key=registration) - #================================================= # CHECK VERSION #================================================= -ynh_script_progression --message="Checking version..." --weight=1 upgrade_type=$(ynh_check_app_version_changed) @@ -51,20 +27,6 @@ abort_if_up_to_date # previous function is what defines 'version', more precisely the 'previous version' previous_version="${version}" -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1 - -# Backup the current version of the app -#REMOVEME? ynh_backup_before_upgrade -#REMOVEME? ynh_clean_setup () { - # Restore it if the upgrade fails -#REMOVEME? ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - #================================================= # STANDARD UPGRADE STEPS #================================================= @@ -83,52 +45,6 @@ fi #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 -# Cleaning legacy permissions -#REMOVEME? if ynh_legacy_permissions_exists; then -#REMOVEME? ynh_legacy_permissions_delete_all - - ynh_app_setting_delete --app=$app --key=is_public -fi - -# Create a permission if needed -#REMOVEME? if ! ynh_permission_exists --permission="api"; then -#REMOVEME? ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --auth_header="false" --show_tile="false" --protected="true" -fi - -# If db_name doesn't exist, create it -if [ -z "$db_name" ]; then - db_name=$(ynh_sanitize_dbid --db_name=$app) -#REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name -fi - -# If db_user doesn't exist, create it -if [ -z "$db_user" ]; then - db_user=$db_name -fi - -# If db_pwd doesn't exist, create it -if [ -z "$db_pwd" ]; then -#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) -#REMOVEME? ynh_app_setting_set --app=$app --key=psqlpwd --value=$db_pwd -fi - -# Switch variables name -#REMOVEME? psql_db=$(ynh_app_setting_get --app=$app --key=psql_db) - -if [ -n "$psql_db" ] -then -#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=psql_db) -#REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name - ynh_app_setting_delete --app=$app --key=psql_db -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 @@ -138,14 +54,6 @@ if [ ! -d "$install_dir/live" ]; then mv $install_dir/$app $install_dir/live fi -#================================================= -# CREATE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 - -# Create a dedicated user (if not existing) -#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" - #================================================= # UPGRADE TO OTP RELEASE #================================================= @@ -154,19 +62,6 @@ config="/etc/$app/config.exs" if ynh_version_gt "1.1.1~ynh1" "${previous_version}" ; then ynh_script_progression --message="Upgrading to OTP release..." --weight=1 - # Define app's data directory - data_dir="/home/yunohost.app/${app}" -#REMOVEME? ynh_app_setting_set --app=$app --key=data_dir --value="$data_dir" - - # Create app folders - mkdir -p "$data_dir/" - mkdir -p "$data_dir/uploads/" - mkdir -p "$data_dir/static/" - mkdir -p "$data_dir/static/emoji/" - - # Give permission to the data_dir - chown -R "$app":"$app" "$data_dir" - rsync -a "$install_dir/live/uploads/" "$data_dir/uploads/" if [ -d "$install_dir/live/instance/static/" ]; then rsync -a "$install_dir/live/instance/static/" "$data_dir/static/" @@ -183,7 +78,7 @@ if ynh_version_gt "1.1.1~ynh1" "${previous_version}" ; then ynh_backup_if_checksum_is_different --file="$config" -#REMOVEME? ynh_secure_remove --file="$install_dir/live" + ynh_secure_remove --file="$install_dir/live" fi if ynh_version_gt "2.0.5~ynh1" "${previous_version}" ; then @@ -204,22 +99,14 @@ if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." --weight=1 -#REMOVEME? ynh_secure_remove --file="$install_dir/live" + ynh_secure_remove --file="$install_dir/live" # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$install_dir/live" --source_id=$YNH_ARCH + ynh_setup_source --dest_dir="$install_dir/live" fi -chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" chown -R $app:$app "$install_dir" -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=1 - -#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies - #================================================= # NGINX CONFIGURATION #================================================= @@ -251,12 +138,10 @@ popd #================================================= ynh_script_progression --message="Updating a configuration file..." --weight=1 -config="/etc/$app/config.exs" +ynh_backup_if_checksum_is_different --file="/etc/$app/config.exs" -ynh_backup_if_checksum_is_different --file="$config" - -chmod 400 "$config" -chown $app:$app "$config" +chmod 400 "/etc/$app/config.exs" +chown $app:$app "/etc/$app/config.exs" #================================================= # SETUP SYSTEMD @@ -282,13 +167,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Access Pleroma.Web.Endpoint" -#================================================= -# RELOAD NGINX -#================================================= -#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/ynh_package_version b/scripts/ynh_package_version deleted file mode 100644 index 0887f5f..0000000 --- a/scripts/ynh_package_version +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -read_json () { - sudo python3 -c "import sys, json;print(json.load(open('$1'))['$2'])" -} - -read_manifest () { - if [ -f '../manifest.json' ] ; then - read_json '../manifest.json' "$1" - else - read_json '../settings/manifest.json' "$1" - fi -} -abort_if_up_to_date () { - version=$(read_json "/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" 'version' 2> /dev/null || echo '20160501-7') - last_version=$(read_manifest 'version') - if [ "${version}" = "${last_version}" ] && [ "$YNH_APP_UPGRADE_TYPE" != "UPGRADE_FORCED" ]; then - ynh_print_info "Up-to-date, nothing to do" - ynh_die "" 0 - fi -} - -ynh_version_gt () -{ - dpkg --compare-versions "$1" gt "$2" -} diff --git a/tests.toml b/tests.toml new file mode 100644 index 0000000..cbbeef1 --- /dev/null +++ b/tests.toml @@ -0,0 +1,3 @@ +test_format = 1.0 + +[default]