1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/plume_ynh.git synced 2024-09-03 20:15:54 +02:00

Merge pull request #90 from YunoHost-Apps/testing

Testing
This commit is contained in:
Éric Gaspar 2023-06-03 14:12:44 +02:00 committed by GitHub
commit aac8c8155c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 140 additions and 853 deletions

View file

@ -1,142 +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)
# TODO: Re-add "| select( .prerelease != true )" when Plume goes out of beta
version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | .tag_name' | sort -V | tail -1)
assets=($(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '[ .[] | select(.tag_name=="'$version'").assets[].browser_download_url ] | join(" ") | @sh' | tr -d "'"))
admin_repo="TryGhost/Admin"
assets+=("https://github.com/TryGhost/Admin/archive/refs/tags/${version}.zip")
# 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
# 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
# Each release can hold multiple assets (e.g. binaries for different architectures, source code, etc.)
echo "${#assets[@]} available asset(s)"
#=================================================
# UPDATE SOURCE FILES
#=================================================
# Here we use the $assets variable to get the resources published in the upstream release.
count=0
# Let's loop over the array of assets URLs
for asset_url in ${assets[@]}; do
echo "Handling asset at $asset_url"
# Assign the asset to a source file in conf/ directory
# Here we base the source file name upon a unique keyword in the assets url (admin vs. update)
# Leave $src empty to ignore the asset
case $asset_url in
*"plume-postgres.tar.gz")
src="amd64"
;;
*)
src=""
;;
esac
# If $src is not empty, let's process the asset
if [ ! -z "$src" ]; then
# Create the temporary directory
tempdir="$(mktemp -d)"
# Download sources and calculate checksum
filename=${asset_url##*/}
curl --silent -4 -L $asset_url -o "$tempdir/$filename"
checksum=$(sha256sum "$tempdir/$filename" | head -c 64)
# Delete temporary directory
rm -rf $tempdir
# Get extension
if [[ $filename == *.tar.gz ]]; then
extension=tar.gz
else
extension=${filename##*.}
fi
# Rewrite source file
cat <<EOT > conf/$src.src
SOURCE_URL=$asset_url
SOURCE_SUM=$checksum
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=$extension
SOURCE_IN_SUBDIR=false
EOT
echo "... conf/$src.src updated"
count=$((count+1))
else
echo "... asset ignored"
fi
done
if [ $count == 0 ]; then
echo "::warning ::None of the assets were processed."
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

View file

@ -1,51 +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 <yunohost-bot@users.noreply.github.com>'
author: 'yunohost-bot <yunohost-bot@users.noreply.github.com>'
signoff: false
branch: ci-auto-update-v${{ env.VERSION }}
base: testing
delete-branch: true
title: 'Upgrade to version ${{ env.VERSION }}'
body: |
Upgrade to v${{ env.VERSION }}
TODO:
- [ ] Add arm64 binaries
draft: false

View file

@ -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 ./

View file

@ -19,7 +19,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
Federated blogging engine, based on ActivityPub. It uses the Rocket framework, and Diesel to interact with the database. Federated blogging engine, based on ActivityPub. It uses the Rocket framework, and Diesel to interact with the database.
**Shipped version:** 0.7.2~ynh1 **Shipped version:** 0.7.2~ynh2
**Demo:** https://joinplu.me/#instances **Demo:** https://joinplu.me/#instances
@ -27,20 +27,6 @@ Federated blogging engine, based on ActivityPub. It uses the Rocket framework, a
![Screenshot of Plume](./doc/screenshots/screenshot.png) ![Screenshot of Plume](./doc/screenshots/screenshot.png)
## Disclaimers / important information
**Warning:** The package can take **15 to 30 minutes** to complete depending on your system configuration. **Don't intrupt the installation process while installing.**
## Important points to read before installing
1. **Plume** is still in **pre-release** stage and undergoing heavy development, so there can be **bugs**.
1. **Plume** requires a dedicated **root domain**, eg. plume.domain.tld
1. **Plume** requires a valid **certificate** installed on the domain. YunoHost can **install a Let's Encrypt certificate** on the domain from **admin web-interface** or through **command-line**.
1. This package is **multi-instance** that means you can run **multiple Plume instances** on a **single server**.
#### Multi-user support
LDAP is activated but HTTP auth is not supported
## Documentation and resources ## Documentation and resources
* Official app website: <https://joinplu.me/> * Official app website: <https://joinplu.me/>

View file

@ -19,7 +19,7 @@ Si vous navez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po
Federated blogging engine, based on ActivityPub. It uses the Rocket framework, and Diesel to interact with the database. Federated blogging engine, based on ActivityPub. It uses the Rocket framework, and Diesel to interact with the database.
**Version incluse :** 0.7.2~ynh1 **Version incluse :** 0.7.2~ynh2
**Démo :** https://joinplu.me/#instances **Démo :** https://joinplu.me/#instances
@ -27,20 +27,6 @@ Federated blogging engine, based on ActivityPub. It uses the Rocket framework, a
![Capture décran de Plume](./doc/screenshots/screenshot.png) ![Capture décran de Plume](./doc/screenshots/screenshot.png)
## Avertissements / informations importantes
**Warning:** The package can take **15 to 30 minutes** to complete depending on your system configuration. **Don't intrupt the installation process while installing.**
## Important points to read before installing
1. **Plume** is still in **pre-release** stage and undergoing heavy development, so there can be **bugs**.
1. **Plume** requires a dedicated **root domain**, eg. plume.domain.tld
1. **Plume** requires a valid **certificate** installed on the domain. YunoHost can **install a Let's Encrypt certificate** on the domain from **admin web-interface** or through **command-line**.
1. This package is **multi-instance** that means you can run **multiple Plume instances** on a **single server**.
#### Multi-user support
LDAP is activated but HTTP auth is not supported
## Documentations et ressources ## Documentations et ressources
* Site officiel de lapp : <https://joinplu.me/> * Site officiel de lapp : <https://joinplu.me/>

View file

@ -1,48 +0,0 @@
;; Test complet
; Manifest
domain="domain.tld"
is_public=1
admin="john"
password="pass"
name="my blog"
registration=0
; Checks
pkg_linter=1
setup_sub_dir=0
setup_root=1
setup_nourl=0
setup_private=1
setup_public=1
upgrade=1
# 0.3.0-alpha-2~ynh1
upgrade=1 from_commit=279716dff5fc79cc84ae2d7799c8094017ac028e
# 0.4.0-alpha-4~ynh1
upgrade=1 from_commit=e99273dfb8df763ebbd41d51ee34d92776dfcbf0
# 0.5.0~ynh1
upgrade=1 from_commit=457f1dd7719286f28755d9561133a8e176be63c7
# 0.6.0~ynh1
upgrade=1 from_commit=0f9c1c6e3c151e94e5f53b1464aec732334209a3
# 0.6.0~ynh2
upgrade=1 from_commit=583e101b12a081c45bee50df9068e606b5983bb2
# 0.7.1~ynh1
upgrade=1 from_commit=655ae344f49a20eb4c335034244b547c9e56e6a0
backup_restore=1
multi_instance=1
port_already_use=0
change_url=1
;;; Options
Email=
Notification=none
;;; Upgrade options
; commit=279716dff5fc79cc84ae2d7799c8094017ac028e
name=0.3.0-alpha-2~ynh1
; commit=e99273dfb8df763ebbd41d51ee34d92776dfcbf0
name=0.4.0-alpha-4~ynh1
; commit=457f1dd7719286f28755d9561133a8e176be63c7
name=0.5.0~ynh1
; commit=0f9c1c6e3c151e94e5f53b1464aec732334209a3
name=0.6.0~ynh1
; commit=583e101b12a081c45bee50df9068e606b5983bb2
name=0.6.0~ynh2
; commit=655ae344f49a20eb4c335034244b547c9e56e6a0
name=0.7.1~ynh1

View file

@ -1,5 +0,0 @@
SOURCE_URL=https://github.com/Plume-org/Plume/releases/download/0.7.2/plume-postgres.tar.gz
SOURCE_SUM=1a8c5a931fef25920503c9ae577b1c180ba7709e88f3d47b077ae80e2d9ea9ef
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=false

View file

@ -1,5 +0,0 @@
SOURCE_URL=https://github.com/YunoHost-Apps/plume_ynh/releases/download/0.7.2/plume-arm64-postgres.tar.gz
SOURCE_SUM=921b3b209b2f3cb352c676ecb93730aa4732e239a53f59f1ec5f128d5b28ec42
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=false

View file

@ -1,6 +1,7 @@
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ { location __PATH__/ {
proxy_pass http://localhost:__PORT__/; proxy_pass http://127.0.0.1:__PORT__;
proxy_set_header Host $http_host; proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

View file

@ -1,13 +1,13 @@
[Unit] [Unit]
Description=plume Description=Plume
After=network.target After=network.target
[Service] [Service]
Type=simple Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/__APP__ WorkingDirectory=__INSTALL_DIR__/__APP__
ExecStart=/bin/sh -c '__FINALPATH__/.cargo/bin/plume >> /var/log/__APP__/__APP__.log 2>&1' ExecStart=/bin/sh -c '__INSTALL_DIR__/.cargo/bin/plume >> /var/log/__APP__/__APP__.log 2>&1'
TimeoutSec=30 TimeoutSec=30
Restart=always Restart=always

View file

@ -1,11 +0,0 @@
**Warning:** The package can take **15 to 30 minutes** to complete depending on your system configuration. **Don't intrupt the installation process while installing.**
## Important points to read before installing
1. **Plume** is still in **pre-release** stage and undergoing heavy development, so there can be **bugs**.
1. **Plume** requires a dedicated **root domain**, eg. plume.domain.tld
1. **Plume** requires a valid **certificate** installed on the domain. YunoHost can **install a Let's Encrypt certificate** on the domain from **admin web-interface** or through **command-line**.
1. This package is **multi-instance** that means you can run **multiple Plume instances** on a **single server**.
#### Multi-user support
LDAP is activated but HTTP auth is not supported

View file

@ -1,69 +0,0 @@
{
"name": "Plume",
"id": "plume",
"packaging_format": 1,
"description": {
"en": "Federated blogging application",
"fr": "Application de blogging fédérée"
},
"version": "0.7.2~ynh1",
"url": "https://joinplu.me/",
"upstream": {
"license": "AGPL-3.0-only",
"website": "https://joinplu.me/",
"demo": "https://joinplu.me/#instances",
"admindoc": "https://docs.joinplu.me/",
"code": "https://github.com/Plume-org/Plume"
},
"license": "AGPL-3.0-only",
"maintainer": {
"name": "yalh76"
},
"requirements": {
"yunohost": ">= 4.3.0"
},
"multi_instance": true,
"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 Plume instance",
"fr": "Choisissez un nom pour votre instance Plume"
},
"example": "My blog",
"default": "My blog"
},
{
"name": "registration",
"type": "boolean",
"ask": {
"en": "Is registrations open to everyone?",
"fr": "Les inscriptions sont-elles ouvertes à tout le monde ?"
},
"default": false
}
]
}
}

78
manifest.toml Normal file
View file

@ -0,0 +1,78 @@
packaging_format = 2
id = "plume"
name = "Plume"
description.en = "Federated blogging application"
description.fr = "Application de blogging fédérée"
version = "0.7.2~ynh2"
maintainers = ["yalh76"]
[upstream]
license = "AGPL-3.0-only"
website = "https://joinplu.me/"
demo = "https://joinplu.me/#instances"
admindoc = "https://docs.joinplu.me/"
code = "https://github.com/Plume-org/Plume"
[integration]
yunohost = ">= 11.1.19"
architectures = ["amd64", "arm64"]
multi_instance = true
ldap = true
sso = false
disk = "50M"
ram.build = "50M"
ram.runtime = "50M"
[install]
[install.domain]
type = "domain"
full_domain = true
[install.init_main_permission]
type = "group"
default = "visitors"
[install.admin]
type = "user"
[install.password]
type = "password"
[install.name]
ask.en = "Choose a name for your Plume instance"
ask.fr = "Choisissez un nom pour votre instance Plume"
type = "string"
example = "My blog"
default = "My blog"
[install.registration]
ask.en = "Is registrations open to everyone?"
ask.fr = "Les inscriptions sont-elles ouvertes à tout le monde ?"
type = "boolean"
default = false
[resources]
[resources.sources.main]
in_subdir = false
arm64.url = "https://github.com/YunoHost-Apps/plume_ynh/releases/download/0.7.2/plume-arm64-postgres.tar.gz"
arm64.sha256 = "921b3b209b2f3cb352c676ecb93730aa4732e239a53f59f1ec5f128d5b28ec42"
amd64.url = "https://github.com/Plume-org/Plume/releases/download/0.7.2/plume-postgres.tar.gz"
amd64.sha256 = "1a8c5a931fef25920503c9ae577b1c180ba7709e88f3d47b077ae80e2d9ea9ef"
[resources.ports]
[resources.system_user]
[resources.install_dir]
[resources.permissions]
main.url = "/"
[resources.apt]
packages = "postgresql postgresql-contrib"
[resources.database]
type = "postgresql"

View file

@ -4,9 +4,6 @@
# COMMON VARIABLES # COMMON VARIABLES
#================================================= #=================================================
# dependencies used by the app
pkg_dependencies="postgresql postgresql-contrib"
#================================================= #=================================================
# PERSONAL HELPERS # PERSONAL HELPERS
#================================================= #=================================================

View file

@ -10,27 +10,6 @@
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers 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)
#================================================= #=================================================
# DECLARE DATA AND CONF FILES TO BACKUP # DECLARE DATA AND CONF FILES TO BACKUP
#================================================= #=================================================
@ -40,7 +19,7 @@ ynh_print_info --message="Declaring files to be backed up..."
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
ynh_backup --src_path="$final_path" ynh_backup --src_path="$install_dir"
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # BACKUP THE NGINX CONFIGURATION

View file

@ -9,60 +9,6 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
old_domain=$YNH_APP_OLD_DOMAIN
old_path=$YNH_APP_OLD_PATH
new_domain=$YNH_APP_NEW_DOMAIN
new_path="/"
app=$YNH_APP_INSTANCE_NAME
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..."
# Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..."
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
ynh_clean_check_starting
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# CHECK WHICH PARTS SHOULD BE CHANGED
#=================================================
change_domain=0
if [ "$old_domain" != "$new_domain" ]
then
change_domain=1
fi
change_path=0
if [ "$old_path" != "$new_path" ]
then
change_path=1
fi
#================================================= #=================================================
# STANDARD MODIFICATIONS # STANDARD MODIFICATIONS
#================================================= #=================================================
@ -77,29 +23,7 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --li
#================================================= #=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." ynh_script_progression --message="Updating NGINX web server configuration..."
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf ynh_change_url_nginx_config
# 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
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
# Set global variables for NGINX helper
domain="$old_domain"
path_url="$new_path"
# Create a dedicated NGINX config
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
ynh_delete_file_checksum --file="$nginx_conf_path"
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
# Store file checksum for the new config file location
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi
#================================================= #=================================================
# SPECIFIC MODIFICATIONS # SPECIFIC MODIFICATIONS
@ -108,7 +32,7 @@ fi
#================================================= #=================================================
ynh_script_progression --message="Modifying a config file..." ynh_script_progression --message="Modifying a config file..."
config_file="$final_path/$app/.env" config_file="$install_dir/$app/.env"
ynh_backup_if_checksum_is_different --file=$config_file ynh_backup_if_checksum_is_different --file=$config_file
ynh_replace_string --match_string="$old_domain" --replace_string="$new_domain" --target_file=$config_file ynh_replace_string --match_string="$old_domain" --replace_string="$new_domain" --target_file=$config_file
@ -125,13 +49,6 @@ ynh_script_progression --message="Starting a systemd service..."
# Start a systemd service # Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started plume" ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started plume"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -9,125 +9,45 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#================================================= #=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST # RETRIEVE ARGUMENTS FROM THE MANIFEST
#================================================= #=================================================
domain=$YNH_APP_ARG_DOMAIN
path_url="/"
is_public=$YNH_APP_ARG_IS_PUBLIC
admin=$YNH_APP_ARG_ADMIN
password=$YNH_APP_ARG_PASSWORD
instance_name=$YNH_APP_ARG_NAME
registration=$YNH_APP_ARG_REGISTRATION
admin_email=$(ynh_user_get_info $admin 'mail') admin_email=$(ynh_user_get_info $admin 'mail')
secret_key=$(ynh_string_random --length=32 | base64) secret_key=$(ynh_string_random --length=32 | base64)
architecture=$YNH_ARCH
app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters..."
# Check machine architecture (in particular, we don't support ARM and 32bit machines)
if [ $architecture == "armhf" ]
then
ynh_die --message="Sorry, but this app can only be installed on a 64 bits machine :("
fi
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 # STORE SETTINGS FROM MANIFEST
#================================================= #=================================================
ynh_script_progression --message="Storing installation settings..." ynh_script_progression --message="Storing installation settings..."
ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set --app=$app --key=admin --value=$admin
ynh_app_setting_set --app=$app --key=instance --value="$instance_name"
ynh_app_setting_set --app=$app --key=registration --value=$registration
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=secret_key --value=$secret_key ynh_app_setting_set --app=$app --key=secret_key --value=$secret_key
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# FIND AND OPEN A PORT
#=================================================
ynh_script_progression --message="Finding an available port..."
# Find an available port
port=$(ynh_find_port --port=8095)
ynh_app_setting_set --app=$app --key=port --value=$port
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..."
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..."
# 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..."
db_name=$(ynh_sanitize_dbid --db_name=$app)
db_user=$db_name
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_psql_test_if_first_run
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." ynh_script_progression --message="Setting up source files..."
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path/$app" --source_id=$architecture ynh_setup_source --dest_dir="$install_dir/$app"
# Create the media directory, where uploads will be stored # Create the media directory, where uploads will be stored
mkdir -p $final_path/media mkdir -p $install_dir/media
# Create the cargo directory # Create the cargo directory
mkdir -p $final_path/.cargo/bin mkdir -p $install_dir/.cargo/bin
# Move binaries # Move binaries
mv $final_path/$app/bin/* $final_path/.cargo/bin/ mv $install_dir/$app/bin/* $install_dir/.cargo/bin/
chmod +x $final_path/.cargo/bin/* chmod +x $install_dir/.cargo/bin/*
# Remove empty bin directory # Remove empty bin directory
ynh_secure_remove --file="$final_path/$app/bin" ynh_secure_remove --file="$install_dir/$app/bin"
chmod 750 "$final_path" chmod 750 "$install_dir"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$install_dir"
chown -R $app:$app "$final_path" chown -R $app:$app "$install_dir"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
@ -151,10 +71,10 @@ chown -R "$app":"$app" "/var/log/$app"
#================================================= #=================================================
ynh_script_progression --message="Adding a config file..." ynh_script_progression --message="Adding a config file..."
ynh_add_config --template="../conf/.env" --destination="$final_path/$app/.env" ynh_add_config --template="../conf/.env" --destination="$install_dir/$app/.env"
chmod 400 "$final_path/$app/.env" chmod 400 "$install_dir/$app/.env"
chown $app:$app "$final_path/$app/.env" chown $app:$app "$install_dir/$app/.env"
#================================================= #=================================================
# MAKE SETUP # MAKE SETUP
@ -162,26 +82,26 @@ chown $app:$app "$final_path/$app/.env"
ynh_script_progression --message="Making setup..." ynh_script_progression --message="Making setup..."
# Set right permissions # Set right permissions
chown -R "$app":"$app" $final_path chown -R "$app":"$app" $install_dir
export PATH="$PATH:$final_path/.cargo/bin:$final_path/.local/bin:/usr/local/sbin" export PATH="$PATH:$install_dir/.cargo/bin:$install_dir/.local/bin:/usr/local/sbin"
pushd $final_path/$app pushd $install_dir/$app
sudo -u "$app" env PATH=$PATH plm migration run sudo -u "$app" env PATH=$PATH plm migration run
# Add new instance # Add new instance
if [ $registration -eq 1 ] if [ $registration -eq 1 ]
then then
sudo -u "$app" env PATH=$PATH plm instance new --domain "$domain" --name "$instance_name" -l 'CC-BY' sudo -u "$app" env PATH=$PATH plm instance new --domain "$domain" --name "$name" -l 'CC-BY'
else else
sudo -u "$app" env PATH=$PATH plm instance new --private --domain "$domain" --name "$instance_name" -l 'CC-BY' sudo -u "$app" env PATH=$PATH plm instance new --private --domain "$domain" --name "$name" -l 'CC-BY'
fi fi
# Add admin user # Add admin user
sudo -u "$app" env PATH=$PATH plm users new --admin -n "$admin" -N "$admin" --email "$admin_email" --password "$password" sudo -u "$app" env PATH=$PATH plm users new --admin -n "$admin" -N "$admin" --email "$admin_email" --password "$password"
# Initialise search index # Initialise search index
sudo -u "$app" env PATH=$PATH plm search init -p $final_path/$app sudo -u "$app" env PATH=$PATH plm search init -p $install_dir/$app
popd popd
#================================================= #=================================================
@ -192,21 +112,9 @@ ynh_script_progression --message="Configuring a systemd service..."
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config ynh_add_systemd_config
#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Configuring log rotation..."
# Use logrotate to manage application logfile(s) # Use logrotate to manage application logfile(s)
ynh_use_logrotate ynh_use_logrotate
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description="$app daemon for Plume" --log="/var/log/$app/$app.log" yunohost service add $app --description="$app daemon for Plume" --log="/var/log/$app/$app.log"
#================================================= #=================================================
@ -216,26 +124,6 @@ ynh_script_progression --message="Starting a systemd service..."
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started plume" ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started plume"
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring permissions..."
# Make app public if necessary
if [ $is_public -eq 1 ]
then
# Everyone can access the app.
# The "main" permission is automatically created before the install script.
ynh_permission_update --permission="main" --add="visitors"
fi
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -9,19 +9,6 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get --app=$app --key=port)
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)
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
#================================================= #=================================================
@ -35,43 +22,12 @@ then
yunohost service remove $app yunohost service remove $app
fi fi
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
ynh_script_progression --message="Stopping and removing the systemd service..."
# Remove the dedicated systemd config # Remove the dedicated systemd config
ynh_remove_systemd_config ynh_remove_systemd_config
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..."
# Remove the app-specific logrotate config # Remove the app-specific logrotate config
ynh_remove_logrotate ynh_remove_logrotate
#=================================================
# REMOVE THE POSTGRESQL DATABASE
#=================================================
ynh_script_progression --message="Removing the PostgreSQL database..."
# 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..."
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..."
# Remove the dedicated NGINX config # Remove the dedicated NGINX config
ynh_remove_nginx_config ynh_remove_nginx_config
@ -80,12 +36,9 @@ ynh_remove_nginx_config
#================================================= #=================================================
ynh_script_progression --message="Removing dependencies..." ynh_script_progression --message="Removing dependencies..."
# Remove metapackage and its dependencies export PATH="$PATH:$install_dir/.cargo/bin:$install_dir/.local/bin:/usr/local/sbin"
ynh_remove_app_dependencies
export PATH="$PATH:$final_path/.cargo/bin:$final_path/.local/bin:/usr/local/sbin" pushd $install_dir/$app
pushd $final_path/$app
sudo -u "$app" env PATH=$PATH cargo uninstall diesel_cli sudo -u "$app" env PATH=$PATH cargo uninstall diesel_cli
popd popd
@ -103,16 +56,6 @@ ynh_script_progression --message="Removing various files..."
# Remove the log files # Remove the log files
ynh_secure_remove --file="/var/log/$app" ynh_secure_remove --file="/var/log/$app"
#=================================================
# GENERIC FINALIZATION
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_script_progression --message="Removing the dedicated system user..."
# Delete a system user
ynh_system_user_delete --username=$app
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -10,65 +10,15 @@
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..."
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=psqlpwd)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..."
test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX web server configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..."
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir=$final_path
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Restoring the app main directory..." ynh_script_progression --message="Restoring the app main directory..."
ynh_restore_file --origin_path="$final_path" ynh_restore_file --origin_path="$install_dir"
chmod 750 "$final_path" chmod -R o-rwx "$install_dir"
chmod -R o-rwx "$final_path" chown -R $app:$app "$install_dir"
chown -R $app:$app "$final_path"
#================================================= #=================================================
# CREATE LOG FOLDER # CREATE LOG FOLDER
@ -78,23 +28,11 @@ ynh_script_progression --message="Creating log folder..."
mkdir -p "/var/log/$app" mkdir -p "/var/log/$app"
chown -R "$app":"$app" "/var/log/$app" chown -R "$app":"$app" "/var/log/$app"
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..."
# Define and install dependencies
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# RESTORE THE POSTGRESQL DATABASE # RESTORE THE POSTGRESQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Restoring the PostgreSQL database..." ynh_script_progression --message="Restoring the PostgreSQL database..."
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_file_as_root --file="./db.sql" --database="$db_name"
#================================================= #=================================================
@ -102,21 +40,13 @@ ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name"
#================================================= #=================================================
ynh_script_progression --message="Restoring the systemd configuration..." ynh_script_progression --message="Restoring the systemd configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore_file --origin_path="/etc/systemd/system/$app.service" ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet systemctl enable $app.service --quiet
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the logrotate configuration..."
ynh_restore_file --origin_path="/etc/logrotate.d/$app" ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description="$app daemon for Plume" --log="/var/log/$app/$app.log" yunohost service add $app --description="$app daemon for Plume" --log="/var/log/$app/$app.log"
#================================================= #=================================================
@ -126,13 +56,6 @@ ynh_script_progression --message="Starting a systemd service..."
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started plume" ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started plume"
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================

View file

@ -9,46 +9,12 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..."
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=psqlpwd)
port=$(ynh_app_setting_get --app=$app --key=port)
secret_key=$(ynh_app_setting_get --app=$app --key=secret_key)
architecture=$YNH_ARCH
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
#================================================= #=================================================
ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed) 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)..."
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
ynh_clean_check_starting
# 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 # STANDARD UPGRADE STEPS
#================================================= #=================================================
@ -58,46 +24,6 @@ ynh_script_progression --message="Stopping a systemd service..."
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped plume" ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped plume"
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..."
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
# Fix previous database name
psql_db=$(ynh_app_setting_get --app=$app --key=psql_db)
if [ -n "$psql_db" ]
then
db_name=$(ynh_app_setting_get --app=$app --key=psql_db)
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
ynh_app_setting_delete --app=$app --key=psql_db
ynh_app_setting_delete --app=$app --key=psqlpwd
fi
# Closing 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
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..."
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir=$final_path
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
@ -107,19 +33,18 @@ then
ynh_script_progression --message="Upgrading source files..." ynh_script_progression --message="Upgrading source files..."
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path/$app" --source_id=$architecture --keep="$app/.env" ynh_setup_source --dest_dir="$install_dir/$app" --keep="$app/.env"
# Move binaries # Move binaries
mv $final_path/$app/bin/* $final_path/.cargo/bin/ mv $install_dir/$app/bin/* $install_dir/.cargo/bin/
chmod +x $final_path/.cargo/bin/* chmod +x $install_dir/.cargo/bin/*
# Remove empty bin directory # Remove empty bin directory
ynh_secure_remove --file="$final_path/$app/bin" ynh_secure_remove --file="$install_dir/$app/bin"
fi fi
chmod 750 "$final_path" chmod -R o-rwx "$install_dir"
chmod -R o-rwx "$final_path" chown -R $app:$app "$install_dir"
chown -R $app:$app "$final_path"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
@ -129,13 +54,6 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..."
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_add_nginx_config
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..."
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# SPECIFIC UPGRADE # SPECIFIC UPGRADE
#================================================= #=================================================
@ -151,19 +69,19 @@ chown -R "$app":"$app" "/var/log/$app"
#================================================= #=================================================
ynh_script_progression --message="Updating a configuration file..." ynh_script_progression --message="Updating a configuration file..."
ynh_add_config --template="../conf/.env" --destination="$final_path/$app/.env" ynh_add_config --template="../conf/.env" --destination="$install_dir/$app/.env"
chmod 400 "$final_path/$app/.env" chmod 400 "$install_dir/$app/.env"
chown $app:$app "$final_path/$app/.env" chown $app:$app "$install_dir/$app/.env"
#================================================= #=================================================
# MAKE SETUP # MAKE SETUP
#================================================= #=================================================
ynh_script_progression --message="Making setup..." ynh_script_progression --message="Making setup..."
export PATH="$PATH:$final_path/.cargo/bin:$final_path/.local/bin:/usr/local/sbin" export PATH="$PATH:$install_dir/.cargo/bin:$install_dir/.local/bin:/usr/local/sbin"
pushd $final_path/$app pushd $install_dir/$app
sudo -u "$app" env PATH=$PATH plm migration run sudo -u "$app" env PATH=$PATH plm migration run
popd popd
@ -199,13 +117,6 @@ ynh_script_progression --message="Starting a systemd service..."
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started plume" ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started plume"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

16
tests.toml Normal file
View file

@ -0,0 +1,16 @@
test_format = 1.0
[default]
# -------------------------------
# Default args to use for install
# -------------------------------
args.name="my blog"
args.registration=0
# -------------------------------
# Commits to test upgrade from
# -------------------------------
test_upgrade_from.655ae344f49a20eb4c335034244b547c9e56e6a0.name = "Upgrade from 0.7.1~ynh1"