mirror of
https://github.com/YunoHost-Apps/piwigo_ynh.git
synced 2024-09-03 20:06:03 +02:00
Cleanup, apply template
This commit is contained in:
parent
adb792d8f7
commit
d04719a32f
7 changed files with 87 additions and 94 deletions
|
@ -1,2 +1,17 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# COMMON VARIABLES
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# PERSONAL HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# EXPERIMENTAL HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# FUTURE OFFICIAL HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC START
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -28,21 +26,13 @@ ynh_backup --src_path="$install_dir"
|
||||||
ynh_backup --src_path="$data_dir" --is_big
|
ynh_backup --src_path="$data_dir" --is_big
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE NGINX CONFIGURATION
|
# BACKUP THE SYSTEM CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# BACKUP THE PHP-FPM CONFIGURATION
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
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 FAIL2BAN CONFIGURATION
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
|
ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
|
||||||
ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
|
ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC STARTING
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -9,8 +7,6 @@
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# STANDARD MODIFICATIONS
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY URL IN NGINX CONF
|
# MODIFY URL IN NGINX CONF
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -3,6 +3,12 @@
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# INITIALIZE AND STORE SETTINGS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
mail="$(ynh_user_get_info --username=$admin --key=mail)"
|
||||||
|
|
||||||
# Gotta save the stupid password because we need it during upgrade because there's no way to trigger the upgrade.php script from command line ...
|
# Gotta save the stupid password because we need it during upgrade because there's no way to trigger the upgrade.php script from command line ...
|
||||||
ynh_app_setting_set --app=$app --key=password --value="$password"
|
ynh_app_setting_set --app=$app --key=password --value="$password"
|
||||||
|
|
||||||
|
@ -15,22 +21,20 @@ ynh_setup_source --dest_dir="$install_dir"
|
||||||
ynh_setup_source --dest_dir="$install_dir/plugins/Ldap_Login" --source_id=ldap_plugin
|
ynh_setup_source --dest_dir="$install_dir/plugins/Ldap_Login" --source_id=ldap_plugin
|
||||||
ynh_setup_source --dest_dir="$install_dir/plugins" --source_id=log_failed_logins_plugin
|
ynh_setup_source --dest_dir="$install_dir/plugins" --source_id=log_failed_logins_plugin
|
||||||
|
|
||||||
chmod 750 "$install_dir"
|
|
||||||
chmod -R o-rwx "$install_dir"
|
chmod -R o-rwx "$install_dir"
|
||||||
chown -R $app:www-data "$install_dir"
|
chown -R "$app:www-data" "$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CONFIGURE DATA DIRECTORY
|
# CONFIGURE DATA DIRECTORY
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Initializing data directory..." --weight=1
|
ynh_script_progression --message="Initializing data directory..." --weight=1
|
||||||
|
|
||||||
mv $install_dir/_data $data_dir/_data
|
mv "$install_dir/_data" "$data_dir/_data"
|
||||||
mv $install_dir/upload $data_dir/upload
|
mv "$install_dir/upload" "$data_dir/upload"
|
||||||
mv $install_dir/galleries $data_dir/galleries
|
mv "$install_dir/galleries" "$data_dir/galleries"
|
||||||
|
|
||||||
chmod 750 "$data_dir"
|
|
||||||
chmod -R o-rwx "$data_dir"
|
chmod -R o-rwx "$data_dir"
|
||||||
chown -R $app:www-data "$data_dir"
|
chown -R "$app:www-data" "$data_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SYSTEM CONFIGURATIONS
|
# SYSTEM CONFIGURATIONS
|
||||||
|
@ -47,8 +51,9 @@ ynh_add_nginx_config
|
||||||
ynh_script_progression --message="Setuping application with CURL..." --weight=5
|
ynh_script_progression --message="Setuping application with CURL..." --weight=5
|
||||||
|
|
||||||
# Installation with cURL
|
# Installation with cURL
|
||||||
mail="$(ynh_user_get_info --username=$admin --key=mail)"
|
ynh_local_curl "/install.php?language=$language" \
|
||||||
ynh_local_curl "/install.php?language=$language" "install=true" "dbhost=127.0.0.1" "dbuser=$db_user" "dbpasswd=$db_pwd" "dbname=$db_name" "prefix=" "admin_name=$admin" "admin_pass1=$password" "admin_pass2=$password" "admin_mail=$mail"
|
"install=true" "dbhost=127.0.0.1" "dbuser=$db_user" "dbpasswd=$db_pwd" "dbname=$db_name" \
|
||||||
|
"prefix=" "admin_name=$admin" "admin_pass1=$password" "admin_pass2=$password" "admin_mail=$mail"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CONFIGURE PIWIGO
|
# CONFIGURE PIWIGO
|
||||||
|
@ -61,9 +66,8 @@ ynh_add_config --template="config.inc.php" --destination="$install_dir/local/con
|
||||||
# Setup database in local/config/database.inc.php
|
# Setup database in local/config/database.inc.php
|
||||||
ynh_add_config --template="database.inc.php" --destination="$install_dir/local/config/database.inc.php"
|
ynh_add_config --template="database.inc.php" --destination="$install_dir/local/config/database.inc.php"
|
||||||
|
|
||||||
chmod 750 "$install_dir"
|
|
||||||
chmod -R o-rwx "$install_dir"
|
chmod -R o-rwx "$install_dir"
|
||||||
chown -R $app:www-data "$install_dir"
|
chown -R "$app:www-data" "$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ADD LDAP PLUGIN
|
# ADD LDAP PLUGIN
|
||||||
|
@ -76,7 +80,7 @@ ynh_script_progression --message="Configuring LDAP plugin..." --weight=2
|
||||||
ynh_local_curl "/ws.php?format=json" "method=pwg.session.login" "username=$admin" "password=$password"
|
ynh_local_curl "/ws.php?format=json" "method=pwg.session.login" "username=$admin" "password=$password"
|
||||||
# Get session token
|
# Get session token
|
||||||
status=$(ynh_local_curl "/ws.php?format=json" "method=pwg.session.getStatus")
|
status=$(ynh_local_curl "/ws.php?format=json" "method=pwg.session.getStatus")
|
||||||
pwg_token=$(jq --raw-output .result.pwg_token <<< $status)
|
pwg_token=$(jq --raw-output .result.pwg_token <<< "$status")
|
||||||
# Install the Ldap_Login plugin
|
# Install the Ldap_Login plugin
|
||||||
ynh_local_curl "/ws.php?format=json" "method=pwg.plugins.performAction" "action=install" "plugin=Ldap_Login" "pwg_token=$pwg_token"
|
ynh_local_curl "/ws.php?format=json" "method=pwg.plugins.performAction" "action=install" "plugin=Ldap_Login" "pwg_token=$pwg_token"
|
||||||
# Activate the Ldap_Login plugin
|
# Activate the Ldap_Login plugin
|
||||||
|
@ -85,7 +89,7 @@ ynh_local_curl "/ws.php?format=json" "method=pwg.plugins.performAction" "action=
|
||||||
ynh_local_curl "/ws.php?format=json" "method=pwg.session.logout"
|
ynh_local_curl "/ws.php?format=json" "method=pwg.session.logout"
|
||||||
|
|
||||||
# Edit Ldap_Login plugin configuration
|
# Edit Ldap_Login plugin configuration
|
||||||
ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name <<< "UPDATE piwigo_ldap_login_config SET value='ou=users,dc=yunohost,dc=org' WHERE param = 'ld_basedn';
|
ynh_mysql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" <<< "UPDATE piwigo_ldap_login_config SET value='ou=users,dc=yunohost,dc=org' WHERE param = 'ld_basedn';
|
||||||
UPDATE piwigo_ldap_login_config SET value='uid' WHERE param = 'ld_user_attr';
|
UPDATE piwigo_ldap_login_config SET value='uid' WHERE param = 'ld_user_attr';
|
||||||
UPDATE piwigo_ldap_login_config SET value='' WHERE param = 'ld_binddn';
|
UPDATE piwigo_ldap_login_config SET value='' WHERE param = 'ld_binddn';
|
||||||
UPDATE piwigo_ldap_login_config SET value='0' WHERE param = 'allow_new_users';
|
UPDATE piwigo_ldap_login_config SET value='0' WHERE param = 'allow_new_users';
|
||||||
|
@ -99,11 +103,11 @@ UPDATE piwigo_ldap_login_config SET value='0' WHERE param = 'ld_group_user_activ
|
||||||
ynh_script_progression --message="Configuring Fail2Ban..." --weight=6
|
ynh_script_progression --message="Configuring Fail2Ban..." --weight=6
|
||||||
|
|
||||||
# Configure and activate log_failed_logins plugin
|
# Configure and activate log_failed_logins plugin
|
||||||
ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name <<< "INSERT INTO plugins (id,state,version) VALUES ('log_failed_logins','active','1.2');"
|
ynh_mysql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" <<< "INSERT INTO plugins (id,state,version) VALUES ('log_failed_logins','active','1.2');"
|
||||||
ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name <<< "INSERT INTO config (param, value) VALUES ('logFailedLoginsFilename','/var/log/${app}FailedLogins.log');"
|
ynh_mysql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" <<< "INSERT INTO config (param, value) VALUES ('logFailedLoginsFilename','/var/log/${app}FailedLogins.log');"
|
||||||
|
|
||||||
touch "/var/log/${app}FailedLogins.log"
|
touch "/var/log/${app}FailedLogins.log"
|
||||||
chown $app: "/var/log/${app}FailedLogins.log"
|
chown "$app:" "/var/log/${app}FailedLogins.log"
|
||||||
|
|
||||||
ynh_add_fail2ban_config --logpath="/var/log/${app}FailedLogins.log" --failregex="ip=<HOST>" --max_retry=6
|
ynh_add_fail2ban_config --logpath="/var/log/${app}FailedLogins.log" --failregex="ip=<HOST>" --max_retry=6
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC START
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC START
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -18,7 +16,7 @@ ynh_script_progression --message="Restoring the app main directory..." --weight=
|
||||||
ynh_restore_file --origin_path="$install_dir"
|
ynh_restore_file --origin_path="$install_dir"
|
||||||
|
|
||||||
chmod -R o-rwx "$install_dir"
|
chmod -R o-rwx "$install_dir"
|
||||||
chown -R $app:www-data "$install_dir"
|
chown -R "$app:www-data" "$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE DATA DIRECTORY
|
# RESTORE THE DATA DIRECTORY
|
||||||
|
@ -27,14 +25,14 @@ ynh_script_progression --message="Restoring the data directory..." --weight=2
|
||||||
|
|
||||||
ynh_restore_file --origin_path="$data_dir" --not_mandatory
|
ynh_restore_file --origin_path="$data_dir" --not_mandatory
|
||||||
|
|
||||||
chown -R $app:www-data "$data_dir"
|
chown -R "$app:www-data" "$data_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE MYSQL DATABASE
|
# RESTORE THE MYSQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the MySQL database..." --weight=2
|
ynh_script_progression --message="Restoring the MySQL database..." --weight=2
|
||||||
|
|
||||||
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
|
ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE PHP-FPM CONFIGURATION
|
# RESTORE THE PHP-FPM CONFIGURATION
|
||||||
|
@ -46,20 +44,18 @@ ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
||||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
touch "/var/log/${app}FailedLogins.log"
|
touch "/var/log/${app}FailedLogins.log"
|
||||||
chown $app: "/var/log/${app}FailedLogins.log"
|
chown "$app:" "/var/log/${app}FailedLogins.log"
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf"
|
ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf"
|
||||||
ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf"
|
ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf"
|
||||||
ynh_systemd_action --action=restart --service_name=fail2ban
|
ynh_systemd_action --action=restart --service_name=fail2ban
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC FINALIZATION
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX AND PHP-FPM
|
# RELOAD NGINX AND PHP-FPM
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=2
|
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=2
|
||||||
|
|
||||||
ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
|
ynh_systemd_action --service_name="php$phpversion-fpm" --action=reload
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -3,6 +3,11 @@
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# ENSURE DOWNWARD COMPATIBILITY
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
||||||
|
|
||||||
# Boring backward compatibility
|
# Boring backward compatibility
|
||||||
if [ "${language:-}" == "fr" ] ; then
|
if [ "${language:-}" == "fr" ] ; then
|
||||||
language="fr_FR"
|
language="fr_FR"
|
||||||
|
@ -10,58 +15,47 @@ else
|
||||||
language="en_UK"
|
language="en_UK"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "${password:-}" ];
|
if [ -z "${password:-}" ]; then
|
||||||
then
|
password="$admin_pwd"
|
||||||
password="${admin_pwd}"
|
|
||||||
ynh_app_setting_set --app=$app --key=password --value="$password"
|
ynh_app_setting_set --app=$app --key=password --value="$password"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
# Get rid of legacy symlinks
|
||||||
# CHECK VERSION
|
if [ -L "$install_dir/_data" ]; then
|
||||||
#=================================================
|
ynh_secure_remove "$install_dir/_data"
|
||||||
|
fi
|
||||||
upgrade_type=$(ynh_check_app_version_changed)
|
if [ -L "$install_dir/galleries" ]; then
|
||||||
|
ynh_secure_remove "$install_dir/galleries"
|
||||||
|
fi
|
||||||
|
if [ -L "$install_dir/upload" ]; then
|
||||||
|
ynh_secure_remove "$install_dir/upload"
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Upgrading source files..." --weight=3
|
||||||
|
|
||||||
# Get rid of legacy symlinks
|
ynh_setup_source --dest_dir="$install_dir"
|
||||||
[ -L "$install_dir/_data" ] && ynh_secure_remove "$install_dir/_data" || true
|
ynh_setup_source --dest_dir="$install_dir/plugins/Ldap_Login" --source_id=ldap_plugin
|
||||||
[ -L "$install_dir/galleries" ] && ynh_secure_remove "$install_dir/galleries" || true
|
ynh_setup_source --dest_dir="$install_dir/plugins" --source_id=log_failed_logins_plugin
|
||||||
[ -L "$install_dir/upload" ] && ynh_secure_remove "$install_dir/upload" || true
|
|
||||||
|
|
||||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
# We don't want to keep those in the install dir, they already are in $data_dir
|
||||||
then
|
if [ -d "$install_dir/_data" ] && [ ! -L "$install_dir/_data" ]; then
|
||||||
ynh_script_progression --message="Upgrading source files..." --weight=3
|
|
||||||
|
|
||||||
ynh_setup_source --dest_dir="$install_dir"
|
|
||||||
ynh_setup_source --dest_dir="$install_dir/plugins/Ldap_Login" --source_id=ldap_plugin
|
|
||||||
ynh_setup_source --dest_dir="$install_dir/plugins" --source_id=log_failed_logins_plugin
|
|
||||||
|
|
||||||
# We don't want to keep those in the install dir, they already are in $data_dir
|
|
||||||
if [ -d "$install_dir/_data" ] && [ ! -L "$install_dir/_data" ]
|
|
||||||
then
|
|
||||||
ynh_secure_remove "$install_dir/_data"
|
ynh_secure_remove "$install_dir/_data"
|
||||||
fi
|
fi
|
||||||
if [ -d "$install_dir/galleries" ] && [ ! -L "$install_dir/galleries" ]
|
if [ -d "$install_dir/galleries" ] && [ ! -L "$install_dir/galleries" ]; then
|
||||||
then
|
|
||||||
ynh_secure_remove "$install_dir/galleries"
|
ynh_secure_remove "$install_dir/galleries"
|
||||||
fi
|
fi
|
||||||
if [ -d "$install_dir/upload" ] && [ ! -L "$install_dir/upload" ]
|
if [ -d "$install_dir/upload" ] && [ ! -L "$install_dir/upload" ]; then
|
||||||
then
|
|
||||||
ynh_secure_remove "$install_dir/upload"
|
ynh_secure_remove "$install_dir/upload"
|
||||||
fi
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
chmod 750 "$data_dir"
|
|
||||||
chmod -R o-rwx "$data_dir"
|
chmod -R o-rwx "$data_dir"
|
||||||
chown -R $app:www-data "$data_dir"
|
chown -R "$app:www-data" "$data_dir"
|
||||||
|
|
||||||
chmod 750 "$install_dir"
|
|
||||||
chmod -R o-rwx "$install_dir"
|
chmod -R o-rwx "$install_dir"
|
||||||
chown -R $app:www-data "$install_dir"
|
chown -R "$app:www-data" "$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PHP-FPM CONFIGURATION
|
# PHP-FPM CONFIGURATION
|
||||||
|
@ -72,8 +66,6 @@ ynh_add_fpm_config
|
||||||
|
|
||||||
ynh_add_nginx_config
|
ynh_add_nginx_config
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SPECIFIC UPGRADE
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPGRADE APPLICATION WITH CURL
|
# UPGRADE APPLICATION WITH CURL
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -94,9 +86,8 @@ ynh_add_config --template="config.inc.php" --destination="$install_dir/local/con
|
||||||
# Setup database in local/config/database.inc.php
|
# Setup database in local/config/database.inc.php
|
||||||
ynh_add_config --template="database.inc.php" --destination="$install_dir/local/config/database.inc.php"
|
ynh_add_config --template="database.inc.php" --destination="$install_dir/local/config/database.inc.php"
|
||||||
|
|
||||||
chmod 750 "$install_dir"
|
|
||||||
chmod -R o-rwx "$install_dir"
|
chmod -R o-rwx "$install_dir"
|
||||||
chown -R $app:www-data "$install_dir"
|
chown -R "$app:www-data" "$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CONFIGURE LDAP PLUGIN
|
# CONFIGURE LDAP PLUGIN
|
||||||
|
@ -104,7 +95,7 @@ chown -R $app:www-data "$install_dir"
|
||||||
ynh_script_progression --message="Configuring LDAP plugin..." --weight=2
|
ynh_script_progression --message="Configuring LDAP plugin..." --weight=2
|
||||||
|
|
||||||
# Disable LDAP plugin to avoid warning messages during API call
|
# Disable LDAP plugin to avoid warning messages during API call
|
||||||
ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name <<< "DELETE FROM plugins WHERE id='Ldap_Login';"
|
ynh_mysql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" <<< "DELETE FROM plugins WHERE id='Ldap_Login';"
|
||||||
|
|
||||||
# Activate the LDAP plugin using the WS API
|
# Activate the LDAP plugin using the WS API
|
||||||
|
|
||||||
|
@ -114,36 +105,39 @@ ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name <<<
|
||||||
ynh_local_curl "/ws.php?format=json" "method=pwg.session.login" "username=$admin" "password=$password"
|
ynh_local_curl "/ws.php?format=json" "method=pwg.session.login" "username=$admin" "password=$password"
|
||||||
# Get session token
|
# Get session token
|
||||||
status=$(ynh_local_curl "/ws.php?format=json" "method=pwg.session.getStatus")
|
status=$(ynh_local_curl "/ws.php?format=json" "method=pwg.session.getStatus")
|
||||||
pwg_token=$(jq --raw-output .result.pwg_token <<< $status)
|
pwg_token=$(jq --raw-output .result.pwg_token <<< "$status")
|
||||||
# Activate the Ldap_Login plugin
|
# Activate the Ldap_Login plugin
|
||||||
ynh_local_curl "/ws.php?format=json" "method=pwg.plugins.performAction" "action=activate" "plugin=Ldap_Login" "pwg_token=$pwg_token"
|
ynh_local_curl "/ws.php?format=json" "method=pwg.plugins.performAction" "action=activate" "plugin=Ldap_Login" "pwg_token=$pwg_token"
|
||||||
# Log out
|
# Log out
|
||||||
ynh_local_curl "/ws.php?format=json" "method=pwg.session.logout"
|
ynh_local_curl "/ws.php?format=json" "method=pwg.session.logout"
|
||||||
|
|
||||||
# Edit Ldap_Login plugin configuration
|
# Edit Ldap_Login plugin configuration
|
||||||
ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name <<< "UPDATE piwigo_ldap_login_config SET value='ou=users,dc=yunohost,dc=org' WHERE param = 'ld_basedn';
|
ynh_mysql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" <<< "UPDATE piwigo_ldap_login_config SET value='ou=users,dc=yunohost,dc=org' WHERE param = 'ld_basedn';
|
||||||
UPDATE piwigo_ldap_login_config SET value='uid' WHERE param = 'ld_user_attr';
|
UPDATE piwigo_ldap_login_config SET value='uid' WHERE param = 'ld_user_attr';
|
||||||
UPDATE piwigo_ldap_login_config SET value='' WHERE param = 'ld_binddn';
|
UPDATE piwigo_ldap_login_config SET value='' WHERE param = 'ld_binddn';
|
||||||
UPDATE piwigo_ldap_login_config SET value='0' WHERE param = 'allow_new_users';
|
UPDATE piwigo_ldap_login_config SET value='0' WHERE param = 'allow_new_users';
|
||||||
UPDATE piwigo_ldap_login_config SET value='0' WHERE param = 'ld_group_user_active';"
|
UPDATE piwigo_ldap_login_config SET value='0' WHERE param = 'ld_group_user_active';"
|
||||||
|
|
||||||
# Remove configuration file for older plugin version
|
# Remove configuration file for older plugin version
|
||||||
if [ -f $install_dir/plugins/Ldap_Login/data.dat ] ; then
|
if [ -f "$install_dir/plugins/Ldap_Login/data.dat" ] ; then
|
||||||
ynh_secure_remove --file=$install_dir/plugins/Ldap_Login/data.dat
|
ynh_secure_remove --file="$install_dir/plugins/Ldap_Login/data.dat"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC FINALIZATION
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPGRADE FAIL2BAN
|
# UPGRADE FAIL2BAN
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reconfiguring Fail2Ban..." --weight=8
|
ynh_script_progression --message="Reconfiguring Fail2Ban..." --weight=8
|
||||||
|
|
||||||
# Configure and activate log_failed_logins plugin
|
# Configure and activate log_failed_logins plugin
|
||||||
ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name <<< "INSERT INTO plugins (id,state,version) VALUES ('log_failed_logins','active','1.2');" 2>&1 > /dev/null || ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name <<< "UPDATE plugins SET state='active' WHERE id='log_failed_logins';"
|
if ! ynh_mysql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" <<< "INSERT INTO plugins (id,state,version) VALUES ('log_failed_logins','active','1.2');" 2>&1 > /dev/null; then
|
||||||
ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name <<< "INSERT INTO config (param, value) VALUES ('logFailedLoginsFilename','/var/log/${app}FailedLogins.log');" 2>&1 > /dev/null || ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name <<< "UPDATE config SET value='/var/log/${app}FailedLogins.log' WHERE param='logFailedLoginsFilename';"
|
ynh_mysql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" <<< "UPDATE plugins SET state='active' WHERE id='log_failed_logins';"
|
||||||
|
fi
|
||||||
|
if ! ynh_mysql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" <<< "INSERT INTO config (param, value) VALUES ('logFailedLoginsFilename','/var/log/${app}FailedLogins.log');" 2>&1 > /dev/null; then
|
||||||
|
ynh_mysql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" <<< "UPDATE config SET value='/var/log/${app}FailedLogins.log' WHERE param='logFailedLoginsFilename';"
|
||||||
|
fi
|
||||||
|
|
||||||
touch "/var/log/${app}FailedLogins.log"
|
touch "/var/log/${app}FailedLogins.log"
|
||||||
chown $app: "/var/log/${app}FailedLogins.log"
|
chown "$app:" "/var/log/${app}FailedLogins.log"
|
||||||
|
|
||||||
ynh_add_fail2ban_config --logpath="/var/log/${app}FailedLogins.log" --failregex="ip=<HOST>" --max_retry=6
|
ynh_add_fail2ban_config --logpath="/var/log/${app}FailedLogins.log" --failregex="ip=<HOST>" --max_retry=6
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue