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

[autopatch] Automatic patch attempt for helpers 2.1

This commit is contained in:
Yunohost-Bot 2024-08-31 02:51:21 +02:00 committed by Alexandre Aubin
parent 62094410b2
commit f6ed173171
10 changed files with 84 additions and 153 deletions

View file

@ -6,7 +6,7 @@ After=network.target
Type=simple
User=__APP__
Group=__APP__
Environment="__YNH_NODE_LOAD_PATH__"
Environment="PATH=__PATH_WITH_NODEJS__"
Environment="NODE_ENV=development"
ExecStart=/bin/sh -c ' npm run unmanaged'
WorkingDirectory=__INSTALL_DIR__/

View file

@ -17,7 +17,8 @@ website = "https://framagit.org/yphil/petrolette"
fund = "https://liberapay.com/yPhil/donate"
[integration]
yunohost = ">= 11.2"
yunohost = ">= 11.2.18"
helpers_version = "2.1"
architectures = "all"
multi_instance = true
ldap = false

View file

@ -1,19 +1,7 @@
#!/bin/bash
#=================================================
# COMMON VARIABLES
# COMMON VARIABLES AND CUSTOM HELPERS
#=================================================
NODEJS_VERSION=18
#=================================================
# PERSONAL HELPERS
#=================================================
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================
nodejs_version=18

View file

@ -1,40 +1,31 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# 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
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
ynh_print_info "Declaring files to be backed up..."
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
ynh_backup --src_path="$install_dir"
ynh_backup "$install_dir"
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# BACKUP SYSTEMD
#=================================================
ynh_backup --src_path="/etc/systemd/system/$app.service"
ynh_backup "/etc/systemd/system/$app.service"
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -1,41 +1,31 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_script_progression "Stopping $app's systemd service..."
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd"
ynh_systemctl --service=$app --action="stop" --log_path="systemd"
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
ynh_script_progression "Updating NGINX web server configuration..."
ynh_change_url_nginx_config
ynh_config_change_url_nginx
#=================================================
# GENERIC FINALISATION
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_script_progression "Starting $app's systemd service..."
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd"
ynh_systemctl --service=$app --action="start" --log_path="systemd"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Change of URL completed for $app" --last
ynh_script_progression "Change of URL completed for $app"

View file

@ -1,22 +1,18 @@
#!/bin/bash
# In simple cases, you don't need a config script.
# In simple cases, you don't need a config script.
# With a simple config_panel.toml, you can write in the app settings, in the
# With a simple config_panel.toml, you can write in the app settings, in the
# upstream config file or replace complete files (logo ...) and restart services.
# The config scripts allows you to go further, to handle specific cases
# The config scripts allows you to go further, to handle specific cases
# (validation of several interdependent fields, specific getter/setter for a value,
# display dynamic informations or choices, pre-loading of config type .cube... ).
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source /usr/share/yunohost/helpers
ynh_abort_if_errors
#REMOVEME? ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS
@ -24,10 +20,10 @@ ynh_abort_if_errors
final_path=$(ynh_app_setting_get $app final_path)
get__instance_type() {
if [ -f "$final_path/petrolette.config.json" ]
then
then
echo 1
else
echo 0
@ -35,16 +31,15 @@ get__instance_type() {
}
set__instance_type() {
if [ "$instanceType" -eq 1 ]
if [ "$instanceType" -eq 1 ]
then
echo '{ "instanceType" : "monoUser" }' > "$final_path/petrolette.config.json"
ynh_app_setting_set --app=$app --key=mono_user --value=1
ynh_app_setting_set --key=mono_user --value=1
else
rm "$final_path/petrolette.config.json"
ynh_app_setting_set --app=$app --key=mono_user --value=0
ynh_app_setting_set --key=mono_user --value=0
fi
}
#=================================================
# GENERIC FINALIZATION
#=================================================
ynh_app_config_run $1

View file

@ -1,25 +1,19 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..."
ynh_script_progression "Installing dependencies..."
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
ynh_nodejs_install
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..."
ynh_script_progression "Setting up source files..."
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir"
@ -27,13 +21,13 @@ ynh_setup_source --dest_dir="$install_dir"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..."
ynh_script_progression "Configuring NGINX web server..."
# Create a dedicated NGINX config
ynh_add_nginx_config
ynh_config_add_nginx
# Create a dedicated systemd config
ynh_add_systemd_config
ynh_config_add_systemd
yunohost service add $app --description="The news reader that doesn't know you" --log="/var/log/$app/$app.log"
@ -42,7 +36,7 @@ yunohost service add $app --description="The news reader that doesn't know you"
#=================================================
# INSTALL PETROLETTE
#=================================================
ynh_script_progression --message="Installing application using node..."
ynh_script_progression "Installing application using node..."
pushd $install_dir
# set port in configuration file
@ -50,33 +44,33 @@ pushd $install_dir
sed -i "/HTTPS_PORT/s/[0-9]*[0-9]/$port_https/" package.json
# use custom home value to avoid bower storing values in root and have right errors
if [ $mono_user -eq 1 ] ; then
ynh_add_config --template="petrolette.config.json" --destination="petrolette.config.json"
ynh_config_add --template="petrolette.config.json" --destination="petrolette.config.json"
fi
if [ "$path" != "/" ] ; then
sed -i "s|\$.get(\"/feed\", {|\$.get(\"feed\", {|" public/js/PTL.feed.js
sed -i "s|\$.get(\"/feed\", {|\$.get(\"feed\", {|" public/js/PTL.feed.js
fi
[[ -v HOME ]] && TMP_HOME=$HOME
HOME=$(pwd)
export NODE_ENV=production
ynh_use_nodejs
ynh_exec_warn_less $ynh_npm install --ignore-scripts
ynh_hide_warnings npm install --ignore-scripts
[[ -v TMP_HOME ]] && HOME=$TMP_HOME || unset HOME
popd
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:$app "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:$app "$install_dir"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..."
ynh_script_progression "Starting $app's systemd service..."
# Start a systemd service
ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="Pétrolette HTTP Server running on port"
ynh_systemctl --service=$app --action=start --log_path=systemd --wait_until="Pétrolette HTTP Server running on port"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed"
ynh_script_progression "Installation of $app completed"

View file

@ -1,11 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
@ -16,22 +10,22 @@ source /usr/share/yunohost/helpers
#=================================================
# 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
if ynh_hide_warnings yunohost service status $app >/dev/null
then
ynh_script_progression --message="Removing $app service integration..."
ynh_script_progression "Removing $app service integration..."
yunohost service remove $app
fi
# Remove the dedicated systemd config
ynh_remove_systemd_config
ynh_config_remove_systemd
# Remove the dedicated NGINX config
ynh_remove_nginx_config
ynh_config_remove_nginx
ynh_remove_nodejs
ynh_nodejs_remove
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Removal of $app completed"
ynh_script_progression "Removal of $app completed"

View file

@ -1,11 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# 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
@ -13,24 +7,23 @@ source /usr/share/yunohost/helpers
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..."
ynh_script_progression "Restoring the app main directory..."
ynh_restore_file --origin_path="$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:$app "$install_dir"
ynh_restore "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:$app "$install_dir"
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
ynh_nodejs_install
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
ynh_restore "/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet
yunohost service add $app --description="The news reader that doesn't know you" --log="/var/log/$app/$app.log"
@ -38,14 +31,14 @@ yunohost service add $app --description="The news reader that doesn't know you"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=3
ynh_script_progression "Starting $app's systemd service..."
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Pétrolette HTTP Server running on port"
ynh_systemctl --service=$app --action="start" --log_path=systemd --wait_until="Pétrolette HTTP Server running on port"
ynh_systemd_action --service_name=nginx --action=reload
ynh_systemctl --service=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed for $app" --last
ynh_script_progression "Restoration completed for $app"

View file

@ -1,36 +1,23 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_script_progression "Stopping $app's systemd service..."
ynh_systemd_action --service_name=$app --action=stop --log_path=systemd
ynh_systemctl --service=$app --action=stop --log_path=systemd
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
# FIXME: this is still supported but the recommendation is now to *always* re-setup the app sources wether or not the upstream sources changed
if ynh_app_upstream_version_changed
then
ynh_script_progression --message="Upgrading source files..." --weight=1
ynh_script_progression "Upgrading source files..."
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir"
@ -39,53 +26,51 @@ fi
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=3
ynh_script_progression "Upgrading NGINX web server configuration..."
# Create a dedicated NGINX config
ynh_add_nginx_config
ynh_config_add_nginx
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
ynh_nodejs_install
# Create a dedicated systemd config
ynh_add_systemd_config
ynh_config_add_systemd
yunohost service add $app --description="The news reader that doesn't know you" --log="/var/log/$app/$app.log"
#=================================================
# SPECIFIC UPGRADE
#=================================================
# UPDATE APP
#=================================================
ynh_script_progression --message="Upgrading the app..." --weight=5
ynh_script_progression "Upgrading the app..."
pushd $install_dir
# set port in configuration file
sed -i "/HTTP_PORT/s/[0-9]*[0-9]/$port/" package.json
sed -i "/HTTPS_PORT/s/[0-9]*[0-9]/$port_https/" package.json
if [ "$path" != "/" ] ; then
sed -i "s|\$.get(\"/feed\", {|\$.get(\"feed\", {|" public/js/PTL.feed.js
sed -i "s|\$.get(\"/feed\", {|\$.get(\"feed\", {|" public/js/PTL.feed.js
fi
[[ -v HOME ]] && TMP_HOME=$HOME
HOME=$(pwd)
ynh_use_nodejs
ynh_exec_warn_less $ynh_npm install --ignore-scripts
ynh_hide_warnings npm install --ignore-scripts
[[ -v TMP_HOME ]] && HOME=$TMP_HOME || unset HOME
popd
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:$app "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:$app "$install_dir"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=3
ynh_script_progression "Starting $app's systemd service..."
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Pétrolette HTTP Server running on port"
ynh_systemctl --service=$app --action="start" --log_path=systemd --wait_until="Pétrolette HTTP Server running on port"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last
ynh_script_progression "Upgrade of $app completed"