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

Apply last example_ynh

This commit is contained in:
yalh76 2021-04-09 21:21:27 +02:00
parent 47fa6f6092
commit a2b6dbf4bb
12 changed files with 78 additions and 133 deletions

View file

@ -1,7 +0,0 @@
language: python
before_install:
- git clone https://github.com/YunoHost/package_linter /tmp/package_linter
script:
- /tmp/package_linter/package_linter.py ./

View file

@ -47,8 +47,8 @@ If User Mode is configured Multiple users, the app be used by multiple users
#### Supported architectures
* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/writefreely%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/writefreely/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/writefreely%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/writefreely/)
* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/writefreely.svg)](https://ci-apps.yunohost.org/ci/apps/writefreely/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/writefreely.svg)](https://ci-apps-arm.yunohost.org/ci/apps/writefreely/)
## Limitations

View file

@ -24,7 +24,7 @@
backup_restore=1
multi_instance=1
port_already_use=0
change_url=0
change_url=1
;;; Options
Email=yalh@yahoo.com
Notification=all

View file

@ -14,16 +14,16 @@ hash_seed =
[database]
type = mysql
filename =
username = __DBUSER__
password = __DBPWD__
database = __DBNAME__
username = __DB_USER__
password = __DB_PWD__
database = __DB_NAME__
host = localhost
port = 3306
[app]
site_name = WriteFreely
site_description = WriteFreely_Blogs
host = __DOMAIN_URL__
host = __DOMAIN__
theme = write
editor =
disable_js = false
@ -34,7 +34,7 @@ wf_modesty = false
chorus = false
forest = false
disable_drafts = false
single_user = __SINGLEUSER__
single_user = __SINGLE_USER__
open_registration = true
min_username_len = 3
max_blogs = 4

View file

@ -6,11 +6,11 @@ After=network.target
Type=simple
User=__APP__
Group=__APP__
StandardOutput=syslog
StandardError=syslog
WorkingDirectory=__FINALPATH__
WorkingDirectory=__FINALPATH__/
ExecStart=__FINALPATH__/writefreely
Restart=always
StandardOutput=syslog
StandardError=syslog
[Install]
WantedBy=multi-user.target

View file

@ -9,14 +9,9 @@
"version": "0.12.0~ynh4",
"url": "https://writefreely.org",
"license": "AGPL-3.0-or-later",
"maintainer": [
{
"name": "Anmol Sharma",
"email": "anmol@datamol.org"
},
{
"maintainer": {
"name": "yalh76"
}],
},
"requirements": {
"yunohost": ">= 4.1.3"
},
@ -30,37 +25,21 @@
{
"name": "domain",
"type": "domain",
"ask": {
"en": "Choose a domain name for WriteFreely",
"fr": "Choisissez un nom de domaine pour WriteFreely"
},
"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

@ -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,19 +79,19 @@ 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

View file

@ -79,6 +79,14 @@ ynh_script_progression --message="Finding an available port..."
port=$(ynh_find_port --port=8095)
ynh_app_setting_set --app=$app --key=port --value=$port
#=================================================
# 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 MYSQL DATABASE
#=================================================
@ -98,22 +106,18 @@ 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" --source_id=$architecture
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R root:$app "$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
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
#=================================================
@ -124,52 +128,29 @@ ynh_script_progression --message="Configuring a systemd service..."
# Create a dedicated systemd config
ynh_add_systemd_config
#=================================================
# MODIFY A CONFIG FILE
#=================================================
ynh_script_progression --message="Modifying a config file..."
# setup application config
cp "../conf/config.ini" "$final_path/config.ini"
ynh_replace_string --match_string="__DBNAME__" --replace_string="$db_name" --target_file="$final_path/config.ini"
ynh_replace_string --match_string="__DBUSER__" --replace_string="$db_name" --target_file="$final_path/config.ini"
ynh_replace_string --match_string="__DBPWD__" --replace_string="$db_pwd" --target_file="$final_path/config.ini"
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/config.ini"
ynh_replace_string --match_string="__DOMAIN_URL__" --replace_string="https://$domain" --target_file="$final_path/config.ini"
ynh_replace_string --match_string="__SINGLEUSER__" --replace_string="$single_user" --target_file="$final_path/config.ini"
#=================================================
# 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="$final_path/config.ini"
#=================================================
# MAKE SETUP
#=================================================
ynh_script_progression --message="Making setup..."
chown -R "$app":"$app" "$final_path"
pushd $final_path
sudo -u $app ./writefreely --init-db
sudo -u $app ./writefreely --gen-keys
sudo -u $app ./writefreely --create-admin "$admin":"$password"
popd
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a config file..."
ynh_add_config --template="../conf/config.ini" --destination="$final_path/config.ini"
chmod 400 "$final_path/config.ini"
chown $app:$app "$final_path/config.ini"
#=================================================
# 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
#=================================================

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..."
@ -62,9 +62,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
#=================================================

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
@ -48,17 +48,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
#=================================================
@ -68,12 +61,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 root:$app "$final_path"
#=================================================
# SPECIFIC RESTORATION

View file

@ -78,7 +78,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
@ -93,6 +93,14 @@ ynh_script_progression --message="Stopping a systemd service..."
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped Write Freely"
#=================================================
# 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,6 +113,10 @@ then
ynh_setup_source --dest_dir="$final_path" --source_id=$architecture
fi
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R root:$app "$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
@ -113,14 +125,6 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..."
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# 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
#=================================================
@ -145,25 +149,17 @@ ynh_script_progression --message="Upgrading systemd configuration..."
ynh_add_systemd_config
#=================================================
# STORE THE CONFIG FILE CHECKSUM
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Storing the config file checksum..."
ynh_script_progression --message="Adding a config file..."
ynh_backup_if_checksum_is_different --file="$final_path/config.ini"
ynh_add_config --template="../conf/config.ini" --destination="$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"
chmod 400 "$final_path/config.ini"
chown $app:$app "$final_path/config.ini"
#=================================================
# 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
#=================================================