mirror of
https://github.com/YunoHost-Apps/cheky_ynh.git
synced 2024-09-03 18:16:00 +02:00
WIP - rework automated upgrade method
Does not work at the moment.
This commit is contained in:
parent
de7e7522b2
commit
5af9dc26f5
2 changed files with 54 additions and 1 deletions
|
@ -109,7 +109,8 @@ ynh_add_fpm_config
|
||||||
#=================================================
|
#=================================================
|
||||||
# ...
|
# ...
|
||||||
#=================================================
|
#=================================================
|
||||||
#todo: part needed ?
|
|
||||||
|
ynh_print_info "Running specific upgrade..."
|
||||||
# Verify the checksum and backup the file if it's different
|
# Verify the checksum and backup the file if it's different
|
||||||
#ynh_backup_if_checksum_is_different "$final_path/CONFIG_FILE"
|
#ynh_backup_if_checksum_is_different "$final_path/CONFIG_FILE"
|
||||||
# Recalculate and store the config file checksum into the app settings
|
# Recalculate and store the config file checksum into the app settings
|
||||||
|
@ -120,7 +121,22 @@ ynh_add_fpm_config
|
||||||
# needs to be edited with latest version
|
# needs to be edited with latest version
|
||||||
# Also avoid to make file "$final_path/version.php" writable
|
# Also avoid to make file "$final_path/version.php" writable
|
||||||
|
|
||||||
|
# Give full access to "$app" so php script can do "its own magic stuff"
|
||||||
|
chown -R $app: $final_path
|
||||||
|
|
||||||
#exec_as "$app" "/usr/bin/php $YNH_CWD/upgrade_cheky.php $final_path"
|
#exec_as "$app" "/usr/bin/php $YNH_CWD/upgrade_cheky.php $final_path"
|
||||||
|
sudo -u "$app" "/usr/bin/php $YNH_CWD/upgrade_cheky.php $final_path"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CONFIGURE HOOKS
|
||||||
|
#=================================================
|
||||||
|
### TODO: Better to use a hook like "post_app_upgrade" ?
|
||||||
|
#ynh_print_info "Running post upgrade recipe..."
|
||||||
|
|
||||||
|
#ynh_replace_string "__FINALPATH__" "$final_path" "../hooks/post_app_install"
|
||||||
|
#ynh_replace_string "__FINALPATH__" "$final_path" "../hooks/post_app_remove"
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
37
scripts/upgrade_cheky.php
Normal file
37
scripts/upgrade_cheky.php
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// source: https://forum.cheky.net/mise-a-jour-de-cheky-en-ligne-de-commande-t659-p1.html#p2624
|
||||||
|
|
||||||
|
//$root_path = "__FINALPATH__";
|
||||||
|
$root_path = $_SERVER["argv"][1];
|
||||||
|
if (empty($root_path) || !is_dir($root_path)) {
|
||||||
|
fwrite(STDERR, "Chemin manquant dans hook : post_app_upgrade");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
require $root_path."/bootstrap.php";
|
||||||
|
|
||||||
|
$storageType = $config->get("storage", "type", "files");
|
||||||
|
if ($storageType == "db") {
|
||||||
|
$userStorage = new \App\Storage\Db\User($dbConnection);
|
||||||
|
} else {
|
||||||
|
$userStorage = new \App\Storage\File\User(DOCUMENT_ROOT."/var/users.db");
|
||||||
|
}
|
||||||
|
|
||||||
|
//require $root_path."/bootstrap.php";
|
||||||
|
|
||||||
|
$_POST = array(
|
||||||
|
"upgrade" => 1,
|
||||||
|
);
|
||||||
|
|
||||||
|
require $root_path."/app/admin/scripts/upgrade.php";
|
||||||
|
|
||||||
|
// S'il y a des erreurs, on les écrit dans STDERR et on quitte
|
||||||
|
// avec un code erreur.
|
||||||
|
#if (!empty($errors)) {
|
||||||
|
# fwrite(STDERR, str_replace(
|
||||||
|
# array("<br>", "<br />"), "", implode("\n", $errors)
|
||||||
|
# );
|
||||||
|
# exit(1);
|
||||||
|
#}
|
Loading…
Add table
Reference in a new issue