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

Merge pull request #169 from YunoHost-Apps/testing

Apply example_ynh
This commit is contained in:
yalh76 2021-04-23 13:13:32 +02:00 committed by GitHub
commit d131fd4f07
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 85 additions and 120 deletions

View file

@ -82,8 +82,8 @@ The app can be used by multiple users.
#### Supported architectures
* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/pleroma%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/pleroma/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/pleroma%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/pleroma/)
* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/pleroma.svg)](https://ci-apps.yunohost.org/ci/apps/pleroma/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/pleroma.svg)](https://ci-apps-arm.yunohost.org/ci/apps/pleroma/)
## Links

View file

@ -1,8 +1,3 @@
# See here for more informations
# https://github.com/YunoHost/package_check#syntax-check_process-file
# Move this file from check_process.default to check_process when you have filled it.
;; Test complet
; Manifest
domain="domain.tld" (DOMAIN)
@ -53,6 +48,8 @@
upgrade=1 from_commit=63723f18af5b035a41e967078cc3128423b1f9ae
# 2.3.0~ynh1
upgrade=1 from_commit=9f5c0970d2bf8bb6111785184b1d3762228b04ec
# 2.3.0~ynh2
upgrade=1 from_commit=4757df265b0c3e8d1fc5280190ccfe5705dcb691
backup_restore=1
multi_instance=0
port_already_use=0
@ -93,3 +90,5 @@ Notification=yes
name=2.2.2~ynh1
; commit=9f5c0970d2bf8bb6111785184b1d3762228b04ec
name=2.3.0~ynh1
; commit=4757df265b0c3e8d1fc5280190ccfe5705dcb691
name=2.3.0~ynh2

View file

@ -6,7 +6,7 @@
"en": "A free, federated social networking server built on open protocols.",
"fr": "Un serveur de réseautage social fédéré et gratuit basé sur des protocoles ouverts."
},
"version": "2.3.0~ynh2",
"version": "2.3.0~ynh3",
"url": "https://git.pleroma.social/pleroma/pleroma",
"license": "AGPL-3.0-only",
"maintainer": [
@ -29,37 +29,21 @@
{
"name": "domain",
"type": "domain",
"ask": {
"en": "Choose a domain name for Pleroma",
"fr": "Choisissez un nom de domaine pour Pleroma"
},
"example": "example.com"
},
{
"name": "admin",
"type": "user",
"ask": {
"en": "Choose an admin user",
"fr": "Choisissez l'administrateur"
},
"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
@ -81,23 +81,23 @@ pkill -u $app
#=================================================
# 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
@ -136,7 +136,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

@ -89,6 +89,14 @@ 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
#=================================================
@ -116,12 +124,16 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path
architecture=$(ynh_detect_arch)
ynh_setup_source --dest_dir="$final_path/$app" --source_id=$architecture
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
if [ $cache -eq 1 ]
@ -134,14 +146,6 @@ then
ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf"
fi
#=================================================
# 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
#=================================================
@ -152,16 +156,17 @@ ynh_script_progression --message="Creating the data directory..."
# Define app's data directory
datadir="/home/yunohost.app/${app}"
ynh_app_setting_set --app=$app --key=datadir --value="$datadir"
# Create app folders
mkdir -p "$datadir/"
mkdir -p "$datadir/uploads/"
mkdir -p "$datadir/static/"
mkdir -p "$datadir/static/emoji/"
# Give permission to the datadir
chown -R "$app":"$app" "$datadir"
ynh_app_setting_set --app=$app --key=datadir --value="$datadir"
chmod 750 "$datadir"
chmod -R o-rwx "$datadir"
chown -R $app:$app "$datadir"
#=================================================
# CREATE THE CONFIG DIRECTORY
@ -228,24 +233,14 @@ pushd $final_path/$app
su "$app" -s $SHELL -lc "$final_path/$app/bin/pleroma_ctl user new $admin $admin_email --password $password --moderator --admin -y"
popd
#=================================================
# 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"
chmod 400 "$config"
chown $app:$app "$config"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
ynh_script_progression --message="Securing files and directories..."
# Set permissions to app files
chown -R "$app":"$app" "$final_path"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
@ -271,7 +266,7 @@ ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --aut
#=================================================
# 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

@ -21,7 +21,6 @@ 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)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#=================================================
# STANDARD REMOVE
@ -29,7 +28,7 @@ datadir=$(ynh_app_setting_get --app=$app --key=datadir)
# 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..."
@ -59,7 +58,7 @@ ynh_remove_systemd_config
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"
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
#=================================================
# REMOVE DEPENDENCIES
@ -80,9 +79,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
ynh_secure_remove --file="/etc/nginx/conf.d/$app-cache.conf"
@ -99,9 +98,9 @@ fi
#=================================================
# SPECIFIC REMOVE
#=================================================
# REMOVE DIRECTORIES
# REMOVE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing directories..."
ynh_script_progression --message="Removing configuration..."
# Remove the config directory securely
ynh_secure_remove --file="/etc/$app"

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
@ -23,7 +23,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
@ -52,7 +52,7 @@ 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"
@ -61,13 +61,6 @@ then
ynh_restore_file --origin_path="/etc/nginx/conf.d/$app-cache.conf"
fi
#=================================================
# 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
#=================================================
@ -77,12 +70,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"
#=================================================
# SPECIFIC RESTORATION
@ -100,8 +96,9 @@ mkdir -p "$datadir/uploads/"
mkdir -p "$datadir/static/"
mkdir -p "$datadir/static/emoji/"
# Give permission to the datadir
chown -R "$app":"$app" "$datadir"
chmod 750 "$datadir"
chmod -R o-rwx "$datadir"
chown -R $app:$app "$datadir"
#=================================================
# RESTORE THE CONFIG FILE
@ -110,6 +107,9 @@ ynh_script_progression --message="Restoring the config file..."
ynh_restore_file --origin_path="/etc/$app/config.exs"
chmod 400 "/etc/$app/config.exs"
chown $app:$app "/etc/$app/config.exs"
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
@ -159,7 +159,7 @@ fi
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX AND PHP-FPM
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..."

View file

@ -99,19 +99,11 @@ previous_version="${version}"
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
# Inform the backup/restore process that it should not save the data directory
# Use only for the previous backup script that doesn't set 'is_big'
ynh_app_setting_set --app=$app --key=backup_core_only --value=1
# Backup the current version of the app
ynh_backup_before_upgrade
# Remove the option backup_core_only after the backup.
ynh_app_setting_delete --app=$app --key=backup_core_only
ynh_clean_setup () {
ynh_clean_check_starting
# 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
@ -130,6 +122,14 @@ if ynh_version_gt "${previous_version}" "1.1.1~ynh1" ; then
pkill -u $app
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"
#=================================================
# UPGRADE TO OTP RELEASE
#=================================================
@ -189,12 +189,16 @@ then
ynh_setup_source --dest_dir="$final_path/$app" --source_id=$architecture
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
ynh_secure_remove --file="/etc/nginx/conf.d/$app-cache.conf"
@ -215,20 +219,12 @@ 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
#=================================================
# MODIFY A CONFIG FILE
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Modifying a config file..."
ynh_script_progression --message="Updating a config file..."
config="/etc/$app/config.exs"
@ -239,9 +235,6 @@ ynh_backup_if_checksum_is_different --file="$config"
#=================================================
ynh_script_progression --message="Making upgrade..."
# Give permission to the final_path
chown -R "$app":"$app" "$final_path"
pushd $final_path/$app
su "$app" -s $SHELL -lc "$final_path/$app/bin/pleroma_ctl migrate"
popd
@ -254,6 +247,9 @@ ynh_script_progression --message="Storing the config file checksum..."
# Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum --file="$config"
chmod 400 "$config"
chown $app:$app "$config"
#=================================================
# SETUP SYSTEMD
#=================================================
@ -264,14 +260,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"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
@ -292,7 +280,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