1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/misskey_ynh.git synced 2024-09-03 19:46:03 +02:00

Apply last example_ynh

This commit is contained in:
yalh76 2022-06-19 04:48:15 +02:00
parent fc165bea0b
commit bcc065634b
9 changed files with 125 additions and 126 deletions

View file

@ -138,7 +138,7 @@ id: 'aid'
#proxyRemoteFiles: true
# Sign to ActivityPub GET request (default: false)
# signToActivityPubGet: true
#signToActivityPubGet: true
#allowedPrivateNetworks: [
# '127.0.0.1/32'

View file

@ -1,4 +1,5 @@
location / {
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ {
proxy_pass http://127.0.0.1:__PORT__;
proxy_set_header Host $host;

View file

@ -1,12 +1,13 @@
[Unit]
Description=Misskey: microblogging platform
After=network.target
[Service]
Type=simple
User=__APP__
Group=__APP__
WorkingDirectory=__FINALPATH__
Environment="PATH=__ENV_PATH__"
WorkingDirectory=__FINALPATH__/
Environment="__YNH_NODE_LOAD_PATH__"
Environment="NODE_ENV=production"
ExecStart=__YNH_NPM__ start
TimeoutSec=60

View file

@ -6,7 +6,7 @@
"en": "Microblogging platform",
"fr": "Platforme de Microblogging"
},
"version": "12.110.1~ynh1",
"version": "12.110.1~ynh2",
"url": "https://misskey-hub.net/",
"upstream": {
"license": "AGPL-3.0",

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
@ -15,7 +15,6 @@ source /usr/share/yunohost/helpers
#=================================================
ynh_clean_setup () {
### Remove this function if there's nothing to clean before calling the remove script.
true
}
# Exit if an error occurs during the execution of the script
@ -50,17 +49,19 @@ ynh_backup --src_path="$final_path"
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# BACKUP SYSTEMD
#=================================================
ynh_backup --src_path="/etc/systemd/system/$app.service"
# SPECIFIC BACKUP
#=================================================
# BACKUP LOGROTATE
#=================================================
ynh_backup --src_path="/etc/logrotate.d/$app"
#=================================================
# BACKUP SYSTEMD
#=================================================
ynh_backup --src_path="/etc/systemd/system/$app.service"
#=================================================
# BACKUP THE POSTGRESQL DATABASE
#=================================================

View file

@ -14,8 +14,7 @@ source /usr/share/yunohost/helpers
#=================================================
ynh_clean_setup () {
### Remove this function if there's nothing to clean before calling the remove script.
true
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
@ -72,23 +71,9 @@ ynh_app_setting_set --app=$app --key=port --value=$port
ynh_script_progression --message="Installing dependencies..." --weight=3
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
#=================================================
# CREATE A POSTGRESQL DATABASE
#=================================================
ynh_script_progression --message="Creating a PostgreSQL database..." --weight=2
# Create postgresql database
db_name=$(ynh_sanitize_dbid --db_name=$app)
db_user=$db_name
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_psql_test_if_first_run
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
#=================================================
# CREATE DEDICATED USER
#=================================================
@ -97,6 +82,17 @@ ynh_script_progression --message="Configuring system user..." --weight=2
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# CREATE A POSTGRESQL DATABASE
#=================================================
ynh_script_progression --message="Creating a PostgreSQL database..." --weight=2
db_name=$(ynh_sanitize_dbid --db_name=$app)
db_user=$db_name
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_psql_test_if_first_run
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
@ -115,21 +111,11 @@ chown -R $app:www-data "$final_path"
#=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=3
# Create a dedicated nginx config
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=1
env_path="$PATH"
# Create a dedicated systemd config
ynh_add_systemd_config
#=================================================
# STORE THE CONFIG FILE CHECKSUM
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1
@ -140,17 +126,25 @@ ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db"
ynh_add_config --template="../conf/default.yml" --destination="$final_path/.config/default.yml"
#=================================================
# INSTALLING MISKKEY
# BUILD APP
#=================================================
ynh_script_progression --message="Installing Misskey..." --weight=15
ynh_script_progression --message="Building app..." --weight=15
pushd "$final_path"
ynh_use_nodejs
ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH yarn add ts-node webpack
ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH NODE_ENV=production yarn build
ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH yarn run init
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn add ts-node webpack
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH NODE_ENV=production yarn build
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn run init
popd
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=1
# Create a dedicated systemd config
ynh_add_systemd_config
#=================================================
# SETUP LOGROTATE
#=================================================
@ -172,7 +166,7 @@ yunohost service add $app --description="A interplanetary blogging platform" --l
ynh_script_progression --message="Starting a systemd service..." --weight=1
# Start a systemd service
ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="All workers started"
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="All workers started"
#=================================================
# SETUP SSOWAT

View file

@ -29,8 +29,8 @@ redis_db=$(ynh_app_setting_get --app=$app --key=redis_db)
# REMOVE SERVICE INTEGRATION IN YUNOHOST
#=================================================
# 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
# 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..." --weight=1
yunohost service remove $app
@ -42,7 +42,15 @@ fi
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
# Remove the dedicated systemd config
ynh_remove_systemd_config --service="$app"
ynh_remove_systemd_config
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
# Remove the app-specific logrotate config
ynh_remove_logrotate
#=================================================
# REMOVE THE POSTGRESQL DATABASE
@ -50,7 +58,7 @@ ynh_remove_systemd_config --service="$app"
ynh_script_progression --message="Removing the PostgreSQL database..." --weight=1
# 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 THE REDIS DATABASE
@ -59,16 +67,6 @@ ynh_script_progression --message="Removing the redis database..." --weight=1
ynh_redis_remove_db "$redis_db"
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=1
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
ynh_remove_nodejs
#=================================================
# REMOVE APP MAIN DIR
#=================================================
@ -82,16 +80,17 @@ ynh_secure_remove --file="$final_path"
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
# Remove the dedicated nginx config
# Remove the dedicated NGINX config
ynh_remove_nginx_config
#=================================================
# REMOVE LOGROTATE CONFIGURATION
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
ynh_script_progression --message="Removing dependencies..." --weight=1
# Remove the app-specific logrotate config
ynh_remove_logrotate
# Remove metapackage and its dependencies
ynh_remove_nodejs
ynh_remove_app_dependencies
#=================================================
# SPECIFIC REMOVE

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
@ -15,8 +15,7 @@ source /usr/share/yunohost/helpers
#=================================================
ynh_clean_setup () {
#### Remove this function if there's nothing to clean before calling the remove script.
true
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
@ -44,11 +43,7 @@ test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
# STANDARD RESTORATION STEPS
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
@ -77,11 +72,16 @@ ynh_script_progression --message="Reinstalling dependencies..." --weight=5
# Define and install dependencies
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
#=================================================
# RESTORE 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 POSTGRESQL DATABASE
#=================================================
@ -118,10 +118,12 @@ yunohost service add $app --description="A interplanetary blogging platform" --l
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action=start --log_path="systemd" --line_match="All workers started"
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="All workers started"
#=================================================
# RELOAD NGINX AND PHP-FPM
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1

View file

@ -26,6 +26,7 @@ port=$(ynh_app_setting_get --app=$app --key=port)
#=================================================
# CHECK VERSION
#=================================================
ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed)
@ -46,12 +47,22 @@ ynh_script_progression --message="Backing up the app before upgrading (may take
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# restore it if the upgrade fails
ynh_clean_check_starting
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd --line_match="Stopped"
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
@ -77,15 +88,6 @@ if ynh_legacy_permissions_exists; then
fi
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action=stop --log_path=systemd --line_match="Stopped"
#=================================================
# CREATE DEDICATED USER
#=================================================
@ -97,7 +99,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
# For now nothing will upgrade as I don't which files needs to be backed up before upgrade
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..."
@ -110,6 +112,15 @@ chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=5
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
#=================================================
# NGINX CONFIGURATION
#=================================================
@ -119,26 +130,16 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." -
ynh_add_nginx_config
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=5
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
#=================================================
# Updating process MISSKEY
# BUILD APP
#=================================================
ynh_script_progression --message="Building app..."
pushd "$final_path"
ynh_use_nodejs
ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH yarn cleanall
ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH yarn install
ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH NODE_ENV=production yarn build
ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH yarn migrate
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn cleanall
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn install
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH NODE_ENV=production yarn build
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn migrate
popd
#=================================================
@ -146,11 +147,11 @@ popd
#=================================================
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
env_path="$PATH"
# Create a dedicated systemd config
ynh_add_systemd_config
#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
#=================================================
@ -171,7 +172,7 @@ yunohost service add $app --description="A interplanetary blogging platform" --l
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="All workers started"
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="All workers started"
#=================================================
# RELOAD NGINX