mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Merge pull request #192 from YunoHost/install-no-remove-on-fail-option
Install no remove on fail option
This commit is contained in:
commit
e910694179
2 changed files with 18 additions and 13 deletions
|
@ -499,6 +499,9 @@ app:
|
||||||
-a:
|
-a:
|
||||||
full: --args
|
full: --args
|
||||||
help: Serialized arguments for app script (i.e. "domain=domain.tld&path=/path")
|
help: Serialized arguments for app script (i.e. "domain=domain.tld&path=/path")
|
||||||
|
-n:
|
||||||
|
full: --no-remove-on-failure
|
||||||
|
help: Debug option to avoid removing the app on a failed installation
|
||||||
|
|
||||||
### app_remove() TODO: Write help
|
### app_remove() TODO: Write help
|
||||||
remove:
|
remove:
|
||||||
|
|
|
@ -438,7 +438,7 @@ def app_upgrade(auth, app=[], url=None, file=None):
|
||||||
logger.success(m18n.n('upgrade_complete'))
|
logger.success(m18n.n('upgrade_complete'))
|
||||||
|
|
||||||
|
|
||||||
def app_install(auth, app, label=None, args=None):
|
def app_install(auth, app, label=None, args=None, no_remove_on_failure=False):
|
||||||
"""
|
"""
|
||||||
Install apps
|
Install apps
|
||||||
|
|
||||||
|
@ -446,6 +446,7 @@ def app_install(auth, app, label=None, args=None):
|
||||||
app -- Name, local path or git URL of the app to install
|
app -- Name, local path or git URL of the app to install
|
||||||
label -- Custom name for the app
|
label -- Custom name for the app
|
||||||
args -- Serialize arguments for app installation
|
args -- Serialize arguments for app installation
|
||||||
|
no_remove_on_failure -- Debug option to avoid removing the app on a failed installation
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from yunohost.hook import hook_add, hook_remove, hook_exec
|
from yunohost.hook import hook_add, hook_remove, hook_exec
|
||||||
|
@ -539,19 +540,20 @@ def app_install(auth, app, label=None, args=None):
|
||||||
logger.exception(m18n.n('unexpected_error'))
|
logger.exception(m18n.n('unexpected_error'))
|
||||||
finally:
|
finally:
|
||||||
if install_retcode != 0:
|
if install_retcode != 0:
|
||||||
# Setup environment for remove script
|
if not no_remove_on_failure:
|
||||||
env_dict_remove = {}
|
# Setup environment for remove script
|
||||||
env_dict_remove["YNH_APP_ID"] = app_id
|
env_dict_remove = {}
|
||||||
env_dict_remove["YNH_APP_INSTANCE_NAME"] = app_instance_name
|
env_dict_remove["YNH_APP_ID"] = app_id
|
||||||
env_dict_remove["YNH_APP_INSTANCE_NUMBER"] = str(instance_number)
|
env_dict_remove["YNH_APP_INSTANCE_NAME"] = app_instance_name
|
||||||
|
env_dict_remove["YNH_APP_INSTANCE_NUMBER"] = str(instance_number)
|
||||||
|
|
||||||
# Execute remove script
|
# Execute remove script
|
||||||
remove_retcode = hook_exec(
|
remove_retcode = hook_exec(
|
||||||
os.path.join(extracted_app_folder, 'scripts/remove'),
|
os.path.join(extracted_app_folder, 'scripts/remove'),
|
||||||
args=[app_instance_name], env=env_dict_remove)
|
args=[app_instance_name], env=env_dict_remove)
|
||||||
if remove_retcode != 0:
|
if remove_retcode != 0:
|
||||||
logger.warning(m18n.n('app_not_properly_removed',
|
logger.warning(m18n.n('app_not_properly_removed',
|
||||||
app=app_instance_name))
|
app=app_instance_name))
|
||||||
|
|
||||||
# Clean tmp folders
|
# Clean tmp folders
|
||||||
shutil.rmtree(app_setting_path)
|
shutil.rmtree(app_setting_path)
|
||||||
|
|
Loading…
Add table
Reference in a new issue