mirror of
https://github.com/YunoHost-Apps/agendav_ynh.git
synced 2024-09-03 20:36:12 +02:00
Apply last example_ynh
This commit is contained in:
parent
006e999dd9
commit
c28d9ea2bd
10 changed files with 64 additions and 97 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,2 +0,0 @@
|
||||||
*~
|
|
||||||
*.sw[po]
|
|
|
@ -20,9 +20,9 @@ $app['proxies'] = [];
|
||||||
|
|
||||||
// Database settings
|
// Database settings
|
||||||
$app['db.options'] = [
|
$app['db.options'] = [
|
||||||
'dbname' => '__DBNAME__',
|
'dbname' => '__DB_NAME__',
|
||||||
'user' => '__DBUSER__',
|
'user' => '__DB_USER__',
|
||||||
'password' => '__DBPASS__',
|
'password' => '__DB_PWD__',
|
||||||
'host' => 'localhost',
|
'host' => 'localhost',
|
||||||
'driver' => 'pdo_mysql'
|
'driver' => 'pdo_mysql'
|
||||||
];
|
];
|
||||||
|
@ -31,7 +31,7 @@ $app['db.options'] = [
|
||||||
$app['csrf.secret'] = '__ENCRYPTKEY__';
|
$app['csrf.secret'] = '__ENCRYPTKEY__';
|
||||||
|
|
||||||
// Log path
|
// Log path
|
||||||
$app['log.path'] = '__LOGDIR__/';
|
$app['log.path'] = '/var/log/__APP__/';
|
||||||
|
|
||||||
// Base URL
|
// Base URL
|
||||||
$app['caldav.baseurl'] = '__CALDAV_BASEURL__';
|
$app['caldav.baseurl'] = '__CALDAV_BASEURL__';
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"website": "http://agendav.org",
|
"website": "http://agendav.org",
|
||||||
"demo": "https://demo.yunohost.org/agendav/",
|
"demo": "https://demo.yunohost.org/agendav/",
|
||||||
"admindoc": "http://docs.agendav.org",
|
"admindoc": "https://agendav.readthedocs.io/",
|
||||||
"code": "https://github.com/agendav/agendav"
|
"code": "https://github.com/agendav/agendav"
|
||||||
},
|
},
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
|
|
|
@ -4,10 +4,10 @@
|
||||||
# COMMON VARIABLES
|
# COMMON VARIABLES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
YNH_PHP_VERSION="7.3"
|
php_dependencies="php$YNH_DEFAULT_PHP_VERSION-ctype php$YNH_DEFAULT_PHP_VERSION-curl php$YNH_DEFAULT_PHP_VERSION-mbstring php$YNH_DEFAULT_PHP_VERSION-mcrypt php$YNH_DEFAULT_PHP_VERSION-tokenizer php$YNH_DEFAULT_PHP_VERSION-xml php$YNH_DEFAULT_PHP_VERSION-xmlreader php$YNH_DEFAULT_PHP_VERSION-xmlwriter php$YNH_DEFAULT_PHP_VERSION-mysql"
|
||||||
|
|
||||||
# dependencies used by the app
|
# dependencies used by the app (must be on a single line)
|
||||||
pkg_dependencies="php${YNH_PHP_VERSION}-cli"
|
pkg_dependencies="$php_dependencies"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PERSONAL HELPERS
|
# PERSONAL HELPERS
|
||||||
|
|
|
@ -14,6 +14,9 @@ source /usr/share/yunohost/helpers
|
||||||
# MANAGE SCRIPT FAILURE
|
# MANAGE SCRIPT FAILURE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
ynh_clean_setup () {
|
||||||
|
true
|
||||||
|
}
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
ynh_abort_if_errors
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ app=$YNH_APP_INSTANCE_NAME
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# 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"
|
# Needed for helper "ynh_add_nginx_config"
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
|
@ -81,7 +81,7 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# 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
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,9 @@ source /usr/share/yunohost/helpers
|
||||||
# MANAGE SCRIPT FAILURE
|
# MANAGE SCRIPT FAILURE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
ynh_clean_setup () {
|
||||||
|
true
|
||||||
|
}
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
ynh_abort_if_errors
|
||||||
|
|
||||||
|
@ -29,7 +32,7 @@ app=$YNH_APP_INSTANCE_NAME
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
# 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
|
final_path=/var/www/$app
|
||||||
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
||||||
|
@ -74,7 +77,7 @@ ynh_app_setting_set --app=$app --key=language --value=$language
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALL DEPENDENCIES
|
# INSTALL DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Installing dependencies..."
|
ynh_script_progression --message="Installing dependencies..." --weight=1
|
||||||
|
|
||||||
ynh_install_app_dependencies $pkg_dependencies
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
|
@ -89,7 +92,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE A MYSQL DATABASE
|
# 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_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||||
db_user=$db_name
|
db_user=$db_name
|
||||||
|
@ -112,7 +115,7 @@ chown -R $app:www-data "$final_path"
|
||||||
#=================================================
|
#=================================================
|
||||||
# PHP-FPM CONFIGURATION
|
# 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
|
# Create a dedicated PHP-FPM config
|
||||||
ynh_add_fpm_config
|
ynh_add_fpm_config
|
||||||
|
@ -144,23 +147,9 @@ timezone=$(cat /etc/timezone)
|
||||||
caldav_domain=$(ynh_app_setting_get --app=$caldav_app --key=domain)
|
caldav_domain=$(ynh_app_setting_get --app=$caldav_app --key=domain)
|
||||||
caldav_path=$(ynh_app_setting_get --app=$caldav_app --key=path)
|
caldav_path=$(ynh_app_setting_get --app=$caldav_app --key=path)
|
||||||
caldav_url="https://${caldav_domain}${caldav_path%/}"
|
caldav_url="https://${caldav_domain}${caldav_path%/}"
|
||||||
|
caldav_baseurl="${caldav_url}${caldav_baseurl}"
|
||||||
|
|
||||||
conf_path="${final_path}/web/config/settings.php"
|
ynh_add_config --template="../conf/settings.php" --destination="${final_path}/web/config/settings.php"
|
||||||
cp ../conf/settings.php "$conf_path"
|
|
||||||
|
|
||||||
logdir=/var/log/$app
|
|
||||||
|
|
||||||
ynh_replace_string --match_string="__DBUSER__" --replace_string="$db_name" --target_file="$conf_path"
|
|
||||||
ynh_replace_string --match_string="__DBPASS__" --replace_string="$db_pwd" --target_file="$conf_path"
|
|
||||||
ynh_replace_string --match_string="__DBNAME__" --replace_string="$db_name" --target_file="$conf_path"
|
|
||||||
ynh_replace_string --match_string="__ENCRYPTKEY__" --replace_string="$encryptkey" --target_file="$conf_path"
|
|
||||||
ynh_replace_string --match_string="__LOGDIR__" --replace_string="$logdir" --target_file="$conf_path"
|
|
||||||
ynh_replace_string --match_string="__TIMEZONE__" --replace_string="$timezone" --target_file="$conf_path"
|
|
||||||
ynh_replace_string --match_string="__LANGUAGE__" --replace_string="$language" --target_file="$conf_path"
|
|
||||||
ynh_replace_string --match_string="__CALDAV_BASEURL__" --replace_string="${caldav_url}${caldav_baseurl}" --target_file="$conf_path"
|
|
||||||
ynh_replace_string --match_string="__CALDAV_DOMAIN__" --replace_string="$caldav_domain" --target_file="$conf_path"
|
|
||||||
|
|
||||||
ynh_store_file_checksum --file="$conf_path"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RUN DATABASE MIGRATIONS (INCLUDES INITIALIZATION)
|
# RUN DATABASE MIGRATIONS (INCLUDES INITIALIZATION)
|
||||||
|
@ -172,10 +161,6 @@ ynh_script_progression --message="Initialising AgenDAV..." --weight=3
|
||||||
php${phpversion} agendavcli migrations:migrate --no-interaction
|
php${phpversion} agendavcli migrations:migrate --no-interaction
|
||||||
)
|
)
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SECURE FILES AND DIRECTORIES
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
chown -R $app:www-data $final_path
|
chown -R $app:www-data $final_path
|
||||||
|
|
||||||
# Only agendav user should write here
|
# Only agendav user should write here
|
||||||
|
@ -191,10 +176,10 @@ chmod -R 750 ${final_path}/web/config/
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP LOGROTATE
|
# SETUP LOGROTATE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring log rotation..."
|
ynh_script_progression --message="Configuring log rotation..." --weight=1
|
||||||
|
|
||||||
mkdir -p $logdir
|
mkdir -p /var/log/$app
|
||||||
chown -R $app: $logdir
|
chown -R $app: /var/log/$app
|
||||||
|
|
||||||
# Use logrotate to manage application logfile(s)
|
# Use logrotate to manage application logfile(s)
|
||||||
ynh_use_logrotate
|
ynh_use_logrotate
|
||||||
|
@ -202,7 +187,7 @@ ynh_use_logrotate
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# 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
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
|
@ -210,4 +195,4 @@ ynh_systemd_action --service_name=nginx --action=reload
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Installation of AgenDAV completed" --last
|
ynh_script_progression --message="Installation of $app completed" --last
|
||||||
|
|
|
@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Loading installation settings..."
|
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE LOGROTATE CONFIGURATION
|
# REMOVE LOGROTATE CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing logrotate configuration..."
|
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
|
||||||
|
|
||||||
# Remove the app-specific logrotate config
|
# Remove the app-specific logrotate config
|
||||||
ynh_remove_logrotate
|
ynh_remove_logrotate
|
||||||
|
@ -32,7 +32,7 @@ ynh_remove_logrotate
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE THE MYSQL DATABASE
|
# 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
|
# Remove a database if it exists, along with the associated user
|
||||||
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
|
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
|
||||||
|
@ -48,7 +48,7 @@ ynh_secure_remove --file="$final_path"
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE NGINX CONFIGURATION
|
# 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
|
# Remove the dedicated NGINX config
|
||||||
ynh_remove_nginx_config
|
ynh_remove_nginx_config
|
||||||
|
@ -64,7 +64,7 @@ ynh_remove_fpm_config
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE DEPENDENCIES
|
# REMOVE DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing dependencies..."
|
ynh_script_progression --message="Removing dependencies..." --weight=1
|
||||||
|
|
||||||
# Remove metapackage and its dependencies
|
# Remove metapackage and its dependencies
|
||||||
ynh_remove_app_dependencies
|
ynh_remove_app_dependencies
|
||||||
|
@ -74,7 +74,7 @@ ynh_remove_app_dependencies
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE VARIOUS FILES
|
# REMOVE VARIOUS FILES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing various files..."
|
ynh_script_progression --message="Removing various files..." --weight=1
|
||||||
|
|
||||||
ynh_secure_remove --file="/var/log/$app"
|
ynh_secure_remove --file="/var/log/$app"
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ ynh_secure_remove --file="/var/log/$app"
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE DEDICATED USER
|
# 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
|
# Delete a system user
|
||||||
ynh_system_user_delete --username=$app
|
ynh_system_user_delete --username=$app
|
||||||
|
|
|
@ -14,6 +14,9 @@ source /usr/share/yunohost/helpers
|
||||||
# MANAGE SCRIPT FAILURE
|
# MANAGE SCRIPT FAILURE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
ynh_clean_setup () {
|
||||||
|
true
|
||||||
|
}
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
ynh_abort_if_errors
|
||||||
|
|
||||||
|
@ -34,7 +37,7 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE RESTORED
|
# 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 \
|
test ! -d $final_path \
|
||||||
|| ynh_die --message="There is already a directory: $final_path "
|
|| ynh_die --message="There is already a directory: $final_path "
|
||||||
|
@ -52,7 +55,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE APP MAIN DIR
|
# 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"
|
ynh_restore_file --origin_path="$final_path"
|
||||||
|
|
||||||
|
@ -75,7 +78,7 @@ chmod -R 750 ${final_path}/web/config/
|
||||||
#=================================================
|
#=================================================
|
||||||
# REINSTALL DEPENDENCIES
|
# REINSTALL DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reinstalling dependencies..."
|
ynh_script_progression --message="Reinstalling dependencies..." --weight=1
|
||||||
|
|
||||||
# Define and install dependencies
|
# Define and install dependencies
|
||||||
ynh_install_app_dependencies $pkg_dependencies
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
@ -90,7 +93,7 @@ ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE NGINX CONFIGURATION
|
# 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"
|
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
|
@ -106,7 +109,7 @@ ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE LOGROTATE CONFIGURATION
|
# RESTORE THE LOGROTATE CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the logrotate configuration..."
|
ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1
|
||||||
|
|
||||||
mkdir -p /var/log/$app
|
mkdir -p /var/log/$app
|
||||||
chown -R $app: /var/log/$app
|
chown -R $app: /var/log/$app
|
||||||
|
|
|
@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Loading installation settings..."
|
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK VERSION
|
# CHECK VERSION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Checking version..."
|
ynh_script_progression --message="Checking version..." --weight=1
|
||||||
|
|
||||||
upgrade_type=$(ynh_check_app_version_changed)
|
upgrade_type=$(ynh_check_app_version_changed)
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ ynh_abort_if_errors
|
||||||
#=================================================
|
#=================================================
|
||||||
# ENSURE DOWNWARD COMPATIBILITY
|
# ENSURE DOWNWARD COMPATIBILITY
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Ensuring downward compatibility..."
|
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
||||||
|
|
||||||
# If db_name doesn't exist, create it
|
# If db_name doesn't exist, create it
|
||||||
if [ -z "$db_name" ]; then
|
if [ -z "$db_name" ]; then
|
||||||
|
@ -70,14 +70,6 @@ if ynh_legacy_permissions_exists; then
|
||||||
ynh_app_setting_delete --app=$app --key=is_public
|
ynh_app_setting_delete --app=$app --key=is_public
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# 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"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GET THE CALDAV APP
|
# GET THE CALDAV APP
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -101,16 +93,24 @@ else
|
||||||
ynh_die --message="Please install Baïkal or Radicale before AgenDAV."
|
ynh_die --message="Please install Baïkal or Radicale before AgenDAV."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CREATE DEDICATED USER
|
||||||
|
#=================================================
|
||||||
|
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"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||||
then
|
then
|
||||||
ynh_script_progression --message="Upgrading source files..."
|
ynh_script_progression --message="Upgrading source files..." --weight=1
|
||||||
|
|
||||||
# Download, check integrity, uncompress and patch the source from app.src
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
ynh_setup_source --dest_dir="$final_path"
|
ynh_setup_source --dest_dir="$final_path"--keep="web/config/settings.php"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
chmod 750 "$final_path"
|
chmod 750 "$final_path"
|
||||||
|
@ -120,14 +120,14 @@ chown -R $app:www-data "$final_path"
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPGRADE DEPENDENCIES
|
# UPGRADE DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading dependencies..."
|
ynh_script_progression --message="Upgrading dependencies..." --weight=1
|
||||||
|
|
||||||
ynh_install_app_dependencies $pkg_dependencies
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PHP-FPM CONFIGURATION
|
# 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
|
# Create a dedicated PHP-FPM config
|
||||||
ynh_add_fpm_config
|
ynh_add_fpm_config
|
||||||
|
@ -135,7 +135,7 @@ ynh_add_fpm_config
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# 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
|
# Create a dedicated NGINX config
|
||||||
ynh_add_nginx_config
|
ynh_add_nginx_config
|
||||||
|
@ -157,42 +157,20 @@ timezone=$(cat /etc/timezone)
|
||||||
caldav_domain=$(ynh_app_setting_get --app=$caldav_app --key=domain)
|
caldav_domain=$(ynh_app_setting_get --app=$caldav_app --key=domain)
|
||||||
caldav_path=$(ynh_app_setting_get --app=$caldav_app --key=path)
|
caldav_path=$(ynh_app_setting_get --app=$caldav_app --key=path)
|
||||||
caldav_url="https://${caldav_domain}${caldav_path%/}"
|
caldav_url="https://${caldav_domain}${caldav_path%/}"
|
||||||
|
caldav_baseurl="${caldav_url}${caldav_baseurl}"
|
||||||
|
|
||||||
conf_path="${final_path}/web/config/settings.php"
|
ynh_add_config --template="../conf/settings.php" --destination="${final_path}/web/config/settings.php"
|
||||||
|
|
||||||
ynh_backup_if_checksum_is_different --file="$conf_path"
|
|
||||||
|
|
||||||
cp ../conf/settings.php "$conf_path"
|
|
||||||
|
|
||||||
logdir=/var/log/$app
|
|
||||||
|
|
||||||
ynh_replace_string --match_string="__DBUSER__" --replace_string="$db_name" --target_file="$conf_path"
|
|
||||||
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
|
||||||
ynh_replace_string --match_string="__DBPASS__" --replace_string="$db_pwd" --target_file="$conf_path"
|
|
||||||
ynh_replace_string --match_string="__DBNAME__" --replace_string="$db_name" --target_file="$conf_path"
|
|
||||||
ynh_replace_string --match_string="__ENCRYPTKEY__" --replace_string="$encryptkey" --target_file="$conf_path"
|
|
||||||
ynh_replace_string --match_string="__LOGDIR__" --replace_string="$logdir" --target_file="$conf_path"
|
|
||||||
ynh_replace_string --match_string="__TIMEZONE__" --replace_string="$timezone" --target_file="$conf_path"
|
|
||||||
ynh_replace_string --match_string="__LANGUAGE__" --replace_string="$language" --target_file="$conf_path"
|
|
||||||
ynh_replace_string --match_string="__CALDAV_BASEURL__" --replace_string="${caldav_url}${caldav_baseurl}" --target_file="$conf_path"
|
|
||||||
ynh_replace_string --match_string="__CALDAV_DOMAIN__" --replace_string="$caldav_domain" --target_file="$conf_path"
|
|
||||||
|
|
||||||
ynh_store_file_checksum --file="$conf_path"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RUN DATABASE MIGRATIONS (INCLUDES INITIALIZATION)
|
# RUN DATABASE MIGRATIONS (INCLUDES INITIALIZATION)
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading AgenDAV..."
|
ynh_script_progression --message="Upgrading AgenDAV..." --weight=1
|
||||||
|
|
||||||
(
|
(
|
||||||
cd $final_path
|
cd $final_path
|
||||||
php${phpversion} agendavcli migrations:migrate --no-interaction
|
php${phpversion} agendavcli migrations:migrate --no-interaction
|
||||||
)
|
)
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SECURE FILES AND DIRECTORIES
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
chown -R $app:www-data $final_path
|
chown -R $app:www-data $final_path
|
||||||
|
|
||||||
# Only agendav user should write here
|
# Only agendav user should write here
|
||||||
|
@ -210,8 +188,8 @@ chmod -R 750 ${final_path}/web/config/
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=2
|
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=2
|
||||||
|
|
||||||
mkdir -p $logdir
|
mkdir -p /var/log/$app
|
||||||
chown -R $app: $logdir
|
chown -R $app: /var/log/$app
|
||||||
|
|
||||||
# Use logrotate to manage application logfile(s)
|
# Use logrotate to manage application logfile(s)
|
||||||
ynh_use_logrotate --non-append
|
ynh_use_logrotate --non-append
|
||||||
|
@ -219,7 +197,7 @@ ynh_use_logrotate --non-append
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# 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
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue