Merge pull request #37 from YunoHost-Apps/manifestv2

initial manifestv2
This commit is contained in:
Salamandar 2024-03-07 17:37:54 +01:00 committed by GitHub
commit 8084d6fdcc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 212 additions and 656 deletions

View file

@ -1,5 +1,5 @@
<!--
N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/README-generator
N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/readme_generator
It shall NOT be edited by hand.
-->
@ -27,27 +27,17 @@ A search engine for [PeerTube](https://joinpeertube.org/) videos and channels, d
![Screenshot of PeerTube search-index](./doc/screenshots/sepia-search-screenshot.png)
## Disclaimers / important information
## Important points to read before installing
1. **PeerTube search-index** requires a dedicated **root domain**, e.g. search.domain.tld
## Configuration
To configure this app: modify the file `/var/www/peertube-search-index/config/production.yaml` with SSH.
## :red_circle: Antifeatures
- **Not totally free upstream**: The packaged app is under an overall free licence, but with clauses that restrict its use.
## Documentation and resources
* Official app website: <https://search.joinpeertube.org/>
* Official admin documentation: <https://framagit.org/framasoft/peertube/search-index>
* Upstream app code repository: <https://framagit.org/framasoft/peertube/search-index>
* YunoHost Store: <https://apps.yunohost.org/app/peertube-search-index>
* Report a bug: <https://github.com/YunoHost-Apps/peertube-search-index_ynh/issues>
- Official app website: <https://search.joinpeertube.org/>
- Official admin documentation: <https://framagit.org/framasoft/peertube/search-index>
- Upstream app code repository: <https://framagit.org/framasoft/peertube/search-index>
- YunoHost Store: <https://apps.yunohost.org/app/peertube-search-index>
- Report a bug: <https://github.com/YunoHost-Apps/peertube-search-index_ynh/issues>
## Developer info

View file

@ -1,5 +1,5 @@
<!--
N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/README-generator
N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/readme_generator
It shall NOT be edited by hand.
-->
@ -27,27 +27,17 @@ A search engine for [PeerTube](https://joinpeertube.org/) videos and channels, d
![Capture décran de PeerTube search-index](./doc/screenshots/sepia-search-screenshot.png)
## Avertissements / informations importantes
## :red_circle: Anti-fonctionnalités
## Important points to read before installing
1. **PeerTube search-index** requires a dedicated **root domain**, e.g. search.domain.tld
## Configuration
To configure this app: modify the file `/var/www/peertube-search-index/config/production.yaml` with SSH.
## :red_circle: Fonctions indésirables
- **Not totally free upstream**: The packaged app is under an overall free licence, but with clauses that restrict its use.
- **Not totally free upstream** : The packaged app is under an overall free licence, but with clauses that restrict its use.
## Documentations et ressources
* Site officiel de lapp : <https://search.joinpeertube.org/>
* Documentation officielle de ladmin : <https://framagit.org/framasoft/peertube/search-index>
* Dépôt de code officiel de lapp : <https://framagit.org/framasoft/peertube/search-index>
* YunoHost Store: <https://apps.yunohost.org/app/peertube-search-index>
* Signaler un bug : <https://github.com/YunoHost-Apps/peertube-search-index_ynh/issues>
- Site officiel de lapp : <https://search.joinpeertube.org/>
- Documentation officielle de ladmin : <https://framagit.org/framasoft/peertube/search-index>
- Dépôt de code officiel de lapp : <https://framagit.org/framasoft/peertube/search-index>
- YunoHost Store : <https://apps.yunohost.org/app/peertube-search-index>
- Signaler un bug : <https://github.com/YunoHost-Apps/peertube-search-index_ynh/issues>
## Informations pour les développeurs

View file

@ -1,36 +0,0 @@
;; Test complet
; Manifest
domain="domain.tld"
is_public=1
; Checks
pkg_linter=1
setup_sub_dir=1
setup_root=1
setup_nourl=0
setup_private=1
setup_public=1
upgrade=1
# 0.0.1-2020-10-31~ynh1
# upgrade=1 from_commit=b0541627859d2b702b55f7ac33e7f786e70b3051
# 0.0.1-2020-12-24~ynh1
# upgrade=1 from_commit=103b86aa716d289cab00aee49e539cab252e21a3
# 0.0.1-2021-02-17~ynh1
# upgrade=1 from_commit=e9864a6c794ba3ec5e6359b298d299f513a157e7
# 0.0.1.2021.12.28~ynh1
upgrade=1 from_commit=3409d4986706a0b89c36447a2f435f4cd8dde155
backup_restore=1
multi_instance=1
port_already_use=0
change_url=1
;;; Options
Email=
Notification=none
;;; Upgrade options
; commit=b0541627859d2b702b55f7ac33e7f786e70b3051
name=0.0.1-2020-10-31~ynh1
; commit=103b86aa716d289cab00aee49e539cab252e21a3
name=0.0.1-2020-12-24~ynh1
; commit=e9864a6c794ba3ec5e6359b298d299f513a157e7
name=0.0.1-2021-02-17~ynh1
; commit=3409d4986706a0b89c36447a2f435f4cd8dde155
name=0.0.1.2021.12.28~ynh1

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://framagit.org/framasoft/peertube/search-index/-/archive/36a36379b469982e6b2fc219825283e2470135e7/search-index-36a36379b469982e6b2fc219825283e2470135e7.tar.gz
SOURCE_SUM=d5f92138c38642cb1cf559f2260652203aa38cfd03c5811c49e9299d1cdfe3ef
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=search-index.tar.gz
SOURCE_EXTRACT=true

View file

@ -2,7 +2,7 @@
location __PATH__/ {
# Path to source
alias __FINALPATH__/;
alias __INSTALL_DIR__/sources/;
proxy_pass http://localhost:__PORT__;
proxy_set_header X-Real-IP $remote_addr;

View file

@ -5,11 +5,12 @@ After=network.target
[Service]
Type=simple
Environment=NODE_ENV=production
Environment=NODE_CONFIG_DIR=__FINALPATH__/config
Environment="__YNH_NODE_LOAD_PATH__"
Environment=NODE_CONFIG_DIR=__INSTALL_DIR__/sources/config
User=__APP__
Group=__APP__
ExecStart=__YNH_NPM__ start
WorkingDirectory=__FINALPATH__/
WorkingDirectory=__INSTALL_DIR__/sources/
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=__APP__

3
doc/ADMIN.md Normal file
View file

@ -0,0 +1,3 @@
## Configuration
To configure this app: modify the file `/var/www/peertube-search-index/config/production.yaml` with SSH.

View file

@ -1,7 +1,3 @@
## Important points to read before installing
1. **PeerTube search-index** requires a dedicated **root domain**, e.g. search.domain.tld
## Configuration
To configure this app: modify the file `/var/www/peertube-search-index/config/production.yaml` with SSH.

View file

@ -1,42 +0,0 @@
{
"name": "PeerTube search-index",
"id": "peertube-search-index",
"packaging_format": 1,
"description": {
"en": "Search engine for PeerTube videos and channels",
"fr": "Moteur de recherche de vidéos et chaînes PeerTube"
},
"version": "0.0.1.2023.08.08~ynh1",
"url": "https://search.joinpeertube.org/",
"upstream": {
"license": "AGPL-3.0-only",
"website": "https://search.joinpeertube.org/",
"demo": "https://search.joinpeertube.org/",
"admindoc": "https://framagit.org/framasoft/peertube/search-index",
"code": "https://framagit.org/framasoft/peertube/search-index"
},
"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
}
]
}
}

69
manifest.toml Normal file
View file

@ -0,0 +1,69 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json
packaging_format = 2
id = "peertube-search-index"
name = "PeerTube search-index"
description.en = "Search engine for PeerTube videos and channels"
description.fr = "Moteur de recherche de vidéos et chaînes PeerTube"
version = "0.0.1.2023.08.08~ynh1"
maintainers = ["yalh76"]
[upstream]
license = "AGPL-3.0-only"
website = "https://search.joinpeertube.org/"
demo = "https://search.joinpeertube.org/"
admindoc = "https://framagit.org/framasoft/peertube/search-index"
code = "https://framagit.org/framasoft/peertube/search-index"
fund = "https://framasoft.org/fr/#support"
[integration]
yunohost = ">= 4.3.0"
architectures = "all"
multi_instance = true
ldap = "not_relevant"
sso = "not_relevant"
disk = "2000M"
ram.build = "2000M"
ram.runtime = "2000M"
[install]
[install.domain]
type = "domain"
[install.init_main_permission]
type = "group"
default = "visitors"
[resources]
[resources.sources.main]
url = "https://framagit.org/framasoft/peertube/search-index/-/archive/316adda0db184cb36f0645a60dc8f6a1611ecd28/search-index-316adda0db184cb36f0645a60dc8f6a1611ecd28.tar.gz"
sha256 = "d5f92138c38642cb1cf559f2260652203aa38cfd03c5811c49e9299d1cdfe3ef"
# Unused because of submodules...
prefetch = false
autoupdate.strategy = "latest_gitlab_tag"
[resources.system_user]
[resources.install_dir]
[resources.permissions]
main.url = "/"
[resources.ports]
main.default = 8095
[resources.apt]
packages = ["git", ]
[resources.apt.extras.elastic]
repo = "deb https://artifacts.elastic.co/packages/oss-7.x/apt stable main"
key = "https://artifacts.elastic.co/GPG-KEY-elasticsearch"
packages = ["elasticsearch-oss"]
[resources.apt.extras.yarn]
repo = "deb https://dl.yarnpkg.com/debian/ stable main"
key = "https://dl.yarnpkg.com/debian/pubkey.gpg"
packages = ["yarn"]

View file

@ -4,21 +4,28 @@
# COMMON VARIABLES
#=================================================
# dependencies used by the app
pkg_dependencies="git"
extra_pkg_dependencies="elasticsearch-oss"
NODEJS_VERSION=16
REPOSITORY="https://framagit.org/framasoft/peertube/search-index"
COMMIT="316adda0db184cb36f0645a60dc8f6a1611ecd28"
#=================================================
# PERSONAL HELPERS
#=================================================
_git_clone_or_pull() {
repo_dir="$1"
upstream_repository=$(ynh_read_manifest --manifest_key='upstream.code')
upstream_url=$(ynh_read_manifest --manifest_key='resources.sources.main.url')
upstream_commit=$(echo "$upstream_url" | sed -e "s|^${upstream_repository}/-/archive/\([^/]*\)/.*|\1|")
if [ -d "$repo_dir" ]; then
ynh_exec_as "$app" git -C "$repo_dir" fetch --quiet
else
ynh_exec_as "$app" git clone "$upstream_repository" "$repo_dir" --quiet
fi
ynh_exec_as "$app" git -C "$repo_dir" checkout "$upstream_commit" --quiet
ynh_exec_as "$app" git -C "$repo_dir" submodule update --init --recursive
}
#=================================================
# EXPERIMENTAL HELPERS
#=================================================

View file

@ -10,26 +10,6 @@
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get --app=$app --key=domain)
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
@ -39,26 +19,16 @@ ynh_print_info --message="Declaring files to be backed up..."
# BACKUP THE APP MAIN DIR
#=================================================
ynh_backup --src_path="$final_path"
ynh_backup --src_path="$install_dir"
#=================================================
# BACKUP THE NGINX CONFIGURATION
# SYSTEM CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# SPECIFIC BACKUP
#=================================================
# BACKUP LOGROTATE
#=================================================
ynh_backup --src_path="/etc/logrotate.d/$app"
#=================================================
# BACKUP SYSTEMD
#=================================================
ynh_backup --src_path="/etc/systemd/system/$app.service"
#=================================================

View file

@ -9,68 +9,12 @@
source _common.sh
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)
# Add settings here as needed by your application
port=$(ynh_app_setting_get --app=$app --key=port)
#=================================================
# 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 () {
# 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
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..."
ynh_script_progression --message="Stopping $app's systemd service..."
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped $app search index daemon"
@ -79,52 +23,15 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --li
#=================================================
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
#=================================================
# ...
#=================================================
#=================================================
# GENERIC FINALISATION
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..."
ynh_script_progression --message="Starting $app's systemd service..."
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Server listening on port"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload
ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="Server listening on port"
#=================================================
# END OF SCRIPT

View file

@ -10,114 +10,42 @@ source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
# INSTALL NODEJS
#=================================================
ynh_script_progression --message="Installing NodeJS..."
ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
ynh_install_nodejs --nodejs_version="$NODEJS_VERSION"
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
# START ELASTICSEARCH
#=================================================
ynh_script_progression --message="Starting elasticsearch..."
domain=$YNH_APP_ARG_DOMAIN
path_url="/"
is_public=$YNH_APP_ARG_IS_PUBLIC
# Fix permissions in case of remove/reinstall
chown -R elasticsearch:elasticsearch /var/lib/elasticsearch
app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters..."
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
# Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression --message="Storing installation settings..."
ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# FIND AND OPEN A PORT
#=================================================
ynh_script_progression --message="Finding an available port..."
# 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_install_app_dependencies $pkg_dependencies
ynh_install_extra_app_dependencies --repo="deb https://artifacts.elastic.co/packages/oss-7.x/apt stable main" --package="$extra_pkg_dependencies" --key="https://artifacts.elastic.co/GPG-KEY-elasticsearch"
systemctl enable elasticsearch.service --quiet
systemctl start elasticsearch.service
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..."
# Create a system user
ynh_system_user_create --username=$app --home_dir=$final_path
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
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
_git_clone_or_pull "$install_dir/sources"
chmod -R o-rwx "$install_dir"
chown -R "$app:$app" "$install_dir"
install -d -o $app -g $app -m 0750 $final_path
ynh_exec_as $app git clone $REPOSITORY $final_path --quiet
pushd "$final_path"
ynh_exec_as $app git checkout $COMMIT --quiet
popd
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:$app "$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..."
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# SPECIFIC SETUP
#=================================================
# BUILDING
#=================================================
ynh_script_progression --message="Building..."
pushd "$final_path"
ynh_exec_as $app git submodule update --init --recursive
pushd "$install_dir/sources"
ynh_use_nodejs
ynh_exec_as $app env $ynh_node_load_PATH yarn install --pure-lockfile
ynh_exec_as $app mkdir -p "$final_path/dist"
ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm run build
ynh_exec_as "$app" env "$ynh_node_load_PATH" yarn install --pure-lockfile
ynh_exec_as "$app" mkdir -p "dist"
ynh_exec_as "$app" env "$ynh_node_load_PATH" "$ynh_npm" run build
popd
#=================================================
@ -125,63 +53,33 @@ popd
#=================================================
ynh_script_progression --message="Adding a config file..."
ynh_add_config --template="../conf/default.yaml" --destination="$final_path/config/production.yaml"
ynh_add_config --template="default.yaml" --destination="$install_dir/sources/config/production.yaml"
chmod 400 "$final_path/config/production.yaml"
chown $app:$app "$final_path/config/production.yaml"
chmod 400 "$install_dir/sources/config/production.yaml"
chown "$app:$app" "$install_dir/sources/config/production.yaml"
#=================================================
# SETUP SYSTEMD
# SYSTEM CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring a systemd service..."
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
# Create a dedicated systemd config
ynh_add_systemd_config
#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Configuring log rotation..."
yunohost service add "$app" --description="$app search index daemon"
# Use logrotate to manage application logfile(s)
ynh_use_logrotate
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description="$app search index daemon"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..."
ynh_script_progression --message="Starting $app's systemd service..."
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Server listening on port"
#=================================================
# 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
ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="Server listening on port"
#=================================================
# END OF SCRIPT

View file

@ -10,79 +10,24 @@ source _common.sh
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)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# STANDARD REMOVE
#=================================================
# REMOVE SERVICE INTEGRATION IN YUNOHOST
# REMOVE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status $app >/dev/null
then
ynh_script_progression --message="Removing $app service integration..."
yunohost service remove $app
if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then
yunohost service remove "$app"
fi
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
ynh_script_progression --message="Stopping and removing the systemd service..."
# Remove the dedicated systemd config
ynh_remove_systemd_config
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..."
# Remove the app-specific logrotate config
ynh_remove_logrotate
#=================================================
# 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
ynh_remove_nginx_config
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..."
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#=================================================
# 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
#=================================================

View file

@ -11,112 +11,49 @@ source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
# INSTALL NODEJS
#=================================================
ynh_script_progression --message="Reinstalling NodeJS..."
ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
ynh_install_nodejs --nodejs_version="$NODEJS_VERSION"
#=================================================
# LOAD SETTINGS
# START ELASTICSEARCH
#=================================================
ynh_script_progression --message="Loading installation settings..."
ynh_script_progression --message="Starting elasticsearch..."
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)
#=================================================
# 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
systemctl enable elasticsearch.service --quiet
systemctl start elasticsearch.service
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
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 "$final_path"
chown -R $app:$app "$final_path"
chmod -R o-rwx "$install_dir"
chown -R "$app:$app" "$install_dir"
#=================================================
# SPECIFIC RESTORATION
# RESTORE SYSTEM CONFIGURATIONS
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..."
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
ynh_install_extra_app_dependencies --repo="deb https://artifacts.elastic.co/packages/oss-7.x/apt stable main" --package="$extra_pkg_dependencies" --key="https://artifacts.elastic.co/GPG-KEY-elasticsearch"
systemctl enable elasticsearch.service --quiet
systemctl start elasticsearch.service
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
#=================================================
# RESTORE SYSTEMD
#=================================================
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"
systemctl enable $app.service --quiet
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the logrotate configuration..."
systemctl enable "$app.service" --quiet
yunohost service add "$app" --description="$app search index daemon"
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 search index daemon"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..."
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Server listening on port"
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="Server listening on port"
ynh_systemd_action --service_name=nginx --action=reload

View file

@ -9,126 +9,64 @@
source _common.sh
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)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
port=$(ynh_app_setting_get --app=$app --key=port)
#=================================================
# CHECK VERSION
#=================================================
ynh_script_progression --message="Checking version..."
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 () {
# 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
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..."
ynh_script_progression --message="Stopping $app's systemd service..."
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped $app search index daemon"
ynh_systemd_action --service_name="$app" --action="stop" --log_path="systemd" --line_match="Stopped $app search index daemon"
#=================================================
# INSTALL NODEJS
#=================================================
ynh_script_progression --message="Updating NodeJS..."
ynh_install_nodejs --nodejs_version="$NODEJS_VERSION"
#=================================================
# START ELASTICSEARCH
#=================================================
ynh_script_progression --message="Starting elasticsearch..."
systemctl enable elasticsearch.service --quiet
systemctl start elasticsearch.service
#=================================================
# 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
# Move git repository one step lower
if [ -d "$install_dir/.git" ]; then
mkdir "${install_dir}__tmp__"
mv "$install_dir" "${install_dir}__tmp__/sources"
mv "${install_dir}__tmp__" "$install_dir"
fi
# Fix upgrade from 0.0.1.2022.06.03~ynh1
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:$app "$final_path"
#=================================================
# 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
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R "$app:$app" "$install_dir"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Upgrading source files..."
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..."
_git_clone_or_pull "$install_dir/sources"
chmod -R o-rwx "$install_dir"
chown -R "$app:$app" "$install_dir"
# Download, check integrity, uncompress and patch the source from app.src
pushd "$final_path"
ynh_exec_as $app git checkout master
ynh_exec_as $app git pull --quiet
ynh_exec_as $app git checkout $COMMIT --quiet
popd
fi
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:$app "$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..."
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..."
ynh_install_app_dependencies $pkg_dependencies
ynh_install_extra_app_dependencies --repo="deb https://artifacts.elastic.co/packages/oss-7.x/apt stable main" --package="$extra_pkg_dependencies" --key="https://artifacts.elastic.co/GPG-KEY-elasticsearch"
systemctl enable elasticsearch.service --quiet
systemctl start elasticsearch.service
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
#=================================================
# SPECIFIC UPGRADE
#=================================================
# BUILDING
#=================================================
ynh_script_progression --message="Building..."
pushd "$final_path"
ynh_exec_as $app git submodule update --init --recursive
pushd "$install_dir/sources"
ynh_use_nodejs
ynh_exec_as $app env $ynh_node_load_PATH yarn install --pure-lockfile
ynh_exec_as $app mkdir -p "$final_path/dist"
ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm run build
ynh_exec_as "$app" env "$ynh_node_load_PATH" yarn install --pure-lockfile
ynh_exec_as "$app" mkdir -p "dist"
ynh_exec_as "$app" env "$ynh_node_load_PATH" "$ynh_npm" run build
popd
#=================================================
@ -136,49 +74,32 @@ popd
#=================================================
ynh_script_progression --message="Updating a config file..."
ynh_add_config --template="../conf/default.yaml" --destination="$final_path/config/production.yaml"
ynh_add_config --template="default.yaml" --destination="$install_dir/sources/config/production.yaml"
chmod 400 "$final_path/config/production.yaml"
chown $app:$app "$final_path/config/production.yaml"
chmod 400 "$install_dir/sources/config/production.yaml"
chown "$app:$app" "$install_dir/sources/config/production.yaml"
#=================================================
# SETUP SYSTEMD
# REAPPLY SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Upgrading systemd configuration..."
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
# Create a dedicated systemd config
ynh_add_systemd_config
#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Upgrading logrotate configuration..."
yunohost service add "$app" --description="$app search index daemon"
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description="$app search index daemon"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..."
ynh_script_progression --message="Starting $app's systemd service..."
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Server listening on port"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload
ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="Server listening on port"
#=================================================
# END OF SCRIPT

7
tests.toml Normal file
View file

@ -0,0 +1,7 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json
test_format = 1.0
[default]
test_upgrade_from.63fe9f9406b112c086b23f68aaaee3d3d990b862.name = "Last packaging v1 version"