1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/distbin_ynh.git synced 2024-09-03 18:26:10 +02:00

Apply example_ynh

This commit is contained in:
yalh76 2021-04-10 01:14:00 +02:00
parent 4bc80032c3
commit e58116982f
7 changed files with 53 additions and 55 deletions

View file

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

View file

@ -24,6 +24,8 @@
upgrade=1 from_commit=f7bc083d037eb771afeddc2237a24505a5ef1c68
# 1.3.0~ynh6
upgrade=1 from_commit=cdec64125b179f6b19470ceb8379225ed03c10a8
# 1.3.0~ynh7
upgrade=1 from_commit=481c0c5ce62caa9c79a6bd536f390f3814128b3a
backup_restore=1
multi_instance=1
port_already_use=0
@ -40,3 +42,5 @@ Notification=all
name=1.3.0~ynh5
; commit=cdec64125b179f6b19470ceb8379225ed03c10a8
name=1.3.0~ynh6
; commit=481c0c5ce62caa9c79a6bd536f390f3814128b3a
name=1.3.0~ynh7

View file

@ -6,7 +6,7 @@
"en": "Distributed pastebin with ActivityPub.",
"fr": "Pastebin distribué utilisant le protocole ActivityPub."
},
"version": "1.3.0~ynh7",
"version": "1.3.0~ynh8",
"url": "https://distbin.com/",
"license": "Apache-2.0",
"maintainer": {

View file

@ -31,7 +31,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
port=$(ynh_app_setting_get --app=$app --key=port)
#=================================================
# 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)..."

View file

@ -67,6 +67,14 @@ ynh_script_progression --message="Installing dependencies..."
ynh_install_app_dependencies $pkg_dependencies
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
#=================================================
# 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
#=================================================
@ -76,6 +84,10 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R root:$app "$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
@ -84,14 +96,6 @@ ynh_script_progression --message="Configuring NGINX web server..."
# 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
#=================================================
@ -138,22 +142,17 @@ ynh_script_progression --message="Configuring a systemd service..."
ynh_add_systemd_config
#=================================================
# MODIFY A CONFIG FILE
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Modifying a config file..."
ynh_script_progression --message="Adding a config file..."
ynh_add_config --template="../conf/.env" --destination="$final_path/.env"
chmod 400 "$final_path/some_config_file"
chown $app:$app "$final_path/some_config_file"
#=================================================
# 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
#=================================================
# SETUP LOGROTATE
#=================================================

View file

@ -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
@ -50,6 +50,14 @@ 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"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
@ -57,21 +65,9 @@ ynh_script_progression --message="Restoring the app main directory..."
ynh_restore_file --origin_path="$final_path"
#=================================================
# 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
#=================================================
# RESTORE USER RIGHTS
#=================================================
ynh_script_progression --message="Restoring user rights..."
# Restore permissions on app files
chown -R $app:$app $final_path
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R root:$app "$final_path"
#=================================================
# CREATE LOG FOLDER

View file

@ -49,7 +49,7 @@ ynh_script_progression --message="Backing up the app before upgrading (may take
ynh_backup_before_upgrade
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
@ -64,6 +64,14 @@ ynh_script_progression --message="Stopping a systemd service..."
ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd --line_match="Stopped Distbin Service"
#=================================================
# 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
#=================================================
@ -76,6 +84,10 @@ then
ynh_setup_source --dest_dir="$final_path"
fi
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R root:$app "$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
@ -92,14 +104,6 @@ ynh_script_progression --message="Upgrading dependencies..."
ynh_install_app_dependencies $pkg_dependencies
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
#=================================================
# 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
#=================================================
@ -154,16 +158,11 @@ ynh_script_progression --message="Updating a config file..."
ynh_add_config --template="../conf/.env" --destination="$final_path/.env"
chmod 400 "$final_path/some_config_file"
chown $app:$app "$final_path/some_config_file"
#=================================================
# 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
#=================================================