From a9046a720080258f0b57cc14fb397c0ca12cc472 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Lebleu?= Date: Thu, 24 Dec 2015 10:35:39 +0100 Subject: [PATCH 1/3] [enh] Allow to pass the admin password as argument in the cli --- bin/yunohost | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bin/yunohost b/bin/yunohost index a5fadf574..3f947364b 100755 --- a/bin/yunohost +++ b/bin/yunohost @@ -66,6 +66,10 @@ def _parse_cli_args(): action='store_true', default=False, help="Don't produce any output", ) + parser.add_argument('--admin-password', + default=None, dest='password', metavar='PASSWORD', + help="The admin password to use to authenticate", + ) # deprecated arguments parser.add_argument('--plain', action='store_true', default=False, help=argparse.SUPPRESS @@ -199,6 +203,6 @@ if __name__ == '__main__': from moulinette import cli ret = cli(_retrieve_namespaces(), args, use_cache=opts.use_cache, output_as=opts.output_as, - parser_kwargs={'top_parser': parser} + password=opts.password, parser_kwargs={'top_parser': parser} ) sys.exit(ret) From 6840d120c0d2ad6981b11f396ec189d57628eed6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Lebleu?= Date: Thu, 24 Dec 2015 10:37:11 +0100 Subject: [PATCH 2/3] [enh] Add a helper to create a directory under /tmp --- data/apps/helpers.d/filesystem | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/data/apps/helpers.d/filesystem b/data/apps/helpers.d/filesystem index c3332a794..087a9e944 100644 --- a/data/apps/helpers.d/filesystem +++ b/data/apps/helpers.d/filesystem @@ -27,3 +27,15 @@ ynh_bind_or_cp() { fi $SUDO_CMD cp -r "$SRCDIR" "$DESTDIR" } + +# Create a directory under /tmp +# +# usage: ynh_mkdir_tmp +# | ret: the created directory path +ynh_mkdir_tmp() { + TMPDIR="/tmp/$(ynh_string_random 6)" + while [ -d $TMPDIR ]; do + TMPDIR="/tmp/$(ynh_string_random 6)" + done + mkdir -p "$TMPDIR" && echo "$TMPDIR" +} From e5c467ad266e11a8691090dcee220e89b147aea3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Lebleu?= Date: Thu, 24 Dec 2015 10:38:10 +0100 Subject: [PATCH 3/3] [enh] Add helpers to set and get an application setting --- data/apps/helpers.d/setting | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 data/apps/helpers.d/setting diff --git a/data/apps/helpers.d/setting b/data/apps/helpers.d/setting new file mode 100644 index 000000000..14d47c133 --- /dev/null +++ b/data/apps/helpers.d/setting @@ -0,0 +1,18 @@ +# Get an application setting +# +# usage: ynh_app_setting_get app key +# | arg: app - the application id +# | arg: key - the setting to get +ynh_app_setting_get() { + sudo yunohost app setting "$1" "$2" --output-as plain +} + +# Set an application setting +# +# usage: ynh_app_setting_set app key value +# | arg: app - the application id +# | arg: key - the setting name to set +# | arg: value - the setting value to set +ynh_app_setting_set() { + sudo yunohost app setting "$1" "$2" -v "$3" +}