From c3371699e8240e1a34277911d2297f863e892893 Mon Sep 17 00:00:00 2001 From: Kload Date: Fri, 25 Oct 2013 10:11:24 +0000 Subject: [PATCH] App system fixes --- action_map.yml | 2 +- yunohost_app.py | 23 ++++++++++++++--------- yunohost_hook.py | 6 +++++- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/action_map.yml b/action_map.yml index 60d7773c..42625390 100644 --- a/action_map.yml +++ b/action_map.yml @@ -333,7 +333,7 @@ app: action: store_true ### app_setting() - addaccess: + setting: action_help: Set ou get an app setting value api: GET /app/{app}/setting arguments: diff --git a/yunohost_app.py b/yunohost_app.py index 8cbc6245..487aef98 100644 --- a/yunohost_app.py +++ b/yunohost_app.py @@ -352,15 +352,19 @@ def app_install(app, label=None): else: app_setting(app_id, 'label', manifest['name']) - # Move scripts and manifest to the right place - os.system('mv "'+ app_tmp_folder +'/manifest.json" "'+ app_tmp_folder +'/scripts" '+ app_setting_path) - + os.system('chown -R admin: '+ app_tmp_folder) # Execute App install script - if hook_exec(app_setting_path+ '/scripts/install') != 0: + if hook_exec(app_tmp_folder + '/scripts/install') == 0: + # Move scripts and manifest to the right place + os.system('mv "'+ app_tmp_folder +'/manifest.json" "'+ app_tmp_folder +'/scripts" '+ app_setting_path) + shutil.rmtree(app_tmp_folder) + os.system('chmod -R 400 '+ app_setting_path) + os.system('chown -R root: '+ app_setting_path) + win_msg(_("Installation complete")) + else: #TODO: display script fail messages shutil.rmtree(app_setting_path) - - win_msg(_("Installation complete")) + raise YunoHostError(1, _("Installation failed")) def app_remove(app): @@ -375,8 +379,10 @@ def app_remove(app): if not _is_installed(app): raise YunoHostError(22, _("App is not installed")) + app_setting_path = apps_setting_path + app + #TODO: display fail messages from script - if hook_exec(apps_setting_path +'/'+ app + '/scripts/remove') != 0: + if hook_exec(app_setting_path + '/scripts/remove') != 0: pass if os.path.exists(app_setting_path): shutil.rmtree(app_setting_path) @@ -483,10 +489,9 @@ def app_setting(app, key, value=None): with open(settings_file, 'w') as f: yaml.safe_dump(app_settings, f, default_flow_style=False) - - return True + def _extract_app_from_file(path, remove=False): """ Unzip or untar application tarball in app_tmp_folder, or copy it from a directory diff --git a/yunohost_hook.py b/yunohost_hook.py index 77f4e72a..9dfd19b0 100644 --- a/yunohost_hook.py +++ b/yunohost_hook.py @@ -117,4 +117,8 @@ def hook_exec(file, args=None): else: raise YunoHostError(22, _("Missing arguments") + ': ' + arg_name) - return os.system('su - admin -c "bash \\"'+ file +'\\" '+ ' '.join(arg_list) +'"') #TODO: Allow python script + file_path = "./" + if "/" in file and file[0:2] != file_path: + file_path = os.path.dirname(file) + file = file.replace(file_path +"/", "") + return os.system('su - admin -c "cd \\"'+ file_path +'\\" && bash \\"'+ file +'\\" '+ ' '.join(arg_list) +'"') #TODO: Allow python script