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

Merge pull request #20 from YunoHost-Apps/example

Apply example_ynh
This commit is contained in:
yalh76 2021-04-21 20:56:31 +02:00 committed by GitHub
commit afd9750150
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 107 additions and 155 deletions

View file

@ -31,8 +31,8 @@ LDAP and HTTP auth are supported through plugins
#### Supported architectures
* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/osticket%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/osticket/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/osticket%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/osticket/)
* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/osticket.svg)](https://ci-apps.yunohost.org/ci/apps/osticket/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/osticket.svg)](https://ci-apps-arm.yunohost.org/ci/apps/osticket/)
## Additional information

View file

@ -25,6 +25,8 @@
#upgrade=1 from_commit=cadb10e497d938e0e684e43ac870a3807b4b60d9
# 1.14.3
#upgrade=1 from_commit=fe0bd01ffa787713e2b36408abe1e44033aacb69
# 1.15.2~ynh1
upgrade=1 from_commit=20349f58ebb98ce87d3a80da18f11a7bafa04985
backup_restore=1
multi_instance=1
port_already_use=0
@ -39,3 +41,5 @@ Notification=none
name=1.14.2
; commit=fe0bd01ffa787713e2b36408abe1e44033aacb69
name=1.14.3
; commit=20349f58ebb98ce87d3a80da18f11a7bafa04985
name=1.15.2~ynh1

View file

@ -6,7 +6,7 @@
"en": "Open source support ticket system",
"fr": "Système de ticket de support open source"
},
"version": "1.15.2~ynh1",
"version": "1.15.2~ynh2",
"url": "https://osticket.com/",
"license": "GPL-2.0-or-later",
"maintainer": {
@ -26,38 +26,22 @@
{
"name": "domain",
"type": "domain",
"ask": {
"en": "Choose a domain name for osTicket",
"fr": "Choisissez un nom de domaine pour osTicket"
},
"example": "example.com"
},
{
"name": "path",
"type": "path",
"ask": {
"en": "Choose a path for osTicket",
"fr": "Choisissez un chemin pour osTicket"
},
"example": "/osticket",
"default": "/osticket"
},
{
"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
},
{

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

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
@ -72,23 +72,23 @@ fi
#=================================================
# 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
# Change the domain for nginx
# Change the domain for NGINX
if [ $change_domain -eq 1 ]
then
# Delete file checksum for the old conf file location
@ -109,7 +109,7 @@ fi
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading nginx web server..."
ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload

View file

@ -62,6 +62,14 @@ ynh_script_progression --message="Installing dependencies..."
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# 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
#=================================================
@ -93,44 +101,45 @@ ynh_setup_source --dest_dir="$final_path/include/plugins/build/microsoft-teams"
ynh_setup_source --dest_dir="$final_path/include/plugins/build/slack" --source_id="plugin-slack"
ynh_setup_source --dest_dir="$final_path/include/plugins/build/preventautoscroll" --source_id="plugin-preventautoscroll"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring nginx web server..."
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
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring php-fpm..."
ynh_script_progression --message="Configuring PHP-FPM..."
# Create a dedicated php-fpm config
# Create a dedicated PHP-FPM config
ynh_add_fpm_config --usage=low --footprint=low --package="$extra_php_dependencies"
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#=================================================
# SPECIFIC SETUP
#=================================================
# PREPARE INSTALL
# SET THE CRON FILE
#=================================================
ynh_script_progression --message="Preparing install..."
ynh_script_progression --message="Setting the cron file..."
config_file=$final_path/include/ost-config.php
cp -f ../conf/ost-sampleconfig.php "$config_file"
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
admin_fname=$(ynh_user_get_info $admin 'firstname')
admin_lname=$(ynh_user_get_info $admin 'lastname')
admin_mail=$(ynh_user_get_info $admin 'mail')
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a config file..."
cp -f "../conf/ost-sampleconfig.php" "$final_path/include/ost-config.php"
chmod 666 "$final_path/include/ost-config.php"
chown $app:www-data "$final_path/include/ost-config.php"
#=================================================
# BUILD PLUGINS
@ -161,6 +170,7 @@ pushd "$final_path/include/plugins/build"
#php${phpversion} -dphar.readonly=0 make.php build preventautoscroll
#cp *.phar $final_path/include/plugins/.
popd
ynh_secure_remove --file="$final_path/include/plugins/build"
#=================================================
@ -175,18 +185,14 @@ rsync -a "../conf/i18n" "$final_path/include/."
#=================================================
ynh_script_progression --message="Setuping application with CURL..."
# Set right permissions for curl install
chown -R $app: $final_path
# Set the app as temporarily public for curl call
ynh_script_progression --message="Configuring SSOwat..."
# Making the app public for curl
ynh_permission_update --permission="main" --add="visitors"
# Reload SSOwat config
yunohost app ssowatconf
# Reload Nginx
ynh_systemd_action --service_name=nginx --action=reload
admin_fname=$(ynh_user_get_info $admin 'firstname')
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..."
@ -195,42 +201,13 @@ ynh_local_curl "/setup/install.php" "s=install" "name=$app" "email=$app@$domain"
# Remove the public access
ynh_permission_update --permission="main" --remove="visitors"
#=================================================
# FINALIZE INSTALL
#=================================================
ynh_script_progression --message="Finalizing install..."
# Removing setup folder
ynh_secure_remove --file="$final_path/setup"
# Securing config file
chmod 0644 $config_file
#=================================================
# SET THE CRON FILE
#=================================================
ynh_script_progression --message="Setting the cron file..."
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
#=================================================
# 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="$config_file"
chmod 400 "$final_path/include/ost-config.php"
chown $app:www-data "$final_path/include/ost-config.php"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
ynh_script_progression --message="Securing files and directories..."
# Set permissions to app files
chown -R $app: $final_path
#=================================================
# SETUP SSOWAT
#=================================================
@ -247,7 +224,7 @@ fi
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading nginx web server..."
ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload

View file

@ -50,17 +50,17 @@ 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
#=================================================
# REMOVE PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Removing php-fpm configuration..."
ynh_script_progression --message="Removing PHP-FPM configuration..."
# Remove the dedicated php-fpm config
# Remove the dedicated PHP-FPM config
ynh_remove_fpm_config
#=================================================

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
@ -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
@ -49,10 +49,18 @@ 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"
#=================================================
# 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
#=================================================
@ -60,21 +68,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
#=================================================
# RESTORE USER RIGHTS
#=================================================
ynh_script_progression --message="Restoring user rights..."
# Restore permissions on app files
chown -R $app: $final_path
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
# RESTORE THE PHP-FPM CONFIGURATION
@ -83,12 +79,19 @@ ynh_script_progression --message="Restoring PHP-FPM configuration..."
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
# Create a dedicated php-fpm config
# Create a dedicated PHP-FPM config
ynh_add_fpm_config --usage=low --footprint=low --package="$extra_php_dependencies"
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#=================================================
# SPECIFIC RESTORATION
#=================================================
# RESTORE THE CRON FILE
#=================================================
ynh_script_progression --message="Restoring the cron file..."
ynh_restore_file --origin_path="/etc/cron.d/$app"
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
@ -106,19 +109,12 @@ 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
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
#=================================================
# RESTORE THE CRON FILE
#=================================================
ynh_script_progression --message="Restoring the cron file..."
ynh_restore_file --origin_path="/etc/cron.d/$app"
#=================================================
# GENERIC FINALIZATION
#=================================================
# 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..."
ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
ynh_systemd_action --service_name=nginx --action=reload

View file

@ -52,7 +52,7 @@ 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
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
@ -60,6 +60,14 @@ ynh_abort_if_errors
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# 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
#=================================================
@ -95,12 +103,16 @@ then
ynh_secure_remove --file="$tmpdir"
fi
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading nginx web server configuration..."
ynh_script_progression --message="Upgrading NGINX web server configuration..."
# Create a dedicated nginx config
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
@ -110,25 +122,25 @@ ynh_script_progression --message="Upgrading dependencies..."
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# 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
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading php-fpm configuration..."
ynh_script_progression --message="Upgrading PHP-FPM configuration..."
# Create a dedicated php-fpm config
# Create a dedicated PHP-FPM config
ynh_add_fpm_config --usage=low --footprint=low --package="$extra_php_dependencies"
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#=================================================
# SPECIFIC UPGRADE
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a config file..."
chmod 400 "$final_path/include/ost-config.php"
chown $app:www-data "$final_path/include/ost-config.php"
#=================================================
# BUILD PLUGINS
#=================================================
@ -160,6 +172,7 @@ then
#cp -f *.phar $final_path/include/plugins/.
popd
ynh_secure_remove --file="$final_path/include/plugins/build"
ynh_secure_remove --file="$final_path/setup"
fi
#=================================================
@ -169,20 +182,6 @@ ynh_script_progression --message="UPGRADING language..."
rsync -a "../conf/i18n" "$final_path/include/."
#=================================================
# FINALIZE UPGRADE
#=================================================
ynh_script_progression --message="Finalizing install..."
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
# Removing setup folder
ynh_secure_remove --file="$final_path/setup"
# Securing config file
chmod 0644 $config_file
fi
#=================================================
# SET THE CRON FILE
#=================================================
@ -201,18 +200,10 @@ ynh_store_file_checksum --file="$config_file"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
ynh_script_progression --message="Securing files and directories..."
# Set permissions on app files
chown -R $app: $final_path
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading nginx web server..."
ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload