1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/pixelfed_ynh.git synced 2024-09-03 20:06:04 +02:00

Apply example_ynh

This commit is contained in:
yalh76 2020-02-23 18:18:57 +01:00
parent a3e898e568
commit 6e66a37271
8 changed files with 61 additions and 15 deletions

View file

@ -62,11 +62,10 @@ Those commands can be found in the official documentation.
* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/pixelfed%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/pixelfed/) * x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/pixelfed%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/pixelfed/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/pixelfed%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/pixelfed/) * ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/pixelfed%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/pixelfed/)
* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/pixelfed%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/pixelfed/)
## Links ## Links
* Report a bug about this package: https://github.com/YunoHost-Apps/pixelfed_ynh * Report a bug: https://github.com/YunoHost-Apps/pixelfed_ynh
* Pixelfed website: https://pixelfed.org * Pixelfed website: https://pixelfed.org
* Upstream app repository: https://github.com/pixelfed/pixelfed * Upstream app repository: https://github.com/pixelfed/pixelfed
* YunoHost website: https://yunohost.org * YunoHost website: https://yunohost.org

View file

@ -106,7 +106,7 @@ ynh_install_php () {
ynh_pin_repo --package="*" --pin="origin \"packages.sury.org\"" 200 --name=extra_php_version ynh_pin_repo --package="*" --pin="origin \"packages.sury.org\"" 200 --name=extra_php_version
ynh_pin_repo --package="php7.0*" --pin="origin \"packages.sury.org\"" 600 --name=extra_php_version --append ynh_pin_repo --package="php7.0*" --pin="origin \"packages.sury.org\"" 600 --name=extra_php_version --append
# Advertise service in admin panel # INTEGRATE SERVICE IN YUNOHOST
yunohost service add php${phpversion}-fpm --log "/var/log/php${phpversion}-fpm.log" yunohost service add php${phpversion}-fpm --log "/var/log/php${phpversion}-fpm.log"
} }

View file

@ -13,7 +13,11 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_print_info --message="Managing script failure..."
ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors

View file

@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# RETRIEVE ARGUMENTS # RETRIEVE ARGUMENTS
#================================================= #=================================================
ynh_print_info --message="Retrieve arguments from the manifest"
old_domain=$YNH_APP_OLD_DOMAIN old_domain=$YNH_APP_OLD_DOMAIN
old_path="/" old_path="/"
@ -31,8 +32,26 @@ final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
# Add settings here as needed by your application # Add settings here as needed by your application
#db_name=$(ynh_app_setting_get --app="$app" --key=db_name) #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) #db_pwd=$(ynh_app_setting_get --app="$app" --key=db_pwd)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_print_info --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 # CHECK WHICH PARTS SHOULD BE CHANGED
#================================================= #=================================================
@ -67,6 +86,7 @@ fi
#================================================= #=================================================
# UPDATE CONFIG FILE # UPDATE CONFIG FILE
#================================================= #=================================================
ynh_print_info --message="Updating config file..."
config="$final_path/.env" config="$final_path/.env"
ynh_replace_string --match_string="APP_URL=.*" --replace_string="APP_URL=https://$new_domain" --target_file="$config" ynh_replace_string --match_string="APP_URL=.*" --replace_string="APP_URL=https://$new_domain" --target_file="$config"
@ -77,6 +97,7 @@ ynh_replace_string --match_string="MAIL_FROM_ADDRESS=.*" --replace_string="MAIL_
#================================================= #=================================================
# STORE THE CONFIG FILE CHECKSUM # STORE THE CONFIG FILE CHECKSUM
#================================================= #=================================================
ynh_print_info --message="Storing the config file checksum..."
ynh_backup_if_checksum_is_different --file="$config" ynh_backup_if_checksum_is_different --file="$config"
@ -86,6 +107,7 @@ ynh_store_file_checksum --file="$config"
#================================================= #=================================================
# APPLY CHANGES # APPLY CHANGES
#================================================= #=================================================
ynh_print_info --message="Applying changes..."
pushd "$final_path" pushd "$final_path"
php7.3 artisan config:clear php7.3 artisan config:clear

View file

@ -12,13 +12,18 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_print_info --message="Managing script failure..."
ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
#================================================= #=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST # RETRIEVE ARGUMENTS FROM THE MANIFEST
#================================================= #=================================================
ynh_print_info --message="Retrieving arguments from the manifest..."
domain=$YNH_APP_ARG_DOMAIN domain=$YNH_APP_ARG_DOMAIN
path_url="/" path_url="/"
@ -42,6 +47,7 @@ ynh_webpath_register --app="$app" --domain="$domain" --path_url="$path_url"
#================================================= #=================================================
# STORE SETTINGS FROM MANIFEST # STORE SETTINGS FROM MANIFEST
#================================================= #=================================================
ynh_print_info --message="Storing installation settings..."
ynh_app_setting_set --app="$app" --key=domain --value="$domain" 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=path --value="$path_url"
@ -83,6 +89,7 @@ ynh_psql_setup_db --db_user="$db_user" --db_name="$db_name" --db_pwd="$db_pwd"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_print_info --message="Setting up source files..."
ynh_app_setting_set --app="$app" --key=final_path --value="$final_path" 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
@ -115,6 +122,7 @@ ynh_add_fpm_config --phpversion="7.3"
#================================================= #=================================================
# INSTALL PHP DEPENDENCIES # INSTALL PHP DEPENDENCIES
#================================================= #=================================================
ynh_print_info --message="Installing php dependencies..."
chown -R "$app": "$final_path" chown -R "$app": "$final_path"
@ -138,6 +146,7 @@ ynh_add_systemd_config --service="${app}-horizon" --template=horizon.service
#================================================= #=================================================
# MODIFY A CONFIG FILE # MODIFY A CONFIG FILE
#================================================= #=================================================
ynh_print_info --message="Modifying a config file..."
config="$final_path/.env" config="$final_path/.env"
cp ../conf/.env "$config" cp ../conf/.env "$config"
@ -153,6 +162,7 @@ ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --t
#================================================= #=================================================
# STORE THE CHECKSUM OF THE CONFIG FILE # STORE THE CHECKSUM OF THE CONFIG FILE
#================================================= #=================================================
ynh_print_info --message="Storing the config file checksum..."
# Calculate and store the config file checksum into the app settings # Calculate and store the config file checksum into the app settings
ynh_store_file_checksum --file="$config" ynh_store_file_checksum --file="$config"
@ -160,6 +170,7 @@ ynh_store_file_checksum --file="$config"
#================================================= #=================================================
# DEPLOYMENT # DEPLOYMENT
#================================================= #=================================================
ynh_print_info --message="Deploying..."
pushd "$final_path" pushd "$final_path"
php7.3 artisan -n key:generate --force php7.3 artisan -n key:generate --force
@ -180,14 +191,16 @@ popd
#================================================= #=================================================
# SECURE FILES AND DIRECTORIES # SECURE FILES AND DIRECTORIES
#================================================= #=================================================
ynh_print_info --message="Securing files and directories..."
# Set permissions to app files # Set permissions to app files
chown -R root: "$final_path" chown -R root: "$final_path"
chown -R "$app": "$final_path/storage/" chown -R "$app": "$final_path/storage/"
#================================================= #=================================================
# ADVERTISE SERVICE IN ADMIN PANEL # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_print_info --message="Integrating service in YunoHost..."
yunohost service add "${app}-horizon" --description "${app}-horizon daemon for $app" --log "/var/log/$app/${app}-horizon.log" yunohost service add "${app}-horizon" --description "${app}-horizon daemon for $app" --log "/var/log/$app/${app}-horizon.log"

View file

@ -24,10 +24,11 @@ final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
#================================================= #=================================================
# REMOVE SERVICE FROM ADMIN PANEL # REMOVE SERVICE INTEGRATION IN YUNOHOST
#================================================= #=================================================
ynh_print_info --message="Removing service integration in YunoHost..."
# Remove a service from the admin panel, added by `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}-horizon >/dev/null if ynh_exec_warn_less yunohost service status ${app}-horizon >/dev/null
then then
ynh_print_info --message="Removing ${app}-horizon service..." ynh_print_info --message="Removing ${app}-horizon service..."
@ -89,7 +90,7 @@ ynh_remove_fpm_config
ynh_print_info --message="Start php7.0-fpm..." ynh_print_info --message="Start php7.0-fpm..."
#Sometimes with package_check php7.0-fpm fail to reload and stop. So starting the service, just in case. #Sometimes with package_check php7.0-fpm fail to reload and stop. So starting the service, just in case.
ynh_systemd_action --service_name=php7.0-fpm --action=start ynh_systemd_action --service_name=php7.0-fpm --action="start"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION

View file

@ -13,7 +13,11 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_print_info --message="Managing script failure..."
ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
@ -29,7 +33,6 @@ path_url=$(ynh_app_setting_get --app="$app" --key=path)
final_path=$(ynh_app_setting_get --app="$app" --key=final_path) final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
db_name=$(ynh_app_setting_get --app="$app" --key=db_name) db_name=$(ynh_app_setting_get --app="$app" --key=db_name)
db_user=$db_name db_user=$db_name
db_pwd=$(ynh_app_setting_get --app="$app" --key=db_pwd)
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # CHECK IF THE APP CAN BE RESTORED
@ -46,6 +49,7 @@ test ! -d "$final_path" \
#================================================= #=================================================
# RESTORE THE NGINX CONFIGURATION # RESTORE THE NGINX CONFIGURATION
#================================================= #=================================================
ynh_print_info --message="Restoring the nginx configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
@ -67,6 +71,7 @@ ynh_system_user_create --username="$app"
#================================================= #=================================================
# RESTORE USER RIGHTS # RESTORE USER RIGHTS
#================================================= #=================================================
ynh_print_info --message="Restoring user rights..."
# Restore permissions on app files # Restore permissions on app files
chown -R "$app": "$final_path" chown -R "$app": "$final_path"
@ -81,6 +86,7 @@ ynh_install_php --phpversion="7.3" --package="$extra_pkg_dependencies"
#================================================= #=================================================
# RESTORE THE PHP-FPM CONFIGURATION # RESTORE THE PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_print_info --message="Restoring PHP-FPM configuration..."
ynh_restore_file --origin_path="/etc/php/7.3/fpm/pool.d/$app.conf" ynh_restore_file --origin_path="/etc/php/7.3/fpm/pool.d/$app.conf"
@ -99,6 +105,7 @@ ynh_install_app_dependencies "$pkg_dependencies"
#================================================= #=================================================
ynh_print_info --message="Restoring the PostgreSQL database..." ynh_print_info --message="Restoring the PostgreSQL database..."
db_pwd=$(ynh_app_setting_get --app="$app" --key=db_pwd)
ynh_psql_test_if_first_run ynh_psql_test_if_first_run
ynh_psql_setup_db --db_user="$db_user" --db_name="$db_name" --db_pwd="$db_pwd" 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"
@ -112,8 +119,9 @@ ynh_restore_file --origin_path="/etc/systemd/system/${app}-horizon.service"
systemctl enable ${app}-horizon.service systemctl enable ${app}-horizon.service
#================================================= #=================================================
# ADVERTISE SERVICE IN ADMIN PANEL # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_print_info --message="Integrating service in YunoHost..."
yunohost service add "${app}-horizon" --log "/var/log/$app/${app}-horizon.log" yunohost service add "${app}-horizon" --log "/var/log/$app/${app}-horizon.log"

View file

@ -30,6 +30,7 @@ app_key=$(ynh_app_setting_get --app="$app" --key=app_key)
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
#================================================= #=================================================
ynh_print_info --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed) upgrade_type=$(ynh_check_app_version_changed)
@ -148,6 +149,7 @@ ynh_add_fpm_config --phpversion="7.3"
#================================================= #=================================================
# UPDATE PHP DEPENDENCIES # UPDATE PHP DEPENDENCIES
#================================================= #=================================================
ynh_print_info --message="Updating php dependencies..."
chown -R "$app": "$final_path" chown -R "$app": "$final_path"
@ -161,6 +163,7 @@ ynh_composer_exec --phpversion="7.3" --workdir="$final_path" --commands="update"
#================================================= #=================================================
# MODIFY A CONFIG FILE # MODIFY A CONFIG FILE
#================================================= #=================================================
ynh_print_info --message="Modifying a config file..."
config="$final_path/.env" config="$final_path/.env"
ynh_backup_if_checksum_is_different --file="$config" ynh_backup_if_checksum_is_different --file="$config"
@ -180,6 +183,7 @@ ynh_store_file_checksum --file="$config"
#================================================= #=================================================
# DEPLOYMENT # DEPLOYMENT
#================================================= #=================================================
ynh_print_info --message="Deploying..."
pushd "$final_path" pushd "$final_path"
php7.3 artisan horizon:install php7.3 artisan horizon:install
@ -204,17 +208,12 @@ ynh_print_info --message="Upgrading systemd configuration..."
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config --service="${app}-horizon" --template=horizon.service ynh_add_systemd_config --service="${app}-horizon" --template=horizon.service
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
#=================================================
yunohost service add "${app}-horizon" --description "${app}-horizon daemon for $app" --log "/var/log/$app/${app}-horizon.log"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================
# SECURE FILES AND DIRECTORIES # SECURE FILES AND DIRECTORIES
#================================================= #=================================================
ynh_print_info --message="Securing files and directories..."
# Set permissions on app files # Set permissions on app files
chown -R "$app": "$final_path" chown -R "$app": "$final_path"