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

Apply example_ynh

This commit is contained in:
yalh76 2020-02-23 20:01:11 +01:00
parent 7ce18872f4
commit 766ca0ae40
7 changed files with 56 additions and 23 deletions

View file

@ -1,21 +1,20 @@
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location ~ ^/.well-known/(webfinger|nodeinfo|host-meta) {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass http://127.0.0.1:__PORT__;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass http://127.0.0.1:__PORT__;
proxy_redirect off;
}
location ~ ^/(css|img|js|fonts)/ {
root __FINALPATH__/static;
# Optionally cache these files in the browser:
# expires 12M;
root __FINALPATH__/static;
# Optionally cache these files in the browser:
# expires 12M;
}
location __PATH__/ {
proxy_pass http://localhost:__PORT__;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;

View file

@ -13,6 +13,7 @@ source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_print_info --message="Managing script failure..."
ynh_clean_setup () {
ynh_clean_check_starting

View file

@ -35,6 +35,23 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#db_user=$db_name
#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
#=================================================
@ -94,14 +111,16 @@ fi
#=================================================
# MODIFY A CONFIG FILE
#=================================================
ynh_print_info --message="Modifying a config file..."
ynh_backup_if_checksum_is_different --file="$final_path/config.ini"
ynh_replace_string --match_string="host =.*" --replace_string="host = https://$new_domain" --target_file="$final_path/config.ini"
#=================================================
# STORE THE CONFIG FILE CHECKSUM
#=================================================
ynh_print_info --message="Storingthe config file checksum..."
ynh_backup_if_checksum_is_different --file="$final_path/config.ini"
# Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum --file="$final_path/config.ini"

View file

@ -13,6 +13,7 @@ source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_print_info --message="Managing script failure..."
ynh_clean_setup () {
ynh_clean_check_starting
@ -23,7 +24,7 @@ ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
ynh_print_info --message="Retrieve arguments from the manifest ..."
ynh_print_info --message="Retrieving arguments from the manifest..."
domain=$YNH_APP_ARG_DOMAIN
path_url="/"
@ -68,7 +69,6 @@ ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set --app=$app --key=admin --value=$admin
ynh_app_setting_set --app=$app --key=is_public --value=$is_public
ynh_app_setting_set --app=$app --key=single_user --value=$single_user
#=================================================
@ -78,9 +78,8 @@ ynh_app_setting_set --app=$app --key=single_user --value=$single_user
#=================================================
ynh_print_info --message="Configuring firewall..."
# Find a free port
# Find an available port
port=$(ynh_find_port --port=8095)
ynh_app_setting_set --app=$app --key=port --value=$port
#=================================================
@ -131,6 +130,7 @@ ynh_add_systemd_config
#=================================================
# MODIFY A CONFIG FILE
#=================================================
ynh_print_info --message="Modifying a config file..."
# setup application config
cp "../conf/config.ini" "$final_path/config.ini"
@ -145,6 +145,7 @@ ynh_replace_string --match_string="__SINGLEUSER__" --replace_string="$single_use
#=================================================
# STORE THE CONFIG FILE CHECKSUM
#=================================================
ynh_print_info --message="Storing the config file checksum..."
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum --file="$final_path/config.ini"
@ -152,6 +153,7 @@ ynh_store_file_checksum --file="$final_path/config.ini"
#=================================================
# MAKE SETUP
#=================================================
ynh_print_info --message="Making setup..."
chown -R "$app":"$app" "$final_path"
@ -166,20 +168,22 @@ popd
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
ynh_print_info --message="Securing files and directories..."
# Set permissions to app files
chown -R "$app":"$app" "$final_path"
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_print_info --message="Integrating service in YunoHost..."
# if using yunohost version 3.2 or more in the 'manifest.json', a description can be added
yunohost service add $app --description "$app daemon for WriteFreely" --log "/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_print_info --message="Starting a systemd service..."
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Serving on"

View file

@ -25,10 +25,11 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# 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 >/dev/null
then
ynh_print_info --message="Removing $app service..."
@ -70,7 +71,7 @@ ynh_remove_nginx_config
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..." --time --weight=1
ynh_print_info --message="Removing logrotate configuration..."
# Remove the app-specific logrotate config
ynh_remove_logrotate
@ -78,10 +79,11 @@ ynh_remove_logrotate
#=================================================
# CLOSE A PORT
#=================================================
ynh_print_info --message="Closing a port..."
if yunohost firewall list | grep -q "\- $port$"
then
ynh_script_progression --message="Closing port $port..."
ynh_print_info --message="Closing port $port..."
ynh_exec_warn_less yunohost firewall disallow TCP $port
fi

View file

@ -6,12 +6,14 @@
# IMPORT GENERIC HELPERS
#=================================================
#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
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_print_info --message="Managing script failure..."
ynh_clean_setup () {
ynh_clean_check_starting
@ -47,6 +49,7 @@ test ! -d $final_path \
#=================================================
# 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"
@ -68,6 +71,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# RESTORE USER RIGHTS
#=================================================
ynh_print_info --message="Restoring user rights..."
# Restore permissions on app files
chown -R "$app":"$app" "$final_path"
@ -92,8 +96,9 @@ ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_print_info --message="Integrating service in YunoHost..."
yunohost service add $app --description "$app daemon for WriteFreely" --log_type systemd

View file

@ -32,6 +32,7 @@ architecture=$(ynh_detect_arch)
#=================================================
# CHECK VERSION
#=================================================
ynh_print_info --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed)
@ -134,7 +135,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# SPECIFIC UPGRADE
#=================================================
# MAKE UPGRADE
# MAKE THE UPGRADE
#=================================================
ynh_print_info --message="Making the upgrade..."
@ -147,6 +148,7 @@ popd
#=================================================
# STORE THE CONFIG FILE CHECKSUM
#=================================================
ynh_print_info --message="Storing the config file checksum..."
ynh_backup_if_checksum_is_different --file="$final_path/config.ini"
# Recalculate and store the checksum of the file for the next upgrade.
@ -165,6 +167,7 @@ ynh_add_systemd_config
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
ynh_print_info --message="Securing files and directories..."
# Set permissions on app files
chown -R "$app":"$app" "$final_path"
@ -182,7 +185,7 @@ then
fi
#=================================================
# START SERVICE
# START SYSTEMD SERVICE
#=================================================
ynh_print_info --message="Starting a systemd service..."