mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
Hook system bugfixes
This commit is contained in:
parent
41b90067e5
commit
37d87cad09
3 changed files with 18 additions and 24 deletions
|
@ -712,7 +712,7 @@ hook:
|
||||||
api: GET /hook/check
|
api: GET /hook/check
|
||||||
arguments:
|
arguments:
|
||||||
file:
|
file:
|
||||||
help: Script to check
|
help: File to check
|
||||||
|
|
||||||
### hook_exec()
|
### hook_exec()
|
||||||
exec:
|
exec:
|
||||||
|
|
|
@ -652,12 +652,12 @@ def app_ssowatconf():
|
||||||
if 'allowed_users' not in app_settings:
|
if 'allowed_users' not in app_settings:
|
||||||
app_settings['allowed_users'] = ''
|
app_settings['allowed_users'] = ''
|
||||||
|
|
||||||
apps[app] = {
|
apps[app] = {
|
||||||
'domain': app_settings['domain'],
|
'domain': app_settings['domain'],
|
||||||
'path': app_settings['path'],
|
'path': app_settings['path'],
|
||||||
'mode': app_settings['mode'],
|
'mode': app_settings['mode'],
|
||||||
'allowed_users': app_settings['allowed_users']
|
'allowed_users': app_settings['allowed_users']
|
||||||
}
|
}
|
||||||
|
|
||||||
users = {}
|
users = {}
|
||||||
for user in user_list()['Users']:
|
for user in user_list()['Users']:
|
||||||
|
|
|
@ -67,27 +67,21 @@ def hook_check(file):
|
||||||
Parse the script file and get arguments
|
Parse the script file and get arguments
|
||||||
|
|
||||||
Keyword argument:
|
Keyword argument:
|
||||||
file -- Script to check
|
file -- File to check
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
try:
|
||||||
|
with open(file[:file.index('scripts/install')] + 'manifest.json') as f:
|
||||||
|
manifest = json.loads(str(f.read()))
|
||||||
|
except:
|
||||||
|
raise YunoHostError(22, _("Invalid app package"))
|
||||||
|
|
||||||
with open(file, 'r') as conf:
|
action = file[file.index('scripts/') + 8:]
|
||||||
script_lines = conf.readlines()
|
if action in manifest["arguments"]:
|
||||||
|
return manifest["arguments"][action]
|
||||||
in_block = False
|
|
||||||
json_string = ""
|
|
||||||
for line in script_lines:
|
|
||||||
if re.search(r'^#### json"', line):
|
|
||||||
in_block = True
|
|
||||||
if in_block and re.search(r'^####', line):
|
|
||||||
in_block = False
|
|
||||||
elif re.search(r'^##[^#;]', line):
|
|
||||||
json_string = json_string + line[2:]
|
|
||||||
|
|
||||||
if json_string == "":
|
|
||||||
return {}
|
|
||||||
else:
|
else:
|
||||||
return json.loads(json_string)['arguments']
|
return {}
|
||||||
|
|
||||||
|
|
||||||
def hook_exec(file, args=None):
|
def hook_exec(file, args=None):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue