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 #70 from YunoHost-Apps/example

apply example_ynh
This commit is contained in:
yalh76 2021-04-21 21:39:53 +02:00 committed by GitHub
commit 992dbce829
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 95 additions and 137 deletions

View file

@ -39,8 +39,8 @@ LDAP is activated but HTTP auth is not supported
#### Supported architectures
* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/plume%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/plume/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/plume%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/plume/)
* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/plume.svg)](https://ci-apps.yunohost.org/ci/apps/plume/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/plume.svg)](https://ci-apps-arm.yunohost.org/ci/apps/plume/)
## Limitations

View file

@ -1,7 +1,7 @@
;; Test complet
; Manifest
domain="domain.tld" (DOMAIN)
admin="john" (USER)
admin="john" (USER)
is_public=1 (PUBLIC|public=1|private=0)
password="pass"
name="my blog"
@ -20,13 +20,15 @@
upgrade=1 from_commit=e99273dfb8df763ebbd41d51ee34d92776dfcbf0
# 0.5.0~ynh1
upgrade=1 from_commit=457f1dd7719286f28755d9561133a8e176be63c7
# 0.6.0~ynh1
upgrade=1 from_commit=0f9c1c6e3c151e94e5f53b1464aec732334209a3
backup_restore=1
multi_instance=1
port_already_use=0
change_url=1
;;; Options
Email=anmol@datamol.org;yalh@yahoo.com
Notification=yes
Email=
Notification=none
;;; Upgrade options
; commit=279716dff5fc79cc84ae2d7799c8094017ac028e
name=0.3.0-alpha-2~ynh1
@ -34,3 +36,5 @@ Notification=yes
name=0.4.0-alpha-4~ynh1
; commit=457f1dd7719286f28755d9561133a8e176be63c7
name=0.5.0~ynh1
; commit=0f9c1c6e3c151e94e5f53b1464aec732334209a3
name=0.6.0~ynh1

View file

@ -6,17 +6,12 @@
"en": "Federated blogging application",
"fr": "Une application de blogging fédérée."
},
"version": "0.6.0~ynh1",
"version": "0.6.0~ynh2",
"url": "https://joinplu.me/",
"license": "AGPL-3.0-only",
"maintainer": [
{
"name": "Anmol Sharma",
"email": "anmol@datamol.org"
},
{
"name": "yalh76"
}],
"maintainer": {
"name": "yalh76"
},
"requirements": {
"yunohost": ">= 4.1.3"
},
@ -29,37 +24,21 @@
{
"name": "domain",
"type": "domain",
"ask": {
"en": "Choose a domain name for Plume",
"fr": "Choisissez un nom de domaine pour Plume"
},
"example": "example.com"
},
{
"name": "admin",
"type": "user",
"ask": {
"en": "Choose the Plume administrator (must be an existing YunoHost user)",
"fr": "Choisissez l'administrateur de Plume (doit être un utilisateur YunoHost existant)"
},
"example": "johndoe"
},
{
"name": "is_public",
"type": "boolean",
"ask": {
"en": "Is it a public application?",
"fr": "Est-ce une application publique ?"
},
"default": true
},
{
"name": "password",
"type": "password",
"ask": {
"en": "Set the administrator password",
"fr": "Définissez le mot de passe administrateur"
},
"example": "Choose a password"
},
{

View file

@ -6,7 +6,7 @@
# IMPORT GENERIC HELPERS
#=================================================
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers

View file

@ -35,9 +35,9 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before changing its url (may take a while)..."
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
@ -45,7 +45,7 @@ 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
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
@ -79,23 +79,23 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --li
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
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
# Change the path in the nginx config file
# 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
# 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
# Set global variables for NGINX helper
domain="$old_domain"
path_url="$new_path"
# Create a dedicated nginx config
# Create a dedicated NGINX config
ynh_add_nginx_config
fi
# Change the domain for nginx
# Change the domain for NGINX
if [ $change_domain -eq 1 ]
then
# Delete file checksum for the old conf file location
@ -132,7 +132,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --l
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading nginx web server..."
ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload

View file

@ -72,7 +72,7 @@ ynh_app_setting_set --app=$app --key=secret_key --value=$secret_key
#=================================================
# FIND AND OPEN A PORT
#=================================================
ynh_script_progression --message="Finding an available port ..."
ynh_script_progression --message="Finding an available port..."
# Find an available port
port=$(ynh_find_port --port=8095)
@ -81,10 +81,18 @@ ynh_app_setting_set --app=$app --key=port --value=$port
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies ..."
ynh_script_progression --message="Installing dependencies..."
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
#=================================================
@ -101,7 +109,7 @@ ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
#=================================================
# 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
@ -118,24 +126,20 @@ mv $final_path/$app/bin/* $final_path/.cargo/bin/
chmod +x $final_path/.cargo/bin/*
# Remove empty bin directory
ynh_secure_remove --file="$final_path/$app/bin/"
ynh_secure_remove --file="$final_path/$app/bin"
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..."
ynh_script_progression --message="Configuring NGINX web server..."
# Create a dedicated nginx config
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..."
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# SPECIFIC SETUP
#=================================================
@ -146,18 +150,14 @@ mkdir -p "/var/log/$app"
chown -R "$app":"$app" "/var/log/$app"
#=================================================
# MODIFY A CONFIG FILE
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Modifying a config file..."
ynh_script_progression --message="Adding a config file..."
# setup application config
config_file="$final_path/$app/.env"
cp "../conf/.env" $config_file
ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file=$config_file
ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file=$config_file
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file=$config_file
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file=$config_file
ynh_replace_string --match_string="__SECRET_KEY__" --replace_string="$secret_key" --target_file=$config_file
ynh_add_config --template="../conf/.env" --destination="$final_path/$app/.env"
chmod 400 "$final_path/$app/.env"
chown $app:$app "$final_path/$app/.env"
#=================================================
# MAKE SETUP
@ -195,24 +195,8 @@ ynh_script_progression --message="Configuring a systemd service..."
# Create a dedicated systemd config
ynh_add_systemd_config
#=================================================
# STORE THE CONFIG FILE CHECKSUM
#=================================================
ynh_script_progression --message="Storing the config file checksum..."
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum --file=$config_file
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
ynh_script_progression --message="Securing files and directories..."
# Set permissions to app files
chown -R $app: $final_path
#=================================================
# SETUP LOGROTATE
#=================================================
@ -226,7 +210,7 @@ ynh_use_logrotate
#=================================================
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"
#=================================================
# START SYSTEMD SERVICE
@ -251,7 +235,7 @@ fi
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading nginx web server..."
ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload

View file

@ -28,7 +28,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
# REMOVE SERVICE INTEGRATION IN YUNOHOST
#=================================================
# Remove the service from the list of services known by Yunohost (added from `yunohost service add`)
# 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..."
@ -80,9 +80,9 @@ ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing nginx web server configuration..."
ynh_script_progression --message="Removing NGINX web server configuration..."
# Remove the dedicated nginx config
# Remove the dedicated NGINX config
ynh_remove_nginx_config
#=================================================
@ -102,7 +102,6 @@ ynh_script_progression --message="Removing various files..."
# Remove the log files
ynh_secure_remove --file="/var/log/$app"
ynh_secure_remove --file="/var/log/$app/"
#=================================================
# GENERIC FINALIZATION

View file

@ -6,7 +6,7 @@
# IMPORT GENERIC HELPERS
#=================================================
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source ../settings/scripts/ynh_detect_arch__2
source /usr/share/yunohost/helpers
@ -24,7 +24,7 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading settings..."
ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
@ -50,17 +50,10 @@ test ! -d $final_path \
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring 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"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..."
ynh_restore_file --origin_path="$final_path"
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
@ -70,12 +63,15 @@ ynh_script_progression --message="Recreating the dedicated system user..."
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# RESTORE USER RIGHTS
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring user rights..."
ynh_script_progression --message="Restoring the app main directory..."
# Restore permissions on app files
chown -R "$app":"$app" $final_path
ynh_restore_file --origin_path="$final_path"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:$app "$final_path"
#=================================================
# CREATE LOG FOLDER
@ -117,7 +113,7 @@ systemctl enable $app.service --quiet
#=================================================
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"
#=================================================
# START SYSTEMD SERVICE

View file

@ -22,7 +22,10 @@ path_url=$(ynh_app_setting_get --app=$app --key=path)
admin=$(ynh_app_setting_get --app=$app --key=admin)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
port=$(ynh_app_setting_get --app=$app --key=port)
secret_key=$(ynh_app_setting_get --app=$app --key=secret_key)
architecture=$(ynh_detect_arch)
@ -73,7 +76,7 @@ ynh_script_progression --message="Backing up the app before upgrading (may take
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# restore it if the upgrade fails
# Restore it if the upgrade fails
ynh_restore_upgradebackup
ynh_clean_check_starting
}
@ -89,6 +92,14 @@ ynh_script_progression --message="Stopping a systemd service..."
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped plume"
#=================================================
# 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
#=================================================
@ -105,15 +116,19 @@ then
chmod +x $final_path/.cargo/bin/*
# Remove empty bin directory
ynh_secure_remove --file="$final_path/$app/bin/"
ynh_secure_remove --file="$final_path/$app/bin"
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..."
ynh_script_progression --message="Upgrading NGINX web server configuration..."
# Create a dedicated nginx config
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
@ -123,14 +138,6 @@ ynh_script_progression --message="Upgrading dependencies..."
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# 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"
#=================================================
# SPECIFIC UPGRADE
#=================================================
@ -141,30 +148,27 @@ ynh_script_progression --message="Creating log folder..."
mkdir -p "/var/log/$app"
chown -R "$app":"$app" "/var/log/$app"
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a config file..."
ynh_add_config --template="../conf/.env" --destination="$final_path/$app/.env"
chmod 400 "$final_path/$app/.env"
chown $app:$app "$final_path/$app/.env"
#=================================================
# MAKE SETUP
#=================================================
ynh_script_progression --message="Making setup..."
# Set right permissions
chown -R "$app":"$app" $final_path
export PATH="$PATH:$final_path/.cargo/bin:$final_path/.local/bin:/usr/local/sbin"
pushd $final_path/$app
sudo -u "$app" env PATH=$PATH plm migration run
popd
#=================================================
# STORE THE CONFIG FILE CHECKSUM
#=================================================
ynh_script_progression --message="Storing the config file checksum..."
config_file="$final_path/$app/.env"
ynh_backup_if_checksum_is_different --file=$config_file
# Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum --file=$config_file
#=================================================
# SETUP SYSTEMD
#=================================================
@ -175,14 +179,6 @@ ynh_add_systemd_config
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
ynh_script_progression --message="Securing files and directories..."
# Set permissions on app files
chown -R "$app":"$app" "$final_path"
#=================================================
# SETUP LOGROTATE
#=================================================
@ -196,7 +192,7 @@ ynh_use_logrotate --non-append
#=================================================
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"
#=================================================
# START SYSTEMD SERVICE
@ -208,7 +204,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --l
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading nginx web server..."
ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload