mirror of
https://github.com/YunoHost-Apps/teampass_ynh.git
synced 2024-09-03 20:26:37 +02:00
Upgrade fixes
This commit is contained in:
parent
115c8317dd
commit
e78632f072
6 changed files with 76 additions and 27 deletions
|
@ -41,9 +41,9 @@ Supported, with LDAP.
|
||||||
|
|
||||||
#### Supported architectures
|
#### Supported architectures
|
||||||
|
|
||||||
* x86-64b - [/badge/icon)](https://ci-apps.yunohost.org/jenkins/job/teampass%20(Community)/)
|
* x86-64b - 
|
||||||
* ARMv8-A - [%20(%7EARM%7E)/badge/icon)](https://ci-apps-arm.yunohost.org/jenkins/job/teampass%20(Community)%20(%7EARM%7E)/)
|
* ARMv8-A - 
|
||||||
* Jessie x86-64b - [/badge/icon)](https://ci-stretch.nohost.me/jenkins/job/teampass%20(Community)/)
|
* Jessie x86-64b - 
|
||||||
|
|
||||||
## Limitations
|
## Limitations
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ $port = 3306;
|
||||||
$encoding = "utf8";
|
$encoding = "utf8";
|
||||||
|
|
||||||
@date_default_timezone_set($_SESSION['settings']['timezone']);
|
@date_default_timezone_set($_SESSION['settings']['timezone']);
|
||||||
@define('SECUREPATH', '__FINALPATH__/includes');
|
@define('SECUREPATH', '__SKPATH__');
|
||||||
|
if (file_exists("__SKPATH__sk.php")) {
|
||||||
require_once "__SKPATH__sk.php";
|
require_once "__SKPATH__sk.php";
|
||||||
?>
|
}
|
||||||
|
|
|
@ -30,6 +30,24 @@ IS_PACKAGE_CHECK () {
|
||||||
return $(env | grep -c container=lxc)
|
return $(env | grep -c container=lxc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BOOLEAN CONVERTER
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
bool_to_01 () {
|
||||||
|
local var="$1"
|
||||||
|
[ "$var" = "true" ] && var=1
|
||||||
|
[ "$var" = "false" ] && var=0
|
||||||
|
echo "$var"
|
||||||
|
}
|
||||||
|
|
||||||
|
bool_to_true_false () {
|
||||||
|
local var="$1"
|
||||||
|
[ "$var" = "1" ] && var=true
|
||||||
|
[ "$var" = "0" ] && var=false
|
||||||
|
echo "$var"
|
||||||
|
}
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# EXPERIMENTAL HELPERS
|
# EXPERIMENTAL HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -517,7 +535,7 @@ EOF
|
||||||
ynh_store_file_checksum "$finalfail2banjailconf"
|
ynh_store_file_checksum "$finalfail2banjailconf"
|
||||||
ynh_store_file_checksum "$finalfail2banfilterconf"
|
ynh_store_file_checksum "$finalfail2banfilterconf"
|
||||||
|
|
||||||
systemctl reload fail2ban
|
systemctl restart fail2ban
|
||||||
local fail2ban_error="$(journalctl -u fail2ban | tail -n50 | grep "WARNING.*$app.*")"
|
local fail2ban_error="$(journalctl -u fail2ban | tail -n50 | grep "WARNING.*$app.*")"
|
||||||
if [ -n "$fail2ban_error" ]
|
if [ -n "$fail2ban_error" ]
|
||||||
then
|
then
|
||||||
|
@ -532,7 +550,7 @@ EOF
|
||||||
ynh_remove_fail2ban_config () {
|
ynh_remove_fail2ban_config () {
|
||||||
ynh_secure_remove "/etc/fail2ban/jail.d/$app.conf"
|
ynh_secure_remove "/etc/fail2ban/jail.d/$app.conf"
|
||||||
ynh_secure_remove "/etc/fail2ban/filter.d/$app.conf"
|
ynh_secure_remove "/etc/fail2ban/filter.d/$app.conf"
|
||||||
systemctl reload fail2ban
|
systemctl restart fail2ban
|
||||||
}
|
}
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -162,7 +162,7 @@ ynh_replace_string "__SALTKEY__" "$saltkey" ../conf/sk.php
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
cp ../conf/sk.php $path_sk_file/sk.php
|
cp ../conf/sk.php $path_sk_file/sk.php
|
||||||
chown -R root:$app $path_sk_file
|
chown -R $app $path_sk_file
|
||||||
chmod 750 $path_sk_file
|
chmod 750 $path_sk_file
|
||||||
cp ../conf/settings.php $final_path/includes/config/settings.php
|
cp ../conf/settings.php $final_path/includes/config/settings.php
|
||||||
ynh_store_file_checksum "$final_path/includes/config/settings.php" # Enregistre la somme de contrôle du fichier de config
|
ynh_store_file_checksum "$final_path/includes/config/settings.php" # Enregistre la somme de contrôle du fichier de config
|
||||||
|
|
|
@ -76,8 +76,8 @@ ynh_system_user_create $app # Recreate the dedicated user, if not exist
|
||||||
|
|
||||||
# Les fichiers appartiennent à root
|
# Les fichiers appartiennent à root
|
||||||
chown -R root: $final_path
|
chown -R root: $final_path
|
||||||
# Sauf les dossiers files et upload
|
# Sauf les dossiers includes, files et upload
|
||||||
chown -R $app: $final_path/files $final_path/upload
|
chown -R $app $final_path/{includes,files,upload}
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE OF THE PHP-FPM CONFIGURATION
|
# RESTORE OF THE PHP-FPM CONFIGURATION
|
||||||
|
@ -93,7 +93,7 @@ ynh_restore_file "/etc/php5/fpm/conf.d/20-$app.ini"
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_restore_file "/etc/$app/sk.php"
|
ynh_restore_file "/etc/$app/sk.php"
|
||||||
chown -R root:$app "/etc/$app/sk.php"
|
chown -R $app "/etc/$app/sk.php"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE CRON FILE
|
# RESTORE CRON FILE
|
||||||
|
|
|
@ -29,12 +29,12 @@ upgrade_type=$(ynh_check_app_version_changed)
|
||||||
# ENSURE DOWNWARD COMPATIBILITY
|
# ENSURE DOWNWARD COMPATIBILITY
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
if [ -z $final_path ]; then # Si final_path n'est pas renseigné dans app setting
|
if [ -z "$final_path" ]; then # Si final_path n'est pas renseigné dans app setting
|
||||||
final_path=/var/www/$app
|
final_path=/var/www/$app
|
||||||
ynh_app_setting_set $app final_path $final_path
|
ynh_app_setting_set $app final_path $final_path
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z $db_name ]; then # Si db_name n'est pas renseigné dans app setting
|
if [ -z "$db_name" ]; then # Si db_name n'est pas renseigné dans app setting
|
||||||
db_name=$(ynh_sanitize_dbid $app)
|
db_name=$(ynh_sanitize_dbid $app)
|
||||||
ynh_app_setting_set $app db_name $db_name
|
ynh_app_setting_set $app db_name $db_name
|
||||||
fi
|
fi
|
||||||
|
@ -75,7 +75,8 @@ then
|
||||||
ynh_setup_source "$final_path" # Télécharge la source, décompresse et copie dans $final_path
|
ynh_setup_source "$final_path" # Télécharge la source, décompresse et copie dans $final_path
|
||||||
|
|
||||||
# Delete the install directory.
|
# Delete the install directory.
|
||||||
ynh_secure_remove "$final_path/install"
|
# Keep it for the manual upgrade process...
|
||||||
|
# ynh_secure_remove "$final_path/install"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -126,6 +127,8 @@ echo "0 0 * * 0 $app cd $final_path/backups && php script.backup.php" > /etc/cro
|
||||||
# ENSURE DOWNWARD COMPATIBILITY
|
# ENSURE DOWNWARD COMPATIBILITY
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||||
|
then
|
||||||
# Move settings.php from old teampass version
|
# Move settings.php from old teampass version
|
||||||
if [ ! -e "$final_path/includes/config/settings.php" ]
|
if [ ! -e "$final_path/includes/config/settings.php" ]
|
||||||
then
|
then
|
||||||
|
@ -140,6 +143,33 @@ then
|
||||||
ynh_replace_string "jsUrl\" => \"" "&includes/libraries/csrfp/js/csrfprotector.js" $final_path/includes/libraries/csrfp/libs/csrfp.config.php # Renseigne l'adresse de csrfprotector.js
|
ynh_replace_string "jsUrl\" => \"" "&includes/libraries/csrfp/js/csrfprotector.js" $final_path/includes/libraries/csrfp/libs/csrfp.config.php # Renseigne l'adresse de csrfprotector.js
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Run database upgrades
|
||||||
|
# Upgrade to 2.1.23.4
|
||||||
|
ynh_mysql_execute_as_root "ALTER TABLE teampass_misc ADD id INT(12) NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (id);" $app >&2
|
||||||
|
# Upgrade to 2.1.24.4
|
||||||
|
ynh_mysql_execute_as_root "ALTER TABLE teampass_items CHANGE pw_len pw_len INT(5) NOT NULL DEFAULT '0';" $app >&2
|
||||||
|
# Upgrade to 2.1.25.2
|
||||||
|
ynh_mysql_execute_as_root "INSERT INTO teampass_misc (id, type, intitule, valeur) VALUES (NULL, 'admin', 'encryption_protocol', 'ctr');" $app >&2
|
||||||
|
# Upgrade to 2.1.27.x
|
||||||
|
ynh_mysql_execute_as_root "ALTER TABLE teampass_misc CHANGE id increment_id INT(12) NOT NULL AUTO_INCREMENT;" $app >&2
|
||||||
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# UPDATE SETTINGS.PHP
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Remplacement des variables dans le fichier settings.php
|
||||||
|
ynh_replace_string "__DBUSER__" "$db_name" ../conf/settings.php
|
||||||
|
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
|
||||||
|
ynh_replace_string "__DBPWD__" "$db_pwd" ../conf/settings.php
|
||||||
|
ynh_replace_string "__FINALPATH__" "$final_path" ../conf/settings.php
|
||||||
|
path_sk_file=/etc/$app/
|
||||||
|
ynh_replace_string "__SKPATH__" "$path_sk_file" ../conf/settings.php
|
||||||
|
|
||||||
|
ynh_backup_if_checksum_is_different "$final_path/includes/config/settings.php"
|
||||||
|
cp ../conf/settings.php $final_path/includes/config/settings.php
|
||||||
|
ynh_store_file_checksum "$final_path/includes/config/settings.php" # Enregistre la somme de contrôle du fichier de config
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALISATION
|
# GENERIC FINALISATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -148,8 +178,8 @@ fi
|
||||||
|
|
||||||
# Les fichiers appartiennent à root
|
# Les fichiers appartiennent à root
|
||||||
chown -R root: $final_path
|
chown -R root: $final_path
|
||||||
# Sauf certains dossiers includes, files et upload
|
# Sauf certains dossiers includes, install, files et upload
|
||||||
chown -R $app $final_path/{includes,files,upload}
|
chown -R $app $final_path/{includes,install,files,upload}
|
||||||
# Restreint l'accès au dossier de backup
|
# Restreint l'accès au dossier de backup
|
||||||
chmod 750 $final_path/backups
|
chmod 750 $final_path/backups
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue