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:
parent
1600501d32
commit
3c09458527
10 changed files with 185 additions and 186 deletions
|
@ -1,5 +1,4 @@
|
|||
;; Test complet
|
||||
auto_remove=1
|
||||
; Manifest
|
||||
domain="domain.tld" (DOMAIN)
|
||||
path="/path" (PATH)
|
||||
|
@ -16,13 +15,9 @@
|
|||
upgrade=1 from_commit=f159f7a9bdbe470ec026edf09a6eebf10f23425e
|
||||
backup_restore=1
|
||||
multi_instance=1
|
||||
wrong_user=1
|
||||
wrong_path=1
|
||||
incorrect_path=1
|
||||
corrupt_source=0
|
||||
fail_download_source=0
|
||||
port_already_use=0
|
||||
final_path_already_use=0
|
||||
change_url=0
|
||||
;;; Levels
|
||||
Level 1=auto
|
||||
Level 2=auto
|
||||
|
|
|
@ -2,3 +2,5 @@ SOURCE_URL=https://github.com/kanboard/kanboard/archive/v1.2.8.tar.gz
|
|||
SOURCE_SUM=04c1d863918383f53cf98f7a3e989728eecbb90d0ae0d5ebaf0c8a1151b3f771
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FORMAT=tar.gz
|
||||
SOURCE_IN_SUBDIR=true
|
||||
SOURCE_FILENAME=
|
||||
|
|
|
@ -34,7 +34,7 @@ define('FILES_DIR', DATA_DIR.DIRECTORY_SEPARATOR.'files');
|
|||
define('MAIL_CONFIGURATION', true);
|
||||
|
||||
// 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"
|
||||
define('MAIL_TRANSPORT', 'mail');
|
||||
|
@ -58,16 +58,16 @@ define('DB_RUN_MIGRATIONS', false);
|
|||
define('DB_DRIVER', 'mysql');
|
||||
|
||||
// Mysql/Postgres username
|
||||
define('DB_USERNAME', 'yuno_dbuser');
|
||||
define('DB_USERNAME', '__DB_NAME__');
|
||||
|
||||
// Mysql/Postgres password
|
||||
define('DB_PASSWORD', 'yuno_dbpdw');
|
||||
define('DB_PASSWORD', '__DB_PWD__');
|
||||
|
||||
// Mysql/Postgres hostname
|
||||
define('DB_HOSTNAME', 'localhost');
|
||||
|
||||
// Mysql/Postgres database name
|
||||
define('DB_NAME', 'yuno_dbuser');
|
||||
define('DB_NAME', '__DB_NAME__');
|
||||
|
||||
// Mysql/Postgres custom port (null = default port)
|
||||
define('DB_PORT', null);
|
||||
|
@ -180,10 +180,10 @@ define('REVERSE_PROXY_AUTH', true);
|
|||
define('REVERSE_PROXY_USER_HEADER', 'REMOTE_USER');
|
||||
|
||||
// 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
|
||||
define('REVERSE_PROXY_DEFAULT_DOMAIN', 'yuno_domain');
|
||||
define('REVERSE_PROXY_DEFAULT_DOMAIN', '__DOMAIN__');
|
||||
|
||||
// Enable/disable remember me authentication
|
||||
define('REMEMBER_ME_AUTH', false);
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
|
||||
location __PATH__/ {
|
||||
|
||||
# Path to source
|
||||
alias __FINALPATH__/;
|
||||
|
||||
# Force usage of https
|
||||
if ($scheme = http) {
|
||||
rewrite ^ https://$server_name$request_uri? permanent;
|
||||
}
|
||||
|
||||
index index.php;
|
||||
client_max_body_size 50M;
|
||||
try_files $uri $uri/ /index.php?$args;
|
||||
|
|
|
@ -33,36 +33,36 @@
|
|||
"install": [
|
||||
{
|
||||
"name": "domain",
|
||||
"type": "domain",
|
||||
"ask": {
|
||||
"en": "Choose a domain for Kanboard"
|
||||
},
|
||||
"example": "domain.org",
|
||||
"type": "domain"
|
||||
"example": "domain.org"
|
||||
},
|
||||
{
|
||||
"name": "path",
|
||||
"type": "path",
|
||||
"ask": {
|
||||
"en": "Choose a path for Kanboard"
|
||||
},
|
||||
"type": "path",
|
||||
"example": "/kanboard",
|
||||
"default": "/kanboard"
|
||||
},
|
||||
{
|
||||
"name": "admin",
|
||||
"type": "user",
|
||||
"ask": {
|
||||
"en": "Choose the admin user for Kanboard"
|
||||
},
|
||||
"type": "user",
|
||||
"example": "johndoe"
|
||||
},
|
||||
{
|
||||
"name": "is_public",
|
||||
"type": "boolean",
|
||||
"ask": {
|
||||
"en": "Is it a public site ?"
|
||||
},
|
||||
"type": "boolean",
|
||||
"default": "0"
|
||||
"default": false
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -6,12 +6,7 @@
|
|||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
if [ ! -e _common.sh ]; then
|
||||
# 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 ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
|
@ -27,12 +22,9 @@ ynh_abort_if_errors
|
|||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Set app specific variables
|
||||
dbname=$app
|
||||
|
||||
# Retrieve app settings
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
final_path=$(ynh_app_setting_get "$app" final_path)
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
db_name=$(ynh_app_setting_get $app db_name)
|
||||
|
||||
#=================================================
|
||||
# STANDARD BACKUP STEPS
|
||||
|
@ -40,14 +32,13 @@ final_path=$(ynh_app_setting_get "$app" final_path)
|
|||
# BACKUP THE APP MAIN DIR
|
||||
#=================================================
|
||||
|
||||
# Copy the app source files
|
||||
ynh_backup "$final_path"
|
||||
|
||||
#=================================================
|
||||
# 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
|
||||
|
@ -66,4 +57,5 @@ ynh_backup "/etc/fail2ban/filter.d/$app.conf"
|
|||
# BACKUP THE MYSQL DATABASE
|
||||
#=================================================
|
||||
|
||||
ynh_mysql_dump_db "$dbname" > ./db.sql
|
||||
ynh_mysql_dump_db "$db_name" > db.sql
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ ynh_abort_if_errors
|
|||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||
#=================================================
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$YNH_APP_ARG_DOMAIN
|
||||
path_url=$YNH_APP_ARG_PATH
|
||||
admin=$YNH_APP_ARG_ADMIN
|
||||
|
@ -33,14 +32,12 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
#=================================================
|
||||
|
||||
# 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"
|
||||
|
||||
# Normalize the url path syntax
|
||||
path_url=$(ynh_normalize_url_path "$path_url")
|
||||
|
||||
# Check web path availability
|
||||
ynh_webpath_available "$domain" "$path_url"
|
||||
# Register (book) web path
|
||||
ynh_webpath_register "$app" "$domain" "$path_url"
|
||||
|
||||
|
@ -48,16 +45,13 @@ ynh_webpath_register "$app" "$domain" "$path_url"
|
|||
# STORE SETTINGS FROM MANIFEST
|
||||
#=================================================
|
||||
|
||||
ynh_app_setting_set "$app" domain "$domain"
|
||||
ynh_app_setting_set "$app" final_path "$final_path"
|
||||
ynh_app_setting_set "$app" adminusername "$admin"
|
||||
ynh_app_setting_set "$app" is_public "$is_public"
|
||||
|
||||
ynh_app_setting_set $app domain $domain
|
||||
ynh_app_setting_set $app final_path $final_path
|
||||
ynh_app_setting_set $app adminusername $admin
|
||||
ynh_app_setting_set $app is_public $is_public
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
|
@ -68,27 +62,25 @@ ynh_install_app_dependencies $pkg_dependencies
|
|||
# CREATE A MYSQL DATABASE
|
||||
#================================================
|
||||
|
||||
# Generate random password
|
||||
dbpass=$(ynh_string_random)
|
||||
dbname=$app
|
||||
dbuser=$app
|
||||
|
||||
# Initialize database and store mysql password for upgrade
|
||||
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
|
||||
ynh_app_setting_set "$app" mysqlpwd "$dbpass"
|
||||
db_name=$(ynh_sanitize_dbid $app)
|
||||
ynh_app_setting_set $app db_name $db_name
|
||||
ynh_mysql_setup_db $db_name $db_name
|
||||
|
||||
#=================================================
|
||||
# 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
|
||||
ynh_setup_source "$final_path"
|
||||
mkdir -p "$final_path"/sessions/
|
||||
|
||||
mkdir -p $final_path/sessions/
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
|
@ -96,39 +88,39 @@ ynh_add_nginx_config
|
|||
#=================================================
|
||||
|
||||
# Create a system user
|
||||
ynh_system_user_create "$app"
|
||||
ynh_system_user_create $app
|
||||
|
||||
#=================================================
|
||||
# PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
# Create a dedicated php-fpm config
|
||||
ynh_add_fpm_config
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
#=================================================
|
||||
# Create config.php
|
||||
# CREATE CONFIG.PHP
|
||||
#=================================================
|
||||
|
||||
# Retrieve admin email
|
||||
email=$(ynh_user_get_info "$admin" mail)
|
||||
email=$(ynh_user_get_info $admin mail)
|
||||
|
||||
# Copy and edit config.php
|
||||
config_php="${final_path}/config.php"
|
||||
|
||||
cp ../conf/config.php "$config_php"
|
||||
ynh_replace_string "yuno_dbpdw" "$dbpass" "$config_php"
|
||||
ynh_replace_string "yuno_dbuser" "$dbuser" "$config_php"
|
||||
ynh_replace_string "yuno_admin" "$admin" "$config_php"
|
||||
ynh_replace_string "yuno_email" "$email" "$config_php"
|
||||
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
|
||||
# DATABASE INITIALIZATION
|
||||
#=================================================
|
||||
|
||||
# Init database
|
||||
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < "${final_path}/app/Schema/Sql/mysql.sql"
|
||||
ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" < "${final_path}/app/Schema/Sql/mysql.sql"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
|
@ -136,10 +128,10 @@ ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < "${final_path}/app/Schema/S
|
|||
# SECURE FILES AND DIRECTORIES
|
||||
#================================================
|
||||
|
||||
# Set permissions to kanboard and data directory
|
||||
chown -R root:root "$final_path"
|
||||
chown -R "$app" "$final_path"/{data,plugins,sessions}
|
||||
chmod -R 700 "$final_path"/sessions
|
||||
# Set permissions to app files
|
||||
chown -R root: $final_path
|
||||
chown -R $app $final_path/{data,plugins,sessions}
|
||||
chmod -R 700 $final_path/sessions
|
||||
|
||||
#=================================================
|
||||
# SETUP FAIL2BAN
|
||||
|
@ -163,21 +155,26 @@ else
|
|||
fi
|
||||
|
||||
# Make app public or private
|
||||
if [[ "$is_public" -eq 1 ]];
|
||||
if [ $is_public -eq 1 ]
|
||||
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('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('DISABLE_LOGOUT'.*$" "define('DISABLE_LOGOUT', false);" "$config_php"
|
||||
else
|
||||
ynh_app_setting_set "$app" unprotected_uris "/jsonrpc.php"
|
||||
ynh_app_setting_set $app unprotected_uris "/jsonrpc.php"
|
||||
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
|
||||
|
|
|
@ -15,12 +15,13 @@ source /usr/share/yunohost/helpers
|
|||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
final_path=$(ynh_app_setting_get "$app" final_path)
|
||||
|
||||
dbname=$app
|
||||
dbuser=$app
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
db_name=$(ynh_app_setting_get $app db_name)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
|
@ -33,12 +34,13 @@ ynh_remove_app_dependencies
|
|||
#=================================================
|
||||
|
||||
# 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 the app directory securely
|
||||
ynh_secure_remove "$final_path"
|
||||
|
||||
#=================================================
|
||||
|
@ -52,10 +54,21 @@ ynh_remove_nginx_config
|
|||
# REMOVE PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
# Remove the dedicated php-fpm config
|
||||
ynh_remove_fpm_config
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# REMOVE FAIL2BAN CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_remove_fail2ban_config
|
||||
|
||||
#=================================================
|
||||
# REMOVE DEDICATED USER
|
||||
#=================================================
|
||||
|
||||
# Delete a system user
|
||||
ynh_system_user_delete $app
|
||||
|
||||
|
|
|
@ -6,12 +6,7 @@
|
|||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
if [ ! -e _common.sh ]; then
|
||||
# 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 ../settings/scripts/_common.sh
|
||||
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
|
||||
ynh_abort_if_errors
|
||||
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Set app specific variables
|
||||
dbname=$app
|
||||
dbuser=$app
|
||||
|
||||
# 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)
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
path_url=$(ynh_app_setting_get $app path)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
db_name=$(ynh_app_setting_get $app db_name)
|
||||
|
||||
#=================================================
|
||||
# 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_die "Path not available: ${domain}${path_url}"
|
||||
|
||||
test ! -d $final_path \
|
||||
|| ynh_die "There is already a directory: $final_path "
|
||||
|
||||
#=================================================
|
||||
# STANDARD RESTORATION STEPS
|
||||
#=================================================
|
||||
# REINSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
|
||||
# Define and install dependencies
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# 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 files
|
||||
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
|
||||
#=================================================
|
||||
|
||||
# Create the dedicated user (if not existing)
|
||||
ynh_system_user_create "$app"
|
||||
ynh_system_user_create $app
|
||||
|
||||
#=================================================
|
||||
# RESTORE USER RIGHTS
|
||||
#=================================================
|
||||
|
||||
chown -R root:root "$final_path"
|
||||
chown -R "$app" "$final_path"/{data,plugins,sessions}
|
||||
chmod -R 700 "$final_path"/sessions
|
||||
# Restore permissions to app files
|
||||
chown -R $app $final_path/{data,plugins,sessions}
|
||||
|
||||
#=================================================
|
||||
# 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
|
||||
|
@ -113,4 +100,5 @@ systemctl restart fail2ban
|
|||
#=================================================
|
||||
|
||||
service php5-fpm restart
|
||||
service nginx reload
|
||||
systemctl reload nginx
|
||||
|
||||
|
|
129
scripts/upgrade
129
scripts/upgrade
|
@ -10,59 +10,47 @@ source _common.sh
|
|||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Set app specific variables
|
||||
dbuser=$app
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
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)
|
||||
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
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
|
||||
# Fix is_public as a boolean value
|
||||
if [ "$is_public" = "Yes" ]; then
|
||||
ynh_app_setting_set "$app" is_public 1
|
||||
ynh_app_setting_set $app is_public 1
|
||||
is_public=1
|
||||
elif [ "$is_public" = "No" ]; then
|
||||
ynh_app_setting_set "$app" is_public 0
|
||||
ynh_app_setting_set $app is_public 0
|
||||
is_public=0
|
||||
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 [[ -z "$final_path" ]]
|
||||
then
|
||||
final_path="/var/www/$app"
|
||||
ynh_app_setting_set "$app" final_path "$final_path"
|
||||
if [ -z $final_path ]; then
|
||||
final_path=/var/www/$app
|
||||
ynh_app_setting_set $app final_path $final_path
|
||||
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
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup () {
|
||||
|
@ -72,6 +60,13 @@ ynh_clean_setup () {
|
|||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# CHECK THE PATH
|
||||
#=================================================
|
||||
|
||||
# Normalize the URL path syntax
|
||||
path_url=$(ynh_normalize_url_path $path_url)
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
|
@ -81,6 +76,7 @@ ynh_abort_if_errors
|
|||
# Move old app dir
|
||||
mv "$final_path" "$final_path.old"
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source "$final_path"
|
||||
mkdir -p "$final_path"/sessions
|
||||
|
||||
|
@ -106,8 +102,8 @@ ynh_add_nginx_config
|
|||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
|
||||
# Create a system user
|
||||
ynh_system_user_create "$app"
|
||||
# Create a dedicated user (if not existing)
|
||||
ynh_system_user_create $app
|
||||
|
||||
#=================================================
|
||||
# PHP-FPM CONFIGURATION
|
||||
|
@ -117,7 +113,7 @@ ynh_system_user_create "$app"
|
|||
ynh_add_fpm_config
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
@ -125,26 +121,32 @@ ynh_install_app_dependencies $pkg_dependencies
|
|||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
#=================================================
|
||||
# Create config.php
|
||||
# CREATE CONFIG.PHP
|
||||
#=================================================
|
||||
|
||||
# Retrieve admin email
|
||||
email=$(ynh_user_get_info $admin mail)
|
||||
|
||||
# Copy and edit config.php
|
||||
config_php="$final_path/config.php"
|
||||
cp ../conf/config.php "$config_php"
|
||||
config_php="${final_path}/config.php"
|
||||
|
||||
ynh_replace_string "yuno_dbpdw" "$dbpass" "$config_php"
|
||||
ynh_replace_string "yuno_dbuser" "$dbuser" "$config_php"
|
||||
ynh_replace_string "yuno_admin" "$admin" "$config_php"
|
||||
ynh_replace_string "yuno_email" "$email" "$config_php"
|
||||
ynh_replace_string "yuno_domain" "$domain" "$config_php"
|
||||
ynh_backup_if_checksum_is_different "$config_php"
|
||||
|
||||
cp ../conf/config.php "$config_php"
|
||||
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
|
||||
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"
|
||||
# Launch database migratio
|
||||
# Launch database migration
|
||||
php cli db:migrate --no-interaction --verbose
|
||||
# Launch plugins migration
|
||||
php cli plugin:upgrade --no-interaction --verbose
|
||||
|
@ -156,13 +158,13 @@ ynh_replace_string "yuno_domain" "$domain" "$config_php"
|
|||
# SECURE FILES AND DIRECTORIES
|
||||
#=================================================
|
||||
|
||||
# Set permissions to kanboard and data directory
|
||||
chown -R root:root "$final_path"
|
||||
chown -R "$app" "$final_path"/{data,plugins,sessions}
|
||||
chmod -R 700 "$final_path"/sessions
|
||||
# Set permissions to app files
|
||||
chown -R root: $final_path
|
||||
chown -R $app $final_path/{data,plugins,sessions}
|
||||
chmod -R 700 $final_path/sessions
|
||||
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
# SETUP FAIL2BAN
|
||||
#=================================================
|
||||
|
||||
if [[ "$path_url" == "/" ]]
|
||||
|
@ -175,28 +177,33 @@ else
|
|||
ynh_replace_string "^#sub_path_only" "" "$finalnginxconf"
|
||||
ynh_store_file_checksum "$finalnginxconf"
|
||||
fi
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
|
||||
# Make app public or private
|
||||
if [[ "$is_public" -eq 1 ]];
|
||||
if [ $is_public -eq 1 ]
|
||||
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('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('DISABLE_LOGOUT'.*$" "define('DISABLE_LOGOUT', false);" "$config_php"
|
||||
else
|
||||
ynh_app_setting_set "$app" unprotected_uris "/jsonrpc.php"
|
||||
ynh_app_setting_set $app unprotected_uris "/jsonrpc.php"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# SETUP FAIL2BAN
|
||||
#=================================================
|
||||
|
||||
ynh_add_fail2ban_config "/var/log/nginx/$domain-error.log" "^.*authentication failure\" while reading response header from upstream, client: <HOST>,.*$" 5
|
||||
# Calculate and store the config file checksum into the app settings
|
||||
ynh_store_file_checksum "$config_php"
|
||||
|
||||
#=================================================
|
||||
# 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
|
||||
|
||||
#=================================================
|
||||
#=================================================
|
||||
|
||||
service php5-fpm restart
|
||||
|
|
Loading…
Reference in a new issue