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

Apply last example_ynh

This commit is contained in:
yalh76 2022-10-01 16:25:09 +02:00
parent ec23030bf8
commit 138bb5a757
7 changed files with 71 additions and 90 deletions

View file

@ -15,21 +15,23 @@
setup_public=1
upgrade=1
# 1.14.1
#upgrade=1 from_commit=81e4075468d035b12ad70936d016d45d0f124720
upgrade=0 from_commit=81e4075468d035b12ad70936d016d45d0f124720
# 1.14.2
#upgrade=1 from_commit=cadb10e497d938e0e684e43ac870a3807b4b60d9
upgrade=0 from_commit=cadb10e497d938e0e684e43ac870a3807b4b60d9
# 1.14.3
#upgrade=1 from_commit=fe0bd01ffa787713e2b36408abe1e44033aacb69
upgrade=0 from_commit=fe0bd01ffa787713e2b36408abe1e44033aacb69
# 1.15.2~ynh1
#upgrade=1 from_commit=20349f58ebb98ce87d3a80da18f11a7bafa04985
upgrade=0 from_commit=20349f58ebb98ce87d3a80da18f11a7bafa04985
# 1.15.2~ynh2
#upgrade=1 from_commit=55e224ea95f384ab8db46941366b0205cd8d3032
upgrade=0 from_commit=55e224ea95f384ab8db46941366b0205cd8d3032
# 1.15.3.1~ynh1
upgrade=1 from_commit=049b860396347599e0633adf277549146644e460
upgrade=0 from_commit=049b860396347599e0633adf277549146644e460
# 1.15.4~ynh2
upgrade=1 from_commit=9af7e309b19966c19dab60fbb54a46b6d2269323
# 1.16~ynh1
upgrade=1 from_commit=37c6fe88f2a06e9b84fd2ad486b5e51f6345254d
# 1.16.3~ynh1
upgrade=1 from_commit=9624b86e211364645958cf44596450faa3c28783
backup_restore=1
multi_instance=1
port_already_use=0
@ -37,20 +39,3 @@
;;; Options
Email=
Notification=none
;;; Upgrade options
; commit=81e4075468d035b12ad70936d016d45d0f124720
name=1.14.1
; commit=cadb10e497d938e0e684e43ac870a3807b4b60d9
name=1.14.2
; commit=fe0bd01ffa787713e2b36408abe1e44033aacb69
name=1.14.3
; commit=20349f58ebb98ce87d3a80da18f11a7bafa04985
name=1.15.2~ynh1
; commit=55e224ea95f384ab8db46941366b0205cd8d3032
name=1.15.2~ynh2
; commit=049b860396347599e0633adf277549146644e460
name=1.15.3.1~ynh1
; commit=9af7e309b19966c19dab60fbb54a46b6d2269323
name=1.15.4~ynh2
; commit=37c6fe88f2a06e9b84fd2ad486b5e51f6345254d
name=1.16~ynh1

View file

@ -6,9 +6,9 @@
YNH_PHP_VERSION="8.0"
pkg_dependencies="curl php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-gd php-php-gettext php${YNH_PHP_VERSION}-imap php${YNH_PHP_VERSION}-fpm php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-curl"
php_dependencies="php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-gd php-php-gettext php${YNH_PHP_VERSION}-imap php${YNH_PHP_VERSION}-fpm php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-curl"
# php${YNH_PHP_VERSION}-apcu
pkg_dependencies="curl $php_dependencies"
#=================================================
# PERSONAL HELPERS

View file

@ -24,7 +24,7 @@ app=$YNH_APP_INSTANCE_NAME
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..."
ynh_script_progression --message="Loading installation settings..." --weight=1
# Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
@ -32,7 +32,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# 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)..." --weight=1
# Backup the current version of the app
ynh_backup_before_upgrade
@ -67,7 +67,7 @@ fi
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression --message="Updating NGINX web server configuration..."
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
@ -98,7 +98,7 @@ fi
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..."
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
@ -106,4 +106,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Change of URL completed for $app"
ynh_script_progression --message="Change of URL completed for $app" --last

View file

