1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/hubzilla_ynh.git synced 2024-09-03 19:26:21 +02:00

Apply example_ynh

This commit is contained in:
yalh76 2022-07-13 17:22:05 +02:00
parent 67057b98ef
commit 1249585dca
13 changed files with 371 additions and 463 deletions

View file

@ -18,3 +18,7 @@
;;; Options ;;; Options
Email=anmol@datamol.org Email=anmol@datamol.org
Notification=change Notification=change
;;; Upgrade options
; commit=3642c110f0e927ba36ee32e738a81e6afce958f7
name=21.05.21~ynh1
manifest_arg=domain=DOMAIN&admin=USER&database=1&

View file

@ -1,6 +1,7 @@
SOURCE_URL=https://framagit.org/hubzilla/core/-/archive/6.0/core-6.0.tar.gz SOURCE_URL=https://framagit.org/hubzilla/core/-/archive/7.4/core-7.4.tar.gz
SOURCE_SUM=d1982e69694c4b296f04a6fb7b029190964d28abb2d7964a985e55fcf711cce2 SOURCE_SUM=96e657516adce987469ccb39d566d3798a1d7804728eec46b47664c74732c347
SOURCE_SUM_PRG=sha256sum SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR= SOURCE_IN_SUBDIR=true
SOURCE_FILENAME= SOURCE_FILENAME=
SOURCE_EXTRACT=true

View file

@ -1,6 +1,7 @@
SOURCE_URL=https://framagit.org/hubzilla/addons/-/archive/6.0/addons-6.0.tar.gz SOURCE_URL=https://framagit.org/hubzilla/addons/-/archive/7.4/addons-7.4.tar.gz
SOURCE_SUM=e728d832c2993c5cd2bb66f5151919fb948338336205dbd865af0b94bb06c53e SOURCE_SUM=12e5162d7fc9bdac4ceb6b8862c919bbbc6a2d45b8cc7205c66b2299edd91ee6
SOURCE_SUM_PRG=sha256sum SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR= SOURCE_IN_SUBDIR=true
SOURCE_FILENAME= SOURCE_FILENAME=
SOURCE_EXTRACT=true

View file

@ -14,10 +14,10 @@
$db_host = 'localhost'; // Use 'localhost' or ':/path/to/socket.file' if you aren't using a remote server $db_host = 'localhost'; // Use 'localhost' or ':/path/to/socket.file' if you aren't using a remote server
$db_port = 0; // leave 0 for default or set your port $db_port = 0; // leave 0 for default or set your port
$db_user = '__DB_NAME__'; $db_user = '__DB_USER__';
$db_pass = '__DB_PWD'; $db_pass = '__DB_PWD__';
$db_data = '__DB_NAME__'; $db_data = '__DB_NAME__';
$db_type = 0; // use 1 for postgres, 0 for mysql $db_type = __DB_TYPE__; // use 1 for postgres, 0 for mysql
/* /*
* Notice: Many of the following settings will be available in the admin panel * Notice: Many of the following settings will be available in the admin panel
@ -39,9 +39,9 @@ App::$config['system']['timezone'] = 'America/Los_Angeles';
// What is your site name? DO NOT ADD A TRAILING SLASH! // What is your site name? DO NOT ADD A TRAILING SLASH!
App::$config['system']['baseurl'] = 'https://mysite.example'; App::$config['system']['baseurl'] = 'https://__DOMAIN__';
App::$config['system']['sitename'] = "Hubzilla"; App::$config['system']['sitename'] = "YunoHost Hubzilla";
App::$config['system']['location_hash'] = 'if the auto install failed, put a unique random string here'; App::$config['system']['location_hash'] = '__RANDOM_STRING__';
// These lines set additional security headers to be sent with all responses // These lines set additional security headers to be sent with all responses
@ -66,11 +66,11 @@ App::$config['system']['ssl_cookie_protection'] = 1;
App::$config['system']['register_policy'] = REGISTER_OPEN; App::$config['system']['register_policy'] = REGISTER_OPEN;
App::$config['system']['register_text'] = ''; App::$config['system']['register_text'] = '';
App::$config['system']['admin_email'] = ''; App::$config['system']['admin_email'] = '__EMAIL__';
// Location of PHP command line processor // Location of PHP command line processor
App::$config['system']['php_path'] = 'php'; App::$config['system']['php_path'] = 'php__PHPVERSION__';
// Configure how we communicate with directory servers. // Configure how we communicate with directory servers.
@ -88,7 +88,7 @@ App::$config['system']['directory_mode'] = DIRECTORY_MODE_NORMAL;
// or change the name (below) to a file/path where this is allowed. // or change the name (below) to a file/path where this is allowed.
// Uncomment the following 4 lines to turn on PHP error logging. // Uncomment the following 4 lines to turn on PHP error logging.
//error_reporting(E_ERROR | E_WARNING | E_PARSE ); error_reporting(E_ERROR | E_WARNING | E_PARSE );
//ini_set('error_log','php.out'); ini_set('error_log','php.log');
//ini_set('log_errors','1'); ini_set('log_errors','1');
//ini_set('display_errors', '0'); ini_set('display_errors', '0');

View file

@ -1,69 +1,68 @@
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ { location __PATH__/ {
alias __FINALPATH__/; # Path to source
alias __FINALPATH__/;
# Force https if (!-e $request_filename) {
if ($scheme = http) { rewrite ^(.*)$ /index.php?q=$1;
rewrite ^ https://$server_name$request_uri? permanent; }
}
if (!-e $request_filename) { # Default indexes and catch-all
rewrite ^(.*)$ /index.php?q=$1; index index.php;
} charset utf-8;
client_max_body_size 20m; # Common parameter to increase upload size limit in conjunction with dedicated php-fpm file
client_body_buffer_size 128k; client_max_body_size 20m;
client_body_buffer_size 128k;
# Default indexes and catch-all location ~* \.php$ {
index index.php; try_files $uri =404;
charset utf-8;
location ~* \.php$
{
try_files $uri =404;
fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
fastcgi_index index.php; fastcgi_index index.php;
include fastcgi_params; include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
} }
# make sure webfinger and other well known services aren't blocked # make sure webfinger and other well known services aren't blocked
# by denying dot files and rewrite request to the front controller # by denying dot files and rewrite request to the front controller
location ^~ /.well-known/ { location ^~ /.well-known/ {
allow all; allow all;
if (!-e $request_filename) { if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?q=$1; rewrite ^(.*)$ /index.php?q=$1;
} }
} }
# statically serve these file types when possible # statically serve these file types when possible
# otherwise fall back to front controller # otherwise fall back to front controller
# allow browser to cache them # allow browser to cache them
# added .htm for advanced source code editor library # added .htm for advanced source code editor library
# location ~* \.(jpg|jpeg|gif|png|ico|css|js|htm|html|map|ttf|woff|woff2|svg)$ { # location ~* \.(jpg|jpeg|gif|png|ico|css|js|htm|html|map|ttf|woff|woff2|svg)$ {
# expires 30d; # expires 30d;
# try_files $uri /index.php?q=$uri&$args; # try_files $uri /index.php?q=$uri&$args;
# } # }
# block these file types # block these file types
location ~* \.(tpl|md|tgz|log|out)$ { location ~* \.(tpl|md|tgz|log|out)$ {
deny all; deny all;
} }
# deny access to all dot files # deny access to all dot files
location ~ /\. { location ~ /\. {
deny all; deny all;
} }
#deny access to store #deny access to store
location ~ /store { location ~ /store {
deny all; deny all;
} }
#deny access to util #deny access to util
location ~ /util { location ~ /util {
deny all; deny all;
} }
}
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
}

View file

@ -1,2 +0,0 @@
ALTER TABLE pconfig ADD updated datetime NOT NULL DEFAULT '0001-01-01 00:00:00';
ALTER TABLE pconfig ADD INDEX pconfig_updated (updated);

View file

@ -6,7 +6,7 @@
"en": "Decentralized publication platform and social network.", "en": "Decentralized publication platform and social network.",
"fr": "Plateforme de publication décentralisée et un réseau social." "fr": "Plateforme de publication décentralisée et un réseau social."
}, },
"version": "6.0~ynh1", "version": "7.4~ynh1",
"url": "https://zotlabs.org/page/hubzilla/hubzilla-project", "url": "https://zotlabs.org/page/hubzilla/hubzilla-project",
"upstream": { "upstream": {
"license": "MIT", "license": "MIT",
@ -17,22 +17,21 @@
"maintainer": { "maintainer": {
"name": "Anmol Sharma" "name": "Anmol Sharma"
}, },
"services": [
"nginx",
"php7.3-fpm",
"mysql",
"postgresql"
],
"requirements": {
"yunohost": ">= 4.2.0"
},
"previous_maintainers": { "previous_maintainers": {
"name": "Andrew Manning", "name": "Andrew Manning",
"email": "andrew@reticu.li" "email": "andrew@reticu.li"
}, },
"requirements": {
"yunohost": ">= 4.3.0"
},
"multi_instance": true, "multi_instance": true,
"services": [
"nginx",
"php7.3-fpm",
"mysql"
],
"arguments": { "arguments": {
"install" : [ "install": [
{ {
"name": "domain", "name": "domain",
"type": "domain" "type": "domain"
@ -45,11 +44,11 @@
"name": "database", "name": "database",
"type": "string", "type": "string",
"ask": { "ask": {
"en": "Choose the database to be used for the Hubzilla [mysql:1,postgresql:2]", "en": "Choose the database to be used for the Hubzilla]",
"fr": "Choisissez la database de Hubzilla [mysql:1,postgresql:2]" "fr": "Choisissez la database de Hubzilla"
}, },
"choices": ["1", "2"], "choices": ["mysql", "postgresql"],
"default": "1" "default": "mysql"
} }
] ]
} }

View file

@ -4,13 +4,11 @@
# COMMON VARIABLES # COMMON VARIABLES
#================================================= #=================================================
# dependencies used by the app
YNH_PHP_VERSION="7.3" YNH_PHP_VERSION="7.3"
extra_php_dependencies="php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-cli php${YNH_PHP_VERSION}-imagick php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-pgsql php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-gd"
# dependencies used by the app # dependencies used by the app
pkg_dependencies="postgresql postgresql-contrib" pkg_dependencies="php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-cli php${YNH_PHP_VERSION}-imagick php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-pgsql php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-gd"
pg_pkg_dependencies="postgresql postgresql-contrib"
#================================================= #=================================================
# PERSONAL HELPERS # PERSONAL HELPERS
@ -20,31 +18,6 @@ pkg_dependencies="postgresql postgresql-contrib"
# EXPERIMENTAL HELPERS # EXPERIMENTAL HELPERS
#================================================= #=================================================
ynh_smart_mktemp () {
local min_size="${1:-300}"
# Transform the minimum size from megabytes to kilobytes
min_size=$(( $min_size * 1024 ))
# Check if there's enough free space in a directory
is_there_enough_space () {
local free_space=$(df --output=avail "$1" | sed 1d)
test $free_space -ge $min_size
}
if is_there_enough_space /tmp; then
local tmpdir=/tmp
elif is_there_enough_space /var; then
local tmpdir=/var
elif is_there_enough_space /; then
local tmpdir=/
elif is_there_enough_space /home; then
local tmpdir=/home
else
ynh_die "Insufficient free space to continue..."
fi
echo "$(mktemp --directory --tmpdir="$tmpdir")"
}
#================================================= #=================================================
# FUTURE OFFICIAL HELPERS # FUTURE OFFICIAL HELPERS
#================================================= #=================================================

View file

@ -6,6 +6,7 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -13,10 +14,6 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () {
### Remove this function if there's nothing to clean before calling the remove script.
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
@ -57,18 +54,11 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
#================================================= #=================================================
# BACKUP OF THE DATABASE # BACKUP FAIL2BAN CONFIGURATION
#================================================= #=================================================
if [ $database -eq 1 ]; then ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
# Backup MySQL database ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
ynh_print_info --message="Backup of the MySQL database..."
ynh_mysql_dump_db --database="$db_name" > db.sql
elif [ $database -eq 2 ]; then
# Backup PostgreSQL database
ynh_print_info --message="Backup of the PostgreSQL database..."
ynh_psql_dump_db --database="$db_name" > db.sql
fi
#================================================= #=================================================
# SPECIFIC BACKUP # SPECIFIC BACKUP
@ -79,17 +69,24 @@ fi
ynh_backup --src_path="/etc/logrotate.d/$app" ynh_backup --src_path="/etc/logrotate.d/$app"
#================================================= #=================================================
# BACKUP A CRON FILE # BACKUP VARIOUS FILES
#================================================= #=================================================
ynh_backup --src_path="/etc/cron.d/$app" ynh_backup --src_path="/etc/cron.d/$app"
#================================================= #=================================================
# BACKUP FAIL2BAN CONFIGURATION # BACKUP THE DATABASE
#================================================= #=================================================
ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf" if [ $database = "mysql" ]; then
ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf" # Backup MySQL database
ynh_print_info --message="Backup of the MySQL database..."
ynh_mysql_dump_db --database="$db_name" > db.sql
elif [ $database = "postgresql" ]; then
# Backup PostgreSQL database
ynh_print_info --message="Backup of the PostgreSQL database..."
ynh_psql_dump_db --database="$db_name" > db.sql
fi
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -13,10 +13,6 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () {
### Remove this function if there's nothing to clean before calling the remove script.
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
@ -27,13 +23,14 @@ ynh_abort_if_errors
domain=$YNH_APP_ARG_DOMAIN domain=$YNH_APP_ARG_DOMAIN
path_url="/" path_url="/"
admin=$YNH_APP_ARG_ADMIN admin=$YNH_APP_ARG_ADMIN
email=$(ynh_user_get_info --username=$admin --key=mail) database=$YNH_APP_ARG_DATABASE
upload="256M"
random_string="$(ynh_string_random)$(ynh_string_random)$(ynh_string_random)"
database=`expr $YNH_APP_ARG_DATABASE`
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
email=$(ynh_user_get_info --username=$admin --key=mail)
upload="256M"
random_string="$(ynh_string_random --length=48)"
#================================================= #=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#================================================= #=================================================
@ -50,14 +47,26 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#================================================= #=================================================
ynh_script_progression --message="Storing installation settings..." ynh_script_progression --message="Storing installation settings..."
ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set --app=$app --key=admin --value=$admin ynh_app_setting_set --app=$app --key=admin --value=$admin
ynh_app_setting_set --app=$app --key=email --value=$email
ynh_app_setting_set --app=$app --key=upload --value=$upload
ynh_app_setting_set --app=$app --key=database --value=$database ynh_app_setting_set --app=$app --key=database --value=$database
ynh_app_setting_set --app=$app --key=email --value=$email
ynh_app_setting_set --app=$app --key=upload --value=$upload
ynh_app_setting_set --app=$app --key=random_string --value=$random_string ynh_app_setting_set --app=$app --key=random_string --value=$random_string
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..."
if [ $database = "postgresql" ]; then
pkg_dependencies="$pkg_dependencies $pg_pkg_dependencies"
fi
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
@ -67,142 +76,51 @@ ynh_script_progression --message="Configuring system user..."
ynh_system_user_create --username=$app --home_dir="$final_path" ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# STANDARD MODIFICATIONS # CREATE A DATABASE
#================================================= #=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..."
if [ $database -eq 2 ]; then db_name=$(ynh_sanitize_dbid --db_name=$app)
ynh_install_app_dependencies $pkg_dependencies db_user=$db_name
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
if [ $database = "mysql" ]; then
ynh_script_progression --message="Creating a MySQL database..."
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
db_type=0
elif [ $database = "postgresql" ]; then
ynh_script_progression --message="Creating a PostgreSQL database..."
ynh_psql_test_if_first_run
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
db_type=1
fi fi
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..."
# 1 - Hubzilla
ynh_script_progression --message="Setting up Hubzilla source files..."
git clone --quiet https://framagit.org/hubzilla/core.git "$final_path"
ynh_app_setting_set --app=$app --key=final_path --value=$final_path ynh_app_setting_set --app=$app --key=final_path --value=$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 --dest_dir="$final_path" ynh_setup_source --dest_dir="$final_path"
ynh_setup_source --dest_dir="$final_path/addon" --source_id="app_addons"
# 2 - Hubzilla Addons
# Make addon Directory and unpack the Hubzilla addons to this directory
ynh_script_progression --message="Create addon directory inside Hubzilla root folder..."
# mkdir $final_path/addon
# ynh_script_progression --message="Setting up Hubzilla addons source files..."
# ynh_setup_source --dest_dir="$final_path/addon" --source_id="app_addons"
pushd "$final_path"
mkdir -p extend/addon/hzaddons
mkdir addon
git clone --quiet https://framagit.org/hubzilla/addons.git $final_path/extend/addon/hzaddons
filelist=(`ls extend/addon/hzaddons`)
cd addon
for a in "${filelist[@]}" ; do
base=`basename $a`
if [ $base = '.git' ]; then
#echo 'ignoring git'
continue;
fi
if [ ! -d ../extend/addon/hzaddons/$base ]; then
#echo $a 'not a directory'
continue;
fi
if [ -x $base ]; then
#echo $base 'file exists'
continue;
fi
echo linking $base
ln -s ../extend/addon/hzaddons/$base $base
done
popd
# 3 - Some extra folders
ynh_script_progression --message="Creating smarty3 folder for personal data..."
mkdir -p "${final_path}/store/[data]/smarty3"
chmod -R 775 $final_path/store
# Copy the template install/htconfig.sample.php to .htconfig.php
ynh_script_progression --message="Moving .htconfig.php to root of Hubzilla ..."
config="$final_path/.htconfig.php"
cp $final_path/install/htconfig.sample.php $config
# Create php.log inside Hubzilla for logs
ynh_script_progression --message="Create php.log for the Hubzilla debuging..."
touch "$final_path/php.log" touch "$final_path/php.log"
mkdir -p "$final_path/store"
mkdir -p "$final_path/cache/smarty3"
chmod 750 "$final_path" chmod 750 "$final_path"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path" chown -R $app:www-data "$final_path"
chmod -R 775 $final_path/store $final_path/cache
#================================================= #=================================================
# CREATE A DATABASE # PHP-FPM CONFIGURATION
#=================================================
if [ $database -eq 1 ]; then
ynh_script_progression --message="Creating a MySQL database..."
db_name=$(ynh_sanitize_dbid --db_name=$app)
db_user=$db_name
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
ynh_script_progression --message="Importing database..."
ynh_mysql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" < $final_path/install/schema_mysql.sql
elif [ $database -eq 2 ]; then
# Create postgresql database
ynh_script_progression --message="Creating a postgresql database..."
ynh_replace_string --match_string="db_type = 0;" --replace_string="db_type = 1;" --target_file="$config"
db_name=$(ynh_sanitize_dbid --db_name=$app)
db_user=$app
ynh_psql_test_if_first_run
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_script_progression --message="Importing database..."
ynh_psql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" < $final_path/install/schema_postgres.sql
else
ynh_die --message="Some problem occured in creating the database, contact maintainer"
fi
#=================================================
# MODIFY A CONFIG FILE
#================================================= #=================================================
ynh_script_progression --message="Configuring PHP-FPM..."
# Create a dedicated PHP-FPM config
ynh_add_fpm_config
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
ynh_replace_string --match_string="your.mysqlhost.com" --replace_string="localhost" --target_file="$config"
ynh_replace_string --match_string= "mysqlpassword" --replace_string="$db_pwd" --target_file="$config"
ynh_replace_string --match_string="mysqlusername" --replace_string="$db_name" --target_file="$config"
ynh_replace_string --match_string= "mysqldatabasename" --replace_string="$db_name" --target_file="$config"
ynh_replace_string --match_string= "mysite.example" --replace_string="$domain" --target_file="$config"
ynh_replace_string --match_string= "if the auto install failed, put a unique random string here" --replace_string="$random_string" --target_file="$config"
sed -i "s/\['admin_email'\] = '';/\['admin_email'\] = '$email';/g" "$config"
ynh_replace_string --match_string= "//error_reporting(E_ERROR | E_WARNING | E_PARSE );" --replace_string="error_reporting(E_ERROR | E_WARNING | E_PARSE );" --target_file="$config"
ynh_replace_string --match_string= "//ini_set('error_log','php.out');" --replace_string="ini_set('error_log','php.log');" --target_file="$config"
ynh_replace_string --match_string= "//ini_set('log_errors','1');" --replace_string="ini_set('log_errors','1');" --target_file="$config"
ynh_replace_string --match_string= "//ini_set('display_errors', '0');" --replace_string="ini_set('display_errors', '0');" --target_file="$config"
sed -i "s/\['php_path'\] = 'php';/\['php_path'\] = 'php$phpversion';/g" "$config"
#ynh_add_config --template="../conf/htconfig.sample.php" --destination="$final_path/.htconfig.php"
# addon ldap config
ynh_script_progression --message="Push LDAP configuration to .htconfig.php..."
cat ../conf/ldap_conf.php >> $final_path/.htconfig.php
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
@ -212,18 +130,46 @@ ynh_script_progression --message="Configuring NGINX web server..."
ynh_add_nginx_config ynh_add_nginx_config
#================================================= #=================================================
# PHP-FPM CONFIGURATION # SPECIFIC SETUP
#================================================= #=================================================
ynh_script_progression --message="Configuring PHP-FPM..." # PROVISION DATABASE
#=================================================
ynh_script_progression --message="Provisionning database..."
# Create a dedicated PHP-FPM config if [ $database = "mysql" ]; then
ynh_add_fpm_config --package="$extra_php_dependencies" ynh_mysql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" < $final_path/install/schema_mysql.sql
elif [ $database = "postgresql" ]; then
ynh_psql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" < $final_path/install/schema_postgres.sql
fi
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..."
ynh_add_config --template="../conf/htconfig.sample.php" --destination="$final_path/.htconfig.php"
# addon ldap config
ynh_script_progression --message="Push LDAP configuration to .htconfig.php..."
cat ../conf/ldap_conf.php >> $final_path/.htconfig.php
ynh_store_file_checksum --file=$final_path/.htconfig.php
chmod 600 "$final_path/.htconfig.php"
chown $app:$app "$final_path/.htconfig.php"
#=================================================
# SET CRON JOB
#=================================================
ynh_script_progression --message="Setuping cron job..."
# Set up cron job # Set up cron job
ynh_add_config --template="../conf/poller-cron" --destination="/etc/cron.d/$app" ynh_add_config --template="../conf/poller-cron" --destination="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app" chown root: "/etc/cron.d/$app"
chmod 644 "/etc/cron.d/$app" chmod 644 "/etc/cron.d/$app"
#=================================================
# GENERIC FINALIZATION
#================================================= #=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
#================================================= #=================================================
@ -235,14 +181,14 @@ ynh_use_logrotate "$final_path/php.log"
#================================================= #=================================================
# SETUP FAIL2BAN # SETUP FAIL2BAN
#================================================= #=================================================
ynh_script_progression --message="Add Fail2Ban..." ynh_script_progression --message="Configuring Fail2Ban..."
# Create a dedicated Fail2Ban config
ynh_add_fail2ban_config --logpath="$final_path/php.log" --failregex="^.*auth\.php.*failed login attempt.*from IP <HOST>.*$" --max_retry="5" ynh_add_fail2ban_config --logpath="$final_path/php.log" --failregex="^.*auth\.php.*failed login attempt.*from IP <HOST>.*$" --max_retry="5"
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
# As Hubzilla is social network and have its own permission there is no need to keep Hubzilla behind SSO
ynh_script_progression --message="Configuring permissions..." ynh_script_progression --message="Configuring permissions..."
ynh_permission_update --permission="main" --add="visitors" ynh_permission_update --permission="main" --add="visitors"

View file

@ -18,34 +18,34 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user="$db_name" db_user=$db_name
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
database=$(ynh_app_setting_get --app=$app --key=database) database=$(ynh_app_setting_get --app=$app --key=database)
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..."
# Remove the app-specific logrotate config
ynh_remove_logrotate
#================================================= #=================================================
# REMOVE THE DATABASE # REMOVE THE DATABASE
#================================================= #=================================================
if [ $database -eq 1 ]; then if [ $database = "mysql" ]; then
# Removing MySQL database # Removing MySQL database
ynh_script_progression --message="Removing MySQL database..." ynh_script_progression --message="Removing MySQL database..."
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
elif [ $database -eq 2 ]; then elif [ $database = "postgresql" ]; then
# Removing PostgreSQL database # Removing PostgreSQL database
ynh_script_progression --message="Removing postgresql database..." ynh_script_progression --message="Removing PostgreSQL database..."
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
fi fi
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..."
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================
@ -71,27 +71,31 @@ ynh_script_progression --message="Removing PHP-FPM configuration..."
ynh_remove_fpm_config ynh_remove_fpm_config
#================================================= #=================================================
# REMOVE LOGROTATE CONFIGURATION # REMOVE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Removing logrotate configuration..." ynh_script_progression --message="Removing dependencies..."
# Remove the app-specific logrotate config # Remove metapackage and its dependencies
ynh_remove_logrotate ynh_remove_app_dependencies
#=================================================
# REMOVE THE CRON FILE
#=================================================
# Remove a cron file
ynh_secure_remove --file="/etc/cron.d/$app"
#================================================= #=================================================
# REMOVE FAIL2BAN CONFIGURATION # REMOVE FAIL2BAN CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Removing Fail2Ban configuration..." ynh_script_progression --message="Removing Fail2Ban configuration..."
# Remove the dedicated Fail2Ban config
ynh_remove_fail2ban_config ynh_remove_fail2ban_config
#=================================================
# SPECIFIC REMOVE
#=================================================
# REMOVE VARIOUS FILES
#=================================================
ynh_script_progression --message="Removing various files..."
# Remove a cron file
ynh_secure_remove --file="/etc/cron.d/$app"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================

View file

@ -6,7 +6,7 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -14,17 +14,13 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () {
#### Remove this function if there's nothing to clean before calling the remove script.
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
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading settings..." ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -33,32 +29,24 @@ path_url=$(ynh_app_setting_get --app=$app --key=path)
admin=$(ynh_app_setting_get --app=$app --key=admin) admin=$(ynh_app_setting_get --app=$app --key=admin)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
database=$(ynh_app_setting_get --app=$app --key=database)
db_user=$db_name db_user=$db_name
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
database=$(ynh_app_setting_get --app=$app --key=database)
#================================================= #=================================================
# 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..."
ynh_webpath_available --domain=$domain --path_url=$path_url \
|| ynh_die --message="Path not available: ${domain}${path_url}"
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 "
#================================================= #=================================================
# STANDARD RESTORATION STEPS # STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# RECREATE THE DEDICATED USER # RECREATE THE DEDICATED USER
#================================================= #=================================================
ynh_print_info "Recreating the dedicated system user..." ynh_script_progression --message="Recreating the dedicated system user..."
# Create the dedicated user (if not existing) # Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path" ynh_system_user_create --username=$app --home_dir="$final_path"
@ -75,20 +63,51 @@ chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path" chown -R $app:www-data "$final_path"
#================================================= #=================================================
# RESTORE THE MYSQL DATABASE # RESTORE FAIL2BAN CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the Fail2Ban configuration..."
ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf"
ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf"
ynh_systemd_action --action=restart --service_name=fail2ban
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..."
if [ $database = "postgresql" ]; then
pkg_dependencies="$pkg_dependencies $pg_pkg_dependencies"
fi
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# RESTORE THE PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the PHP-FPM configuration..."
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX web server configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE DATABASE
#================================================= #=================================================
ynh_script_progression --message="Restoring the MySQL database..." ynh_script_progression --message="Restoring the MySQL database..."
if [ $database -eq 1 ]; then if [ $database = "mysql" ]; then
ynh_script_progression --message="Restoring MySQL database..." ynh_script_progression --message="Restoring MySQL database..."
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name --db_pwd=$db_pwd ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name < ./db.sql ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
elif [ $database -eq 2 ]; then elif [ $database = "postgresql" ]; then
# Removing postgresql database
ynh_script_progression --message="Reinstalling dependencies..."
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
ynh_script_progression --message="Restoring the PostgreSQL database..." ynh_script_progression --message="Restoring the PostgreSQL database..."
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
ynh_psql_test_if_first_run ynh_psql_test_if_first_run
@ -97,38 +116,19 @@ elif [ $database -eq 2 ]; then
fi fi
#================================================= #=================================================
# RESTORE THE PHP-FPM CONFIGURATION # RESTORE VARIOUS FILES
#=================================================
ynh_script_progression --message="Restoring PHP-FPM configuration..."
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
# Recreate a dedicated php-fpm config
ynh_add_fpm_config --package="$extra_php_dependencies"
#=================================================
# SPECIFIC RESTORATION
#=================================================
# RESTORE THE CRON FILE
#================================================= #=================================================
ynh_script_progression --message="Restoring various files..."
ynh_restore_file --origin_path="/etc/cron.d/$app" ynh_restore_file --origin_path="/etc/cron.d/$app"
#================================================= #=================================================
# RESTORE THE LOGROTATE CONFIGURATION # RESTORE THE LOGROTATE CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Restoring the logrotate configuration..."
ynh_restore_file --origin_path="/etc/logrotate.d/$app" ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#=================================================
# RESTORE FAIL2BAN CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the Fail2Ban configuration..."
ynh_restore_file "/etc/fail2ban/jail.d/$app.conf"
ynh_restore_file "/etc/fail2ban/filter.d/$app.conf"
ynh_systemd_action --action=restart --service_name=fail2ban
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================

View file

@ -18,35 +18,23 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path) path_url=$(ynh_app_setting_get --app=$app --key=path)
admin=$(ynh_app_setting_get --app=$app --key=admin)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
upload=$(ynh_app_setting_get --app=$app --key=upload) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
version=$(grep STD_VERSION $final_path/boot.php | cut -c 38- | rev | cut -c 5- | rev) db_user=$db_name
last_update=$(grep update_time: /etc/yunohost/apps/$app/settings.yml | cut -c 14-)
database=$(ynh_app_setting_get --app=$app --key=database)
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
database=$(ynh_app_setting_get --app=$app --key=database)
upload=$(ynh_app_setting_get --app=$app --key=upload)
random_string=$(ynh_app_setting_get --app=$app --key=random_string)
email=$(ynh_user_get_info --username=$admin --key=mail)
#================================================= #=================================================
# ENSURE DOWNWARD COMPATIBILITY # CHECK VERSION
#================================================= #=================================================
ynh_script_progression --message="Checking version..."
# If db_name doesn't exist, create it upgrade_type=$(ynh_check_app_version_changed)
if [ -z "$db_name" ]; then
db_name=$(ynh_sanitize_dbid --db_name=$app)
ynh_app_setting_set --app=$app --key=db_name --value=$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=$app --key=final_path --value=$final_path
fi
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
@ -56,12 +44,47 @@ ynh_script_progression --message="Backing up the app before upgrading (may take
# 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 () {
# restore it if the upgrade fails # Restore it if the upgrade fails
ynh_restore_upgradebackup ynh_restore_upgradebackup
} }
# 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
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..."
# If final_path doesn't exist, create it
if [ -z "$final_path" ]; then
final_path=/var/www/$app
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
fi
# If db_name doesn't exist, create it
if [ -z "$db_name" ]; then
db_name=$(ynh_sanitize_dbid --db_name=$app)
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
fi
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
# Switch $database to "mysql" or "postgresql"
if [[ $database == "1" ]] 2>/dev/null; then
database="mysql"
ynh_app_setting_set --app=$app --key=database --value=$database
elif [[ $database == "2" ]] 2>/dev/null; then
database="postgresql"
ynh_app_setting_set --app=$app --key=database --value=$database
fi
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
@ -70,75 +93,43 @@ ynh_script_progression --message="Making sure dedicated system user exists..."
# Create a dedicated user (if not existing) # Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path" ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# STANDARD UPGRADE STEPS
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Upgrading source files..."
if [ `cd $final_path && git rev-parse --is-inside-work-tree` ]; then if [ "$upgrade_type" == "UPGRADE_APP" ]
pushd "$final_path" then
git pull ynh_script_progression --message="Upgrading source files..."
cd extend/addon/hzaddons
git pull
cd ../../..
filelist=(`ls extend/addon/hzaddons`)
cd addon
for a in "${filelist[@]}" ; do
base=`basename $a`
if [ $base = '.git' ]; then
#echo 'ignoring git'
continue;
fi
if [ ! -d ../extend/addon/hzaddons/$base ]; then
#echo $a 'not a directory'
continue;
fi
if [ -x $base ]; then
#echo $base 'file exists'
continue;
fi
echo linking $base
ln -s ../extend/addon/hzaddons/$base $base
done
for x in `ls` ; do
if [ -L "$x" ] && ! [ -e "$x" ]; then
echo "removing dead symlink $x" ;
rm -- "$x";
fi;
done
popd
chmod -R 775 $final_path/store
else
# Create a temporary directory
tmpdir="$(ynh_smart_mktemp 6000)"
# Backup the config file in the temp dir
cp -a "$final_path/.htconfig.php" "$tmpdir/.htconfig.php"
cp -a "$final_path/store" "$tmpdir/store"
cp -a "$final_path/php.log" "$tmpdir/php.log"
# Remove the app directory securely
ynh_secure_remove "$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 --dest_dir="$final_path" ynh_setup_source --dest_dir="$final_path" --keep="store/ .htconfig.php php.log"
cp -a "$tmpdir/store" "${final_path}"
cp -a "$tmpdir/.htconfig.php" "${final_path}"
cp -a "$tmpdir/php.log" "${final_path}"
ynh_secure_remove "$tmpdir"
chmod -R 775 $final_path/store
mkdir $final_path/addon
ynh_setup_source --dest_dir="$final_path/addon" --source_id="app_addons" ynh_setup_source --dest_dir="$final_path/addon" --source_id="app_addons"
fi fi
mkdir -p "$final_path/store"
mkdir -p "$final_path/cache/smarty3"
chmod 750 "$final_path" chmod 750 "$final_path"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path" chown -R $app:www-data "$final_path"
chmod -R 775 $final_path/store $final_path/cache
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..."
if [ $database = "postgresql" ]; then
pkg_dependencies="$pkg_dependencies $pg_pkg_dependencies"
fi
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading PHP-FPM configuration..."
# Create a dedicated PHP-FPM config
ynh_add_fpm_config
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
@ -149,19 +140,43 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..."
ynh_add_nginx_config ynh_add_nginx_config
#================================================= #=================================================
# PHP-FPM CONFIGURATION # SPECIFIC UPGRADE
#================================================= #=================================================
ynh_print_info "Upgrading PHP-FPM configuration..." # UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..." --weight=1
# Create a dedicated php-fpm config if [ $database = "mysql" ]; then
ynh_add_fpm_config --package="$extra_php_dependencies" db_type=0
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
elif [ $database = "postgresql" ]; then
db_type=1
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
fi
### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. ynh_add_config --template="../conf/htconfig.sample.php" --destination="$final_path/.htconfig.php"
### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it.
ynh_backup_if_checksum_is_different --file="$final_path/.htconfig.php.back"
# Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum --file="$final_path/.htconfig.php"
# addon ldap config
ynh_script_progression --message="Push LDAP configuration to .htconfig.php..."
cat ../conf/ldap_conf.php >> $final_path/.htconfig.php
ynh_store_file_checksum --file=$final_path/.htconfig.php
chmod 600 "$final_path/.htconfig.php"
chown $app:$app "$final_path/.htconfig.php"
#=================================================
# UPGRADE CRON JOB
#=================================================
ynh_script_progression --message="Upgrading cron job..."
# Set up cron job
ynh_add_config --template="../conf/poller-cron" --destination="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
chmod 644 "/etc/cron.d/$app"
#=================================================
# GENERIC FINALIZATION
#================================================= #=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
#================================================= #=================================================
@ -170,43 +185,14 @@ ynh_script_progression --message="Upgrading logrotate configuration..."
# Use logrotate to manage app-specific logfile(s) # Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append ynh_use_logrotate --non-append
#=================================================
# UPGRADE FAIL2BAN # UPGRADE FAIL2BAN
#================================================= #=================================================
ynh_script_progression --message="Re-configure Fail2Ban..." ynh_script_progression --message="Reconfiguring Fail2Ban..."
# Create a dedicated Fail2Ban config
ynh_add_fail2ban_config --logpath="$final_path/php.log" --failregex="^.*auth\.php.*failed login attempt.*from IP <HOST>.*$" --max_retry="5" ynh_add_fail2ban_config --logpath="$final_path/php.log" --failregex="^.*auth\.php.*failed login attempt.*from IP <HOST>.*$" --max_retry="5"
# Set up cron job
ynh_add_config --template="../conf/poller-cron" --destination="/etc/cron.d/$app"
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..."
if [ $database -eq 1 ]; then
#=================================================
# CHECK VERSION FOR SPECIFIC MYSQL UPDATE
#=================================================
# Check version and if this version was a fresh install push mysql query
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
is_version_equal_three_eight_four=$(awk 'BEGIN{ print "'$version'"<"'3.8.4'" }')
if [ -z "$last_update" ] && [ "$is_version_equal_three_eight_four" -eq 1 ]; then
ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" < "../conf/sql/385.sql"
fi
elif [ $database -eq 2 ]; then
ynh_install_app_dependencies $pkg_dependencies
fi
is_version_less_then_five=$(awk 'BEGIN{ print "'$version'"<"'5.0.0'" }')
if [ "$is_version_less_then_five" -eq 1 ] && [ -f "$final_path/util/z6convert.php" ] ; then
pushd "$final_path"
php${YNH_PHP_VERSION} util/z6convert.php
popd
fi
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================