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

Normalization from example_ynh

This commit is contained in:
Maniack Crudelis 2019-02-15 19:49:22 +01:00
parent 1600501d32
commit 3c09458527
10 changed files with 185 additions and 186 deletions

View file

@ -1,5 +1,4 @@
;; Test complet ;; Test complet
auto_remove=1
; Manifest ; Manifest
domain="domain.tld" (DOMAIN) domain="domain.tld" (DOMAIN)
path="/path" (PATH) path="/path" (PATH)
@ -16,13 +15,9 @@
upgrade=1 from_commit=f159f7a9bdbe470ec026edf09a6eebf10f23425e upgrade=1 from_commit=f159f7a9bdbe470ec026edf09a6eebf10f23425e
backup_restore=1 backup_restore=1
multi_instance=1 multi_instance=1
wrong_user=1
wrong_path=1
incorrect_path=1 incorrect_path=1
corrupt_source=0
fail_download_source=0
port_already_use=0 port_already_use=0
final_path_already_use=0 change_url=0
;;; Levels ;;; Levels
Level 1=auto Level 1=auto
Level 2=auto Level 2=auto

View file

@ -2,3 +2,5 @@ SOURCE_URL=https://github.com/kanboard/kanboard/archive/v1.2.8.tar.gz
SOURCE_SUM=04c1d863918383f53cf98f7a3e989728eecbb90d0ae0d5ebaf0c8a1151b3f771 SOURCE_SUM=04c1d863918383f53cf98f7a3e989728eecbb90d0ae0d5ebaf0c8a1151b3f771
SOURCE_SUM_PRG=sha256sum SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=

View file

@ -34,7 +34,7 @@ define('FILES_DIR', DATA_DIR.DIRECTORY_SEPARATOR.'files');
define('MAIL_CONFIGURATION', true); define('MAIL_CONFIGURATION', true);
// E-mail address for the "From" header (notifications) // E-mail address for the "From" header (notifications)
define('MAIL_FROM', 'yuno_email'); define('MAIL_FROM', '__EMAIL__');
// Mail transport available: "smtp", "sendmail", "mail" (PHP mail function), "postmark", "mailgun", "sendgrid" // Mail transport available: "smtp", "sendmail", "mail" (PHP mail function), "postmark", "mailgun", "sendgrid"
define('MAIL_TRANSPORT', 'mail'); define('MAIL_TRANSPORT', 'mail');
@ -58,16 +58,16 @@ define('DB_RUN_MIGRATIONS', false);
define('DB_DRIVER', 'mysql'); define('DB_DRIVER', 'mysql');
// Mysql/Postgres username // Mysql/Postgres username
define('DB_USERNAME', 'yuno_dbuser'); define('DB_USERNAME', '__DB_NAME__');
// Mysql/Postgres password // Mysql/Postgres password
define('DB_PASSWORD', 'yuno_dbpdw'); define('DB_PASSWORD', '__DB_PWD__');
// Mysql/Postgres hostname // Mysql/Postgres hostname
define('DB_HOSTNAME', 'localhost'); define('DB_HOSTNAME', 'localhost');
// Mysql/Postgres database name // Mysql/Postgres database name
define('DB_NAME', 'yuno_dbuser'); define('DB_NAME', '__DB_NAME__');
// Mysql/Postgres custom port (null = default port) // Mysql/Postgres custom port (null = default port)
define('DB_PORT', null); define('DB_PORT', null);
@ -180,10 +180,10 @@ define('REVERSE_PROXY_AUTH', true);
define('REVERSE_PROXY_USER_HEADER', 'REMOTE_USER'); define('REVERSE_PROXY_USER_HEADER', 'REMOTE_USER');
// Username of the admin, by default blank // Username of the admin, by default blank
define('REVERSE_PROXY_DEFAULT_ADMIN', 'yuno_admin'); define('REVERSE_PROXY_DEFAULT_ADMIN', '__USER__');
// Default domain to use for setting the email address // Default domain to use for setting the email address
define('REVERSE_PROXY_DEFAULT_DOMAIN', 'yuno_domain'); define('REVERSE_PROXY_DEFAULT_DOMAIN', '__DOMAIN__');
// Enable/disable remember me authentication // Enable/disable remember me authentication
define('REMEMBER_ME_AUTH', false); define('REMEMBER_ME_AUTH', false);

View file

@ -1,9 +1,14 @@
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ { location __PATH__/ {
# Path to source
alias __FINALPATH__/; alias __FINALPATH__/;
# Force usage of https
if ($scheme = http) { if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent; rewrite ^ https://$server_name$request_uri? permanent;
} }
index index.php; index index.php;
client_max_body_size 50M; client_max_body_size 50M;
try_files $uri $uri/ /index.php?$args; try_files $uri $uri/ /index.php?$args;

View file

@ -33,36 +33,36 @@
"install": [ "install": [
{ {
"name": "domain", "name": "domain",
"type": "domain",
"ask": { "ask": {
"en": "Choose a domain for Kanboard" "en": "Choose a domain for Kanboard"
}, },
"example": "domain.org", "example": "domain.org"
"type": "domain"
}, },
{ {
"name": "path", "name": "path",
"type": "path",
"ask": { "ask": {
"en": "Choose a path for Kanboard" "en": "Choose a path for Kanboard"
}, },
"type": "path",
"example": "/kanboard", "example": "/kanboard",
"default": "/kanboard" "default": "/kanboard"
}, },
{ {
"name": "admin", "name": "admin",
"type": "user",
"ask": { "ask": {
"en": "Choose the admin user for Kanboard" "en": "Choose the admin user for Kanboard"
}, },
"type": "user",
"example": "johndoe" "example": "johndoe"
}, },
{ {
"name": "is_public", "name": "is_public",
"type": "boolean",
"ask": { "ask": {
"en": "Is it a public site ?" "en": "Is it a public site ?"
}, },
"type": "boolean", "default": false
"default": "0"
} }
] ]
} }

View file

@ -6,12 +6,7 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
if [ ! -e _common.sh ]; then source ../settings/scripts/_common.sh
# Get the _common.sh file if it's not in the current directory
cp ../settings/scripts/_common.sh ./_common.sh
chmod a+rx _common.sh
fi
source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
@ -27,12 +22,9 @@ ynh_abort_if_errors
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
# Set app specific variables domain=$(ynh_app_setting_get $app domain)
dbname=$app final_path=$(ynh_app_setting_get $app final_path)
db_name=$(ynh_app_setting_get $app db_name)
# Retrieve app settings
domain=$(ynh_app_setting_get "$app" domain)
final_path=$(ynh_app_setting_get "$app" final_path)
#================================================= #=================================================
# STANDARD BACKUP STEPS # STANDARD BACKUP STEPS
@ -40,14 +32,13 @@ final_path=$(ynh_app_setting_get "$app" final_path)
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
# Copy the app source files
ynh_backup "$final_path" ynh_backup "$final_path"
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # BACKUP THE NGINX CONFIGURATION
#================================================= #=================================================
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# BACKUP THE PHP-FPM CONFIGURATION # BACKUP THE PHP-FPM CONFIGURATION
@ -66,4 +57,5 @@ ynh_backup "/etc/fail2ban/filter.d/$app.conf"
# BACKUP THE MYSQL DATABASE # BACKUP THE MYSQL DATABASE
#================================================= #=================================================
ynh_mysql_dump_db "$dbname" > ./db.sql ynh_mysql_dump_db "$db_name" > db.sql

View file

@ -20,7 +20,6 @@ ynh_abort_if_errors
# RETRIEVE ARGUMENTS FROM THE MANIFEST # RETRIEVE ARGUMENTS FROM THE MANIFEST
#================================================= #=================================================
# Retrieve arguments
domain=$YNH_APP_ARG_DOMAIN domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH path_url=$YNH_APP_ARG_PATH
admin=$YNH_APP_ARG_ADMIN admin=$YNH_APP_ARG_ADMIN
@ -33,14 +32,12 @@ app=$YNH_APP_INSTANCE_NAME
#================================================= #=================================================
# Check destination directory # Check destination directory
final_path="/var/www/$app" final_path=/var/www/$app
test ! -e "$final_path" || ynh_die "This path already contains a folder" test ! -e "$final_path" || ynh_die "This path already contains a folder"
# Normalize the url path syntax # Normalize the url path syntax
path_url=$(ynh_normalize_url_path "$path_url") path_url=$(ynh_normalize_url_path "$path_url")
# Check web path availability
ynh_webpath_available "$domain" "$path_url"
# Register (book) web path # Register (book) web path
ynh_webpath_register "$app" "$domain" "$path_url" ynh_webpath_register "$app" "$domain" "$path_url"
@ -48,16 +45,13 @@ ynh_webpath_register "$app" "$domain" "$path_url"
# STORE SETTINGS FROM MANIFEST # STORE SETTINGS FROM MANIFEST
#================================================= #=================================================
ynh_app_setting_set "$app" domain "$domain" ynh_app_setting_set $app domain $domain
ynh_app_setting_set "$app" final_path "$final_path" ynh_app_setting_set $app final_path $final_path
ynh_app_setting_set "$app" adminusername "$admin" ynh_app_setting_set $app adminusername $admin
ynh_app_setting_set "$app" is_public "$is_public" ynh_app_setting_set $app is_public $is_public
#================================================= #=================================================
# STANDARD MODIFICATIONS # STANDARD MODIFICATIONS
#=================================================
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
@ -68,27 +62,25 @@ ynh_install_app_dependencies $pkg_dependencies
# CREATE A MYSQL DATABASE # CREATE A MYSQL DATABASE
#================================================ #================================================
# Generate random password db_name=$(ynh_sanitize_dbid $app)
dbpass=$(ynh_string_random) ynh_app_setting_set $app db_name $db_name
dbname=$app ynh_mysql_setup_db $db_name $db_name
dbuser=$app
# Initialize database and store mysql password for upgrade
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
ynh_app_setting_set "$app" mysqlpwd "$dbpass"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_app_setting_set $app final_path $final_path
# 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 "$final_path" ynh_setup_source "$final_path"
mkdir -p "$final_path"/sessions/
mkdir -p $final_path/sessions/
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
# Create a dedicated nginx config
ynh_add_nginx_config ynh_add_nginx_config
#================================================= #=================================================
@ -96,39 +88,39 @@ ynh_add_nginx_config
#================================================= #=================================================
# Create a system user # Create a system user
ynh_system_user_create "$app" ynh_system_user_create $app
#================================================= #=================================================
# PHP-FPM CONFIGURATION # PHP-FPM CONFIGURATION
#================================================= #=================================================
# Create a dedicated php-fpm config
ynh_add_fpm_config ynh_add_fpm_config
#================================================= #=================================================
# SPECIFIC SETUP # SPECIFIC SETUP
#================================================= #=================================================
# Create config.php # CREATE CONFIG.PHP
#================================================= #=================================================
# Retrieve admin email # Retrieve admin email
email=$(ynh_user_get_info "$admin" mail) email=$(ynh_user_get_info $admin mail)
# Copy and edit config.php # Copy and edit config.php
config_php="${final_path}/config.php" config_php="${final_path}/config.php"
cp ../conf/config.php "$config_php" cp ../conf/config.php "$config_php"
ynh_replace_string "yuno_dbpdw" "$dbpass" "$config_php" ynh_replace_string "__DB_PWD__" "$db_pwd" "$config_php"
ynh_replace_string "yuno_dbuser" "$dbuser" "$config_php" ynh_replace_string "__DB_NAME__" $db_name "$config_php"
ynh_replace_string "yuno_admin" "$admin" "$config_php" ynh_replace_string "__USER__" $admin "$config_php"
ynh_replace_string "yuno_email" "$email" "$config_php" ynh_replace_string "__EMAIL__" $email "$config_php"
ynh_replace_string "yuno_domain" "$domain" "$config_php" ynh_replace_string "__DOMAIN__" $domain "$config_php"
#================================================= #=================================================
# Database initialization # DATABASE INITIALIZATION
#================================================= #=================================================
# Init database ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" < "${final_path}/app/Schema/Sql/mysql.sql"
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < "${final_path}/app/Schema/Sql/mysql.sql"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
@ -136,10 +128,10 @@ ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < "${final_path}/app/Schema/S
# SECURE FILES AND DIRECTORIES # SECURE FILES AND DIRECTORIES
#================================================ #================================================
# Set permissions to kanboard and data directory # Set permissions to app files
chown -R root:root "$final_path" chown -R root: $final_path
chown -R "$app" "$final_path"/{data,plugins,sessions} chown -R $app $final_path/{data,plugins,sessions}
chmod -R 700 "$final_path"/sessions chmod -R 700 $final_path/sessions
#================================================= #=================================================
# SETUP FAIL2BAN # SETUP FAIL2BAN
@ -163,21 +155,26 @@ else
fi fi
# Make app public or private # Make app public or private
if [[ "$is_public" -eq 1 ]]; if [ $is_public -eq 1 ]
then then
ynh_app_setting_set "$app" unprotected_uris "/" ynh_app_setting_set $app unprotected_uris "/"
ynh_replace_string "define('LDAP_AUTH'.*$" "define('LDAP_AUTH', true);" "$config_php" ynh_replace_string "define('LDAP_AUTH'.*$" "define('LDAP_AUTH', true);" "$config_php"
ynh_replace_string "define('HIDE_LOGIN_FORM'.*$" "define('HIDE_LOGIN_FORM', false);" "$config_php" ynh_replace_string "define('HIDE_LOGIN_FORM'.*$" "define('HIDE_LOGIN_FORM', false);" "$config_php"
ynh_replace_string "define('REMEMBER_ME_AUTH'.*$" "define('REMEMBER_ME_AUTH', true);" "$config_php" ynh_replace_string "define('REMEMBER_ME_AUTH'.*$" "define('REMEMBER_ME_AUTH', true);" "$config_php"
ynh_replace_string "define('DISABLE_LOGOUT'.*$" "define('DISABLE_LOGOUT', false);" "$config_php" ynh_replace_string "define('DISABLE_LOGOUT'.*$" "define('DISABLE_LOGOUT', false);" "$config_php"
else else
ynh_app_setting_set "$app" unprotected_uris "/jsonrpc.php" ynh_app_setting_set $app unprotected_uris "/jsonrpc.php"
fi fi
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum "$config_php"
#=================================================
# RELOAD NGINX
#=================================================
systemctl reload nginx
#================================================= #=================================================
# RELOAD NGINX & PHP5-FPM
#================================================= #=================================================
# Reload services
service php5-fpm restart
service nginx reload

View file

@ -15,12 +15,13 @@ source /usr/share/yunohost/helpers
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get "$app" domain) domain=$(ynh_app_setting_get $app domain)
final_path=$(ynh_app_setting_get "$app" final_path) final_path=$(ynh_app_setting_get $app final_path)
db_name=$(ynh_app_setting_get $app db_name)
dbname=$app final_path=$(ynh_app_setting_get $app final_path)
dbuser=$app
#=================================================
# STANDARD REMOVE
#================================================= #=================================================
# REMOVE DEPENDENCIES # REMOVE DEPENDENCIES
#================================================= #=================================================
@ -33,12 +34,13 @@ ynh_remove_app_dependencies
#================================================= #=================================================
# 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 "$dbuser" "$dbname" ynh_mysql_remove_db $db_name $db_name
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================
# Remove the app directory securely
ynh_secure_remove "$final_path" ynh_secure_remove "$final_path"
#================================================= #=================================================
@ -52,10 +54,21 @@ ynh_remove_nginx_config
# REMOVE PHP-FPM CONFIGURATION # REMOVE PHP-FPM CONFIGURATION
#================================================= #=================================================
# Remove the dedicated php-fpm config
ynh_remove_fpm_config ynh_remove_fpm_config
#=================================================
# GENERIC FINALIZATION
#================================================= #=================================================
# REMOVE FAIL2BAN CONFIGURATION # REMOVE FAIL2BAN CONFIGURATION
#================================================= #=================================================
ynh_remove_fail2ban_config ynh_remove_fail2ban_config
#=================================================
# REMOVE DEDICATED USER
#=================================================
# Delete a system user
ynh_system_user_delete $app

View file

@ -6,12 +6,7 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
if [ ! -e _common.sh ]; then source ../settings/scripts/_common.sh
# Get the _common.sh file if it's not in the current directory
cp ../settings/scripts/_common.sh ./_common.sh
chmod a+rx _common.sh
fi
source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
@ -21,22 +16,16 @@ source /usr/share/yunohost/helpers
# 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
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
# Set app specific variables domain=$(ynh_app_setting_get $app domain)
dbname=$app path_url=$(ynh_app_setting_get $app path)
dbuser=$app final_path=$(ynh_app_setting_get $app final_path)
db_name=$(ynh_app_setting_get $app db_name)
# Retrieve old app settings
domain=$(ynh_app_setting_get "$app" domain)
path_url=$(ynh_app_setting_get "$app" path)
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
final_path=$(ynh_app_setting_get "$app" final_path)
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # CHECK IF THE APP CAN BE RESTORED
@ -44,59 +33,57 @@ final_path=$(ynh_app_setting_get "$app" final_path)
ynh_webpath_available $domain $path_url \ ynh_webpath_available $domain $path_url \
|| ynh_die "Path not available: ${domain}${path_url}" || ynh_die "Path not available: ${domain}${path_url}"
test ! -d $final_path \ test ! -d $final_path \
|| ynh_die "There is already a directory: $final_path " || ynh_die "There is already a directory: $final_path "
#================================================= #=================================================
# STANDARD RESTORATION STEPS # STANDARD RESTORATION STEPS
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# RESTORE THE NGINX CONFIGURATION # RESTORE THE NGINX CONFIGURATION
#================================================= #=================================================
ynh_restore_file "/etc/nginx/conf.d/${domain}.d/${app}.conf" ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
# Restore the app files
ynh_restore_file "$final_path" ynh_restore_file "$final_path"
#=================================================
# RESTORE THE MYSQL DATABASE
#=================================================
ynh_mysql_setup_db "$dbuser" "$dbname" "$dbpass"
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ./db.sql
#================================================= #=================================================
# RECREATE THE DEDICATED USER # RECREATE THE DEDICATED USER
#================================================= #=================================================
# Create the dedicated user (if not existing) # Create the dedicated user (if not existing)
ynh_system_user_create "$app" ynh_system_user_create $app
#================================================= #=================================================
# RESTORE USER RIGHTS # RESTORE USER RIGHTS
#================================================= #=================================================
chown -R root:root "$final_path" # Restore permissions to app files
chown -R "$app" "$final_path"/{data,plugins,sessions} chown -R $app $final_path/{data,plugins,sessions}
chmod -R 700 "$final_path"/sessions
#================================================= #=================================================
# RESTORE THE PHP-FPM CONFIGURATION # RESTORE THE PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_restore_file "/etc/php5/fpm/pool.d/${app}.conf"
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# RESTORE THE MYSQL DATABASE
#=================================================
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
ynh_mysql_setup_db $db_name $db_name $db_pwd
ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql
#================================================= #=================================================
# RESTORE FAIL2BAN CONFIGURATION # RESTORE FAIL2BAN CONFIGURATION
@ -113,4 +100,5 @@ systemctl restart fail2ban
#================================================= #=================================================
service php5-fpm restart service php5-fpm restart
service nginx reload systemctl reload nginx

View file

@ -10,59 +10,47 @@ source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # LOAD SETTINGS
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#================================================= #=================================================
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
# Set app specific variables domain=$(ynh_app_setting_get $app domain)
dbuser=$app path_url=$(ynh_app_setting_get $app path)
admin=$(ynh_app_setting_get $app adminusername)
is_public=$(ynh_app_setting_get $app is_public)
final_path=$(ynh_app_setting_get $app final_path)
db_name=$(ynh_app_setting_get $app db_name)
# Retrieve settings #=================================================
domain=$(ynh_app_setting_get "$app" domain) # ENSURE DOWNWARD COMPATIBILITY
path_url=$(ynh_app_setting_get "$app" path) #=================================================
admin=$(ynh_app_setting_get "$app" adminusername)
email=$(ynh_user_get_info "$admin" mail)
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
is_public=$(ynh_app_setting_get "$app" is_public)
final_path=$(ynh_app_setting_get "$app" final_path)
if [[ -z "$is_public" ]]
then # Old version doesnt have is_public settings
is_public=0
ynh_app_setting_set "$app" is_public "$is_public"
fi
# Fix is_public as a boolean value # Fix is_public as a boolean value
if [ "$is_public" = "Yes" ]; then if [ "$is_public" = "Yes" ]; then
ynh_app_setting_set "$app" is_public 1 ynh_app_setting_set $app is_public 1
is_public=1 is_public=1
elif [ "$is_public" = "No" ]; then elif [ "$is_public" = "No" ]; then
ynh_app_setting_set "$app" is_public 0 ynh_app_setting_set $app is_public 0
is_public=0 is_public=0
fi fi
# If db_name doesn't exist, create it
if [ -z $db_name ]; then
db_name=$(ynh_sanitize_dbid $app)
ynh_app_setting_set $app db_name $db_name
fi
# If final_path doesn't exist, create it # If final_path doesn't exist, create it
if [[ -z "$final_path" ]] if [ -z $final_path ]; then
then final_path=/var/www/$app
final_path="/var/www/$app" ynh_app_setting_set $app final_path $final_path
ynh_app_setting_set "$app" final_path "$final_path"
fi fi
#================================================= #=================================================
# CHECK THE PATH # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
# Normalize the URL path syntax
path_url=$(ynh_normalize_url_path $path_url)
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade
ynh_clean_setup () { ynh_clean_setup () {
@ -72,6 +60,13 @@ ynh_clean_setup () {
# 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
#=================================================
# CHECK THE PATH
#=================================================
# Normalize the URL path syntax
path_url=$(ynh_normalize_url_path $path_url)
#================================================= #=================================================
# STANDARD UPGRADE STEPS # STANDARD UPGRADE STEPS
#================================================= #=================================================
@ -81,6 +76,7 @@ ynh_abort_if_errors
# Move old app dir # Move old app dir
mv "$final_path" "$final_path.old" mv "$final_path" "$final_path.old"
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source "$final_path" ynh_setup_source "$final_path"
mkdir -p "$final_path"/sessions mkdir -p "$final_path"/sessions
@ -106,8 +102,8 @@ ynh_add_nginx_config
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
# Create a system user # Create a dedicated user (if not existing)
ynh_system_user_create "$app" ynh_system_user_create $app
#================================================= #=================================================
# PHP-FPM CONFIGURATION # PHP-FPM CONFIGURATION
@ -117,7 +113,7 @@ ynh_system_user_create "$app"
ynh_add_fpm_config ynh_add_fpm_config
#================================================= #=================================================
# INSTALL DEPENDENCIES # UPGRADE DEPENDENCIES
#================================================= #=================================================
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
@ -125,29 +121,35 @@ ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# SPECIFIC UPGRADE # SPECIFIC UPGRADE
#================================================= #=================================================
# Create config.php # CREATE CONFIG.PHP
#================================================= #=================================================
# Retrieve admin email
email=$(ynh_user_get_info $admin mail)
# Copy and edit config.php # Copy and edit config.php
config_php="$final_path/config.php" config_php="${final_path}/config.php"
cp ../conf/config.php "$config_php"
ynh_replace_string "yuno_dbpdw" "$dbpass" "$config_php" ynh_backup_if_checksum_is_different "$config_php"
ynh_replace_string "yuno_dbuser" "$dbuser" "$config_php"
ynh_replace_string "yuno_admin" "$admin" "$config_php" cp ../conf/config.php "$config_php"
ynh_replace_string "yuno_email" "$email" "$config_php" db_pwd=$(ynh_app_setting_get $app mysqlpwd)
ynh_replace_string "yuno_domain" "$domain" "$config_php" ynh_replace_string "__DB_PWD__" "$db_pwd" "$config_php"
ynh_replace_string "__DB_NAME__" $db_name "$config_php"
ynh_replace_string "__USER__" $admin "$config_php"
ynh_replace_string "__EMAIL__" $email "$config_php"
ynh_replace_string "__DOMAIN__" $domain "$config_php"
#================================================= #=================================================
# Database initialization # UPGRADE KANBOARD
#================================================= #=================================================
( (
cd "$final_path" cd "$final_path"
# Launch database migratio # Launch database migration
php cli db:migrate --no-interaction --verbose php cli db:migrate --no-interaction --verbose
# Launch plugins migration # Launch plugins migration
php cli plugin:upgrade --no-interaction --verbose php cli plugin:upgrade --no-interaction --verbose
) )
#================================================= #=================================================
@ -156,13 +158,13 @@ ynh_replace_string "yuno_domain" "$domain" "$config_php"
# SECURE FILES AND DIRECTORIES # SECURE FILES AND DIRECTORIES
#================================================= #=================================================
# Set permissions to kanboard and data directory # Set permissions to app files
chown -R root:root "$final_path" chown -R root: $final_path
chown -R "$app" "$final_path"/{data,plugins,sessions} chown -R $app $final_path/{data,plugins,sessions}
chmod -R 700 "$final_path"/sessions chmod -R 700 $final_path/sessions
#================================================= #=================================================
# SETUP SSOWAT # SETUP FAIL2BAN
#================================================= #=================================================
if [[ "$path_url" == "/" ]] if [[ "$path_url" == "/" ]]
@ -175,28 +177,33 @@ else
ynh_replace_string "^#sub_path_only" "" "$finalnginxconf" ynh_replace_string "^#sub_path_only" "" "$finalnginxconf"
ynh_store_file_checksum "$finalnginxconf" ynh_store_file_checksum "$finalnginxconf"
fi fi
#=================================================
# SETUP SSOWAT
#=================================================
# Make app public or private # Make app public or private
if [[ "$is_public" -eq 1 ]]; if [ $is_public -eq 1 ]
then then
ynh_app_setting_set "$app" unprotected_uris "/" ynh_app_setting_set $app unprotected_uris "/"
ynh_replace_string "define('LDAP_AUTH'.*$" "define('LDAP_AUTH', true);" "$config_php" ynh_replace_string "define('LDAP_AUTH'.*$" "define('LDAP_AUTH', true);" "$config_php"
ynh_replace_string "define('HIDE_LOGIN_FORM'.*$" "define('HIDE_LOGIN_FORM', false);" "$config_php" ynh_replace_string "define('HIDE_LOGIN_FORM'.*$" "define('HIDE_LOGIN_FORM', false);" "$config_php"
ynh_replace_string "define('REMEMBER_ME_AUTH'.*$" "define('REMEMBER_ME_AUTH', true);" "$config_php" ynh_replace_string "define('REMEMBER_ME_AUTH'.*$" "define('REMEMBER_ME_AUTH', true);" "$config_php"
ynh_replace_string "define('DISABLE_LOGOUT'.*$" "define('DISABLE_LOGOUT', false);" "$config_php" ynh_replace_string "define('DISABLE_LOGOUT'.*$" "define('DISABLE_LOGOUT', false);" "$config_php"
else else
ynh_app_setting_set "$app" unprotected_uris "/jsonrpc.php" ynh_app_setting_set $app unprotected_uris "/jsonrpc.php"
fi fi
#================================================= # Calculate and store the config file checksum into the app settings
# SETUP FAIL2BAN ynh_store_file_checksum "$config_php"
#=================================================
ynh_add_fail2ban_config "/var/log/nginx/$domain-error.log" "^.*authentication failure\" while reading response header from upstream, client: <HOST>,.*$" 5
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
service php5-fpm restart ynh_add_fail2ban_config "/var/log/nginx/$domain-error.log" "^.*authentication failure\" while reading response header from upstream, client: <HOST>,.*$" 5
systemctl reload nginx systemctl reload nginx
#=================================================
#=================================================
service php5-fpm restart