@ -35,7 +35,7 @@ app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters..."
ynh_script_progression --message="Validating installation parameters..." --weight=1
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
@ -46,7 +46,7 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression --message="Storing installation settings..."
ynh_script_progression --message="Storing installation settings..." --weight=1
ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url
@ -58,14 +58,14 @@ ynh_app_setting_set --app=$app --key=admin --value=$admin
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..."
ynh_script_progression --message="Installing dependencies..." --weight=1
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..."
ynh_script_progression --message="Configuring system user..." --weight=1
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
@ -73,7 +73,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# CREATE A MYSQL DATABASE
#=================================================
ynh_script_progression --message="Creating a MySQL database..."
ynh_script_progression --message="Creating a MySQL database..." --weight=1
db_name=$(ynh_sanitize_dbid --db_name=$app)
db_user=$db_name
@ -83,7 +83,7 @@ ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..."
ynh_script_progression --message="Setting up source files..." --weight=1
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src
@ -110,16 +110,16 @@ chown -R $app:www-data "$final_path"
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring PHP-FPM..."
ynh_script_progression --message="Configuring PHP-FPM..." --weight=1
# Create a dedicated PHP-FPM config
ynh_add_fpm_config --usage=low --footprint=low
ynh_add_fpm_config
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..."
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
@ -129,14 +129,14 @@ ynh_add_nginx_config
#=================================================
# SET THE CRON FILE
#=================================================
ynh_script_progression --message="Setting the cron file..."
ynh_script_progression --message="Setting the cron file..." --weight=1
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..."
ynh_script_progression --message="Adding a configuration file..." --weight=1
cp -f "../conf/ost-sampleconfig.php" "$final_path/include/ost-config.php"
@ -146,7 +146,7 @@ chown $app:www-data "$final_path/include/ost-config.php"
#=================================================
# BUILD PLUGINS
#=================================================
ynh_script_progression --message="Building plugins..."
ynh_script_progression --message="Building plugins..." --weight=1
ynh_exec_as $app mkdir -p "$final_path/include/plugins/build/.config/composer"
export COMPOSER_HOME="$final_path/include/plugins/build/.config/composer"
@ -178,10 +178,10 @@ ynh_secure_remove --file="$final_path/include/plugins/build"
#=================================================
# SETUP APPLICATION WITH CURL
#=================================================
ynh_script_progression --message="Setuping application with CURL..."
ynh_script_progression --message="Setuping application with CURL..." --weight=1
# Set the app as temporarily public for curl call
ynh_script_progression --message="Configuring SSOwat..."
ynh_script_progression --message="Configuring SSOwat..." --weight=1
# Making the app public for curl
ynh_permission_update --permission="main" --add="visitors"
@ -190,7 +190,7 @@ admin_lname=$(ynh_user_get_info $admin 'lastname')
admin_mail=$(ynh_user_get_info $admin 'mail')
# Installation with curl
ynh_script_progression --message="Finalizing installation..."
ynh_script_progression --message="Finalizing installation..." --weight=1
ynh_local_curl "/setup/install.php" "s=install" "name=$app" "email=$app@$domain" "lang_id=$language" "fname=$admin_fname" "lname=$admin_lname" "admin_email=$admin_mail" "username=$admin" "passwd=$password" "passwd2=$password" "prefix=ost_" "dbhost=localhost" "dbname=$db_name" "dbuser=$db_user" "dbpass=$db_pwd"
# Remove the public access
@ -208,7 +208,7 @@ ynh_store_file_checksum --file="$final_path/include/ost-config.php"
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring permissions..."
ynh_script_progression --message="Configuring permissions..." --weight=1
# Make app public if necessary
if [ $is_public -eq 1 ]
@ -221,7 +221,7 @@ fi
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..."
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
@ -229,4 +229,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed"
ynh_script_progression --message="Installation of $app completed" --last

View file

@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..."
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
@ -26,7 +26,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# REMOVE THE MYSQL DATABASE
#=================================================
ynh_script_progression --message="Removing the MySQL database..."
ynh_script_progression --message="Removing the MySQL database..." --weight=1
# Remove a database if it exists, along with the associated user
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
@ -34,7 +34,7 @@ ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing app main directory..."
ynh_script_progression --message="Removing app main directory..." --weight=1
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
@ -42,7 +42,7 @@ 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..." --weight=1
# Remove the dedicated NGINX config
ynh_remove_nginx_config
@ -50,7 +50,7 @@ ynh_remove_nginx_config
#=================================================
# REMOVE PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Removing PHP-FPM configuration..."
ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=1
# Remove the dedicated PHP-FPM config
ynh_remove_fpm_config
@ -58,7 +58,7 @@ ynh_remove_fpm_config
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..."
ynh_script_progression --message="Removing dependencies..." --weight=1
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
@ -68,7 +68,7 @@ ynh_remove_app_dependencies
#=================================================
# REMOVE VARIOUS FILES
#=================================================
ynh_script_progression --message="Removing various files..."
ynh_script_progression --message="Removing various files..." --weight=1
# Remove a cron file
ynh_secure_remove --file="/etc/cron.d/$app"
@ -78,7 +78,7 @@ ynh_secure_remove --file="/etc/cron.d/$app"
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_script_progression --message="Removing the dedicated system user..."
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
# Delete a system user
ynh_system_user_delete --username=$app
@ -87,4 +87,4 @@ ynh_system_user_delete --username=$app
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Removal of $app completed"
ynh_script_progression --message="Removal of $app completed" --last

View file

@ -23,7 +23,7 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..."
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
@ -37,7 +37,7 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..."
ynh_script_progression --message="Validating restoration parameters..." --weight=1
test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
@ -47,15 +47,15 @@ test ! -d $final_path \
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..."
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir=$final_path
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..."
ynh_script_progression --message="Restoring the app main directory..." --weight=1
ynh_restore_file --origin_path="$final_path"
@ -68,7 +68,7 @@ chown -R $app:www-data "$final_path"
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..."
ynh_script_progression --message="Reinstalling dependencies..." --weight=1
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
@ -76,25 +76,21 @@ ynh_install_app_dependencies $pkg_dependencies
#=================================================
# RESTORE THE PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the PHP-FPM configuration..."
ynh_script_progression --message="Restoring the PHP-FPM configuration..." --weight=1
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
# Create a dedicated PHP-FPM config
ynh_add_fpm_config --usage=low --footprint=low
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX web server configuration..."
ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE MYSQL DATABASE
#=================================================
ynh_script_progression --message="Restoring the MySQL database..."
ynh_script_progression --message="Restoring the MySQL database..." --weight=1
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
@ -103,7 +99,7 @@ ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./
#=================================================
# RESTORE VARIOUS FILES
#=================================================
ynh_script_progression --message="Restoring various files..."
ynh_script_progression --message="Restoring various files..." --weight=1
ynh_restore_file --origin_path="/etc/cron.d/$app"
@ -112,7 +108,7 @@ ynh_restore_file --origin_path="/etc/cron.d/$app"
#=================================================
# RELOAD NGINX AND PHP-FPM
#=================================================
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..."
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1
ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
ynh_systemd_action --service_name=nginx --action=reload
@ -121,4 +117,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed for $app"
ynh_script_progression --message="Restoration completed for $app" --last

View file

@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..."
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
@ -26,14 +26,14 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#=================================================
# CHECK VERSION
#=================================================
ynh_script_progression --message="Checking version..."
ynh_script_progression --message="Checking version..." --weight=1
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1
# Backup the current version of the app
ynh_backup_before_upgrade
@ -49,7 +49,7 @@ ynh_abort_if_errors
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..."
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
@ -61,10 +61,10 @@ fi
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..."
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir=$final_path
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
@ -72,7 +72,7 @@ ynh_system_user_create --username=$app --home_dir=$final_path
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..."
ynh_script_progression --message="Upgrading source files..." --weight=1
tmpdir="$(mktemp -d)"
@ -110,23 +110,23 @@ chown -R $app:www-data "$final_path"
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..."
ynh_script_progression --message="Upgrading dependencies..." --weight=1
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading PHP-FPM configuration..."
ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1
# Create a dedicated PHP-FPM config
ynh_add_fpm_config --usage=low --footprint=low
ynh_add_fpm_config
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..."
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
@ -136,7 +136,7 @@ ynh_add_nginx_config
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..."
ynh_script_progression --message="Updating a configuration file..." --weight=1
ynh_store_file_checksum --file="$final_path/include/ost-config.php"
@ -146,10 +146,10 @@ chown $app:www-data "$final_path/include/ost-config.php"
#=================================================
# BUILD PLUGINS
#=================================================
ynh_script_progression --message="Building plugins..."
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Building plugins..." --weight=1
ynh_exec_as $app mkdir -p "$final_path/include/plugins/build/.config/composer"
COMPOSER_HOME="$final_path/include/plugins/build/.config/composer"
pushd "$final_path/include/plugins/build"
@ -180,7 +180,7 @@ fi
#=================================================
# UPGRADE OSTICKET
#=================================================
ynh_script_progression --message="Upgrading the application..."
ynh_script_progression --message="Upgrading the application..." --weight=1
pushd "$final_path"
php$phpversion manage.php upgrade
@ -189,7 +189,7 @@ popd
#=================================================
# SET THE CRON FILE
#=================================================
ynh_script_progression --message="Setting the cron file..."
ynh_script_progression --message="Setting the cron file..." --weight=1
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
@ -198,7 +198,7 @@ ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..."
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
@ -206,4 +206,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed"
ynh_script_progression --message="Upgrade of $app completed" --last