From 3cafe1dda036eb92d605ac54ff9bf6b2f0901f69 Mon Sep 17 00:00:00 2001 From: Kload Date: Mon, 3 Mar 2014 13:10:33 +0100 Subject: [PATCH 01/36] App remove API route fix --- action_map.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action_map.yml b/action_map.yml index 15b41c16..712714eb 100644 --- a/action_map.yml +++ b/action_map.yml @@ -310,7 +310,7 @@ app: ### app_remove() TODO: Write help remove: action_help: Remove app - api: DELETE /app/{app} + api: DELETE /app arguments: app: help: App(s) to delete From 365b84ee69f2bcc4e8fe8cd36c6a1d98b11f17e4 Mon Sep 17 00:00:00 2001 From: Kload Date: Mon, 3 Mar 2014 13:18:46 +0100 Subject: [PATCH 02/36] Return main domain if no domain is provide (closes #91) --- yunohost_tools.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/yunohost_tools.py b/yunohost_tools.py index aecd9ce9..065b1681 100644 --- a/yunohost_tools.py +++ b/yunohost_tools.py @@ -99,7 +99,7 @@ def tools_adminpw(old_password, new_password): raise YunoHostError(22, _("Invalid password")) -def tools_maindomain(old_domain, new_domain, dyndns=False): +def tools_maindomain(old_domain=None, new_domain=None, dyndns=False): """ Main domain change tool @@ -113,6 +113,9 @@ def tools_maindomain(old_domain, new_domain, dyndns=False): with open('/etc/yunohost/current_host', 'r') as f: old_domain = f.readline().rstrip() + if not new_domain: + return { 'Current main domain': old_domain } + validate(r'^([a-zA-Z0-9]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)(\.[a-zA-Z0-9]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)*(\.[a-zA-Z]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)$', old_domain) config_files = [ From 67af5a68e9ff4db86e0f847f4d829325943b9fe3 Mon Sep 17 00:00:00 2001 From: kload Date: Mon, 3 Mar 2014 13:23:51 +0100 Subject: [PATCH 03/36] Ask fix --- action_map.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/action_map.yml b/action_map.yml index 712714eb..c973bdbb 100644 --- a/action_map.yml +++ b/action_map.yml @@ -827,7 +827,6 @@ tools: pattern: '^([a-zA-Z0-9]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)(\.[a-zA-Z0-9]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)*(\.[a-zA-Z]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)$' -n: full: --new-domain - ask: "New main domain" pattern: '^([a-zA-Z0-9]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)(\.[a-zA-Z0-9]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)*(\.[a-zA-Z]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)$' ### tools_postinstall() From fed6718b4a279bcc0f250a05e4b72961603ab09c Mon Sep 17 00:00:00 2001 From: kload Date: Mon, 3 Mar 2014 13:49:18 +0100 Subject: [PATCH 04/36] Add/remove access bugfix (closes #93 and closes #94) --- yunohost_app.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/yunohost_app.py b/yunohost_app.py index ead0ac45..525e4043 100644 --- a/yunohost_app.py +++ b/yunohost_app.py @@ -528,7 +528,11 @@ def app_addaccess(apps, users): apps """ - #TODO: Adapt to SSOwat + if not users: + users = [] + for user in user_list()['Users']: + users.append(user['Username']) + if not isinstance(users, list): users = [users] if not isinstance(apps, list): apps = [apps] @@ -564,6 +568,8 @@ def app_addaccess(apps, users): app_ssowatconf() + return { 'allowed_users': new_users.split(',') } + def app_removeaccess(apps, users): """ @@ -574,7 +580,9 @@ def app_removeaccess(apps, users): apps """ - #TODO: Remove access + remove_all = False + if not users: + remove_all = True if not isinstance(users, list): users = [users] if not isinstance(apps, list): apps = [apps] for app in apps: @@ -587,7 +595,9 @@ def app_removeaccess(apps, users): app_settings = yaml.load(f) if 'skipped_uris' not in app_settings or app_settings['skipped_uris'] != '/': - if 'allowed_users' in app_settings: + if remove_all: + new_users = '' + elif 'allowed_users' in app_settings: for allowed_user in app_settings['allowed_users'].split(','): if allowed_user not in users: if new_users == '': @@ -606,6 +616,7 @@ def app_removeaccess(apps, users): app_ssowatconf() + return { 'allowed_users': new_users.split(',') } def app_setting(app, key, value=None, delete=False): """ From ef6364b5427ac0868756f267b22f7d821c78bd80 Mon Sep 17 00:00:00 2001 From: kload Date: Mon, 3 Mar 2014 13:50:46 +0100 Subject: [PATCH 05/36] Change key formatting to return --- yunohost_tools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yunohost_tools.py b/yunohost_tools.py index 065b1681..320d6472 100644 --- a/yunohost_tools.py +++ b/yunohost_tools.py @@ -114,7 +114,7 @@ def tools_maindomain(old_domain=None, new_domain=None, dyndns=False): old_domain = f.readline().rstrip() if not new_domain: - return { 'Current main domain': old_domain } + return { 'current_main_domain': old_domain } validate(r'^([a-zA-Z0-9]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)(\.[a-zA-Z0-9]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)*(\.[a-zA-Z]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)$', old_domain) From ed0016ed66b8574e181f34619f97979f843f0b8f Mon Sep 17 00:00:00 2001 From: kload Date: Mon, 3 Mar 2014 13:58:41 +0100 Subject: [PATCH 06/36] App clearaccess --- action_map.yml | 7 +++++++ yunohost_app.py | 27 +++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/action_map.yml b/action_map.yml index c973bdbb..42568c7a 100644 --- a/action_map.yml +++ b/action_map.yml @@ -432,6 +432,13 @@ app: full: --users nargs: "+" + ### app_clearaccess() + clearaccess: + action_help: Reset access rights for the app + api: POST /app/access + arguments: + apps: + nargs: "+" ############################# # Backup # diff --git a/yunohost_app.py b/yunohost_app.py index 525e4043..36074183 100644 --- a/yunohost_app.py +++ b/yunohost_app.py @@ -618,6 +618,33 @@ def app_removeaccess(apps, users): return { 'allowed_users': new_users.split(',') } + +def app_clearaccess(apps): + """ + Reset access rights for the app + + Keyword argument: + apps + + """ + if not isinstance(apps, list): apps = [apps] + + for app in apps: + if not _is_installed(app): + raise YunoHostError(22, _("App is not installed")) + + with open(apps_setting_path + app +'/settings.yml') as f: + app_settings = yaml.load(f) + + if 'mode' in app_settings: + app_setting(app, 'mode', delete=True) + + if 'allowed_users' in app_settings: + app_setting(app, 'allowed_users', delete=True) + + app_ssowatconf() + + def app_setting(app, key, value=None, delete=False): """ Set or get an app setting value From 9fb6c8a1670596493d216500f6805954bf2acde1 Mon Sep 17 00:00:00 2001 From: Kload Date: Mon, 3 Mar 2014 14:15:19 +0100 Subject: [PATCH 07/36] Remove light mode and change hostname in /etc/amavis/conf.d/50-user --- yunohost_tools.py | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/yunohost_tools.py b/yunohost_tools.py index 320d6472..70e56775 100644 --- a/yunohost_tools.py +++ b/yunohost_tools.py @@ -123,8 +123,9 @@ def tools_maindomain(old_domain=None, new_domain=None, dyndns=False): '/etc/metronome/metronome.cfg.lua', '/etc/dovecot/dovecot.conf', '/usr/share/yunohost/yunohost-config/others/startup', - '/home/yunohost.backup/tahoe/tahoe.cfg' - '/etc/amavis/conf.d/05-node_id' + '/home/yunohost.backup/tahoe/tahoe.cfg', + '/etc/amavis/conf.d/05-node_id', + '/etc/amavis/conf.d/50-user' ] config_dir = [] @@ -220,21 +221,6 @@ def tools_postinstall(domain, password, dyndns=False): if os.system('hostname -d') != 0: os.system('hostname yunohost.yunohost.org') - # Activate "full" mode if RAM >= 512MB - for L in open("/proc/meminfo"): - if "MemTotal" in L: - if int(L.split(" ")[-2]) < 500000 or not requests.get('http://ip.yunohost.org/'): - os.system('touch /etc/yunohost/light') - else: - os.system('service dspam stop') - os.system('chmod -x /etc/cron.daily/dspam') - os.system('update-rc.d dspam remove') - os.system('sed -i "s/yes/no/g" /etc/default/dspam') - os.system('sed -i "s/dspam=no/dspam=yes/" /etc/yunohost/yunohost.conf') - os.system('apt-get install -y -qq yunohost-config-amavis') - os.system('service amavis start') - os.system('apt-get install --reinstall -y -qq yunohost-config-postfix yunohost-config-dovecot') - # Create SSL CA ssl_dir = '/usr/share/yunohost/yunohost-config/ssl/yunoCA' command_list = [ From 17639a254e0886668ac484033ff20f825361de65 Mon Sep 17 00:00:00 2001 From: Kload Date: Mon, 3 Mar 2014 15:07:06 +0100 Subject: [PATCH 08/36] Restart amavis at postinstallation --- yunohost_tools.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/yunohost_tools.py b/yunohost_tools.py index 70e56775..5fc68786 100644 --- a/yunohost_tools.py +++ b/yunohost_tools.py @@ -153,7 +153,8 @@ def tools_maindomain(old_domain=None, new_domain=None, dyndns=False): 'service nginx restart', 'service metronome restart', 'service postfix restart', - 'service dovecot restart' + 'service dovecot restart', + 'service amavis restart' ] try: From 7818ec8117ad1a5d3fc4237e1bcbb059ea1fe080 Mon Sep 17 00:00:00 2001 From: Alexis Gavoty Date: Mon, 3 Mar 2014 19:06:09 +0100 Subject: [PATCH 09/36] Update yunohost_dyndns.py --- yunohost_dyndns.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yunohost_dyndns.py b/yunohost_dyndns.py index 2d4355ce..4949f366 100644 --- a/yunohost_dyndns.py +++ b/yunohost_dyndns.py @@ -136,7 +136,7 @@ def dyndns_update(dyn_host="dynhost.yunohost.org", domain=None, key=None, ip=Non with open('/etc/yunohost/dyndns/old_ip', 'w') as f: f.write(new_ip) else: - os.remove('/etc/yunohost/dyndns/old_ip') + os.system('rm /etc/yunohost/dyndns/old_ip > /dev/null 2>&1') raise YunoHostError(1, _("An error occured during DynDNS update")) From eaf1a76ca1c2317d201ed8b42c4abdd890c38691 Mon Sep 17 00:00:00 2001 From: Jerome Lebleu Date: Mon, 3 Mar 2014 23:32:20 +0100 Subject: [PATCH 10/36] Fix yunohost-api status --- services.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services.yml b/services.yml index fc0bee7b..ec5c37d4 100644 --- a/services.yml +++ b/services.yml @@ -31,7 +31,7 @@ php5-fpm: status: service log: /var/log/php5-fpm.log yunohost-api: - status: service + status: cat /usr/share/pyshared/yunohost-cli/twistd.pid log: /var/log/yunohost.log postgrey: status: service From bb51b9ce8d265dac206ba6d1688c2665b5bef08c Mon Sep 17 00:00:00 2001 From: npze Date: Sat, 8 Mar 2014 10:48:25 +0100 Subject: [PATCH 11/36] Add regex, protection and static rules for ssowat --- yunohost_app.py | 55 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 13 deletions(-) diff --git a/yunohost_app.py b/yunohost_app.py index 36074183..6c2507ad 100644 --- a/yunohost_app.py +++ b/yunohost_app.py @@ -831,7 +831,12 @@ def app_ssowatconf(): users[user['Username']] = app_map(user=user['Username']) skipped_urls = [] + skipped_regex = [] unprotected_urls = [] + unprotected_regex = [] + protected_urls = [] + protected_regex = [] + apps = {} for app in app_list()['Apps']: if _is_installed(app['ID']): @@ -842,32 +847,56 @@ def app_ssowatconf(): if item[-1:] == '/': item = item[:-1] skipped_urls.append(app_settings['domain'] + app_settings['path'][:-1] + item) + if 'skipped_regex' in app_settings: + for item in app_settings['skipped_regex'].split(','): + skipped_regex.append(item) if 'unprotected_uris' in app_settings: for item in app_settings['unprotected_uris'].split(','): if item[-1:] == '/': item = item[:-1] unprotected_urls.append(app_settings['domain'] + app_settings['path'][:-1] + item) + if 'unprotected_regex' in app_settings: + for item in app_settings['unprotected_regex'].split(','): + unprotected_regex.append(item) + if 'protected_uris' in app_settings: + for item in app_settings['protected_uris'].split(','): + if item[-1:] == '/': + item = item[:-1] + protected_urls.append(app_settings['domain'] + app_settings['path'][:-1] + item) + if 'protected_regex' in app_settings: + for item in app_settings['protected_regex'].split(','): + protected_regex.append(item) for domain in domains: skipped_urls.extend([domain +'/ynhadmin', domain +'/ynhapi']) - conf_dict = { - 'portal_domain': main_domain, - 'portal_path': '/ynhsso/', - 'portal_port': '443', - 'portal_scheme': 'https', - 'additional_headers': { + with open('/etc/ssowat/conf.json') as f: + conf_dict = json.load(f) + + if not 'portal_domain' in conf_dict: + conf_dict['portal_domain'] = main_domain + if not 'portal_path' in conf_dict: + conf_dict['portal_path'] = '/ynhsso/' + if not 'portal_port' in conf_dict: + conf_dict['portal_port'] = '443' + if not 'portal_scheme' in conf_dict: + conf_dict['portal_scheme'] = 'https' + if not 'additional_headers' in conf_dict: + conf_dict['additional_headers'] = { 'Auth-User': 'uid', 'Remote-User': 'uid', 'Name': 'cn', 'Email': 'mail' - }, - 'domains': domains, - 'skipped_urls': skipped_urls, - 'unprotected_urls': unprotected_urls, - 'users': users - } - + } + conf_dict['domains'] = domains + conf_dict['skipped_urls'] = skipped_urls + conf_dict['unprotected_urls'] = unprotected_urls + conf_dict['protected_urls'] = protected_urls + conf_dict['skipped_regex'] = skipped_regex + conf_dict['unprotected_regex'] = unprotected_regex + conf_dict['protected_regex'] = protected_regex + conf_dict['users'] = users + with open('/etc/ssowat/conf.json', 'wb') as f: json.dump(conf_dict, f) From 1fdc5e2d15665e2778b9d30480760d30b3856f4e Mon Sep 17 00:00:00 2001 From: abeudin Date: Tue, 11 Mar 2014 17:58:26 +0100 Subject: [PATCH 12/36] Update action_map.yml --- action_map.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/action_map.yml b/action_map.yml index 42568c7a..adfba131 100644 --- a/action_map.yml +++ b/action_map.yml @@ -855,6 +855,21 @@ tools: help: Subscribe domain to a DynDNS service action: store_true + ### tools_update() + update: + action_help: YunoHost update + api: POST /update + + ### tools_changelog() + changelog: + action_help: YunoHost changelog + api: POST /changelog + + ### tools_upgrade() + upgrade: + action_help: YunoHost upgrade + api: POST /upgrade + ############################# # Hook # From 292000ec541119988df17ff08891576fc62531db Mon Sep 17 00:00:00 2001 From: abeudin Date: Tue, 11 Mar 2014 17:59:18 +0100 Subject: [PATCH 13/36] Update yunohost_tools.py --- yunohost_tools.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/yunohost_tools.py b/yunohost_tools.py index 5fc68786..82ce4d19 100644 --- a/yunohost_tools.py +++ b/yunohost_tools.py @@ -262,3 +262,36 @@ def tools_postinstall(domain, password, dyndns=False): win_msg(_("YunoHost has been successfully configured")) +def tools_update(): + """ + Update distribution + + """ + + process = Popen("/usr/local/bin/checkupdate", stdout=PIPE) + stdout, stderr = process.communicate() + if process.returncode == 1: + win_msg( _("Not upgrade found")) + elif process.returncode == 2: + raise YunoHostError(17, _("Error during update")) + else: + return { "Update" : stdout.splitlines() } + +def tools_changelog(): + """ + Show Changelog + + """ + + + +def tools_upgrade(): + """ + Upgrade distribution + + """ + + if os.path.isfile('/tmp/update_status'): + os.system('at now -f /etc/yunohost/upgrade') + else: + raise YunoHostError(17, _("Launch update before upgrade")) From 6d8a89dcf89b1af562335eb0b5d2a75662ff112c Mon Sep 17 00:00:00 2001 From: abeudin Date: Tue, 11 Mar 2014 18:00:20 +0100 Subject: [PATCH 14/36] Update yunohost_tools.py --- yunohost_tools.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/yunohost_tools.py b/yunohost_tools.py index 82ce4d19..c3253af0 100644 --- a/yunohost_tools.py +++ b/yunohost_tools.py @@ -267,7 +267,6 @@ def tools_update(): Update distribution """ - process = Popen("/usr/local/bin/checkupdate", stdout=PIPE) stdout, stderr = process.communicate() if process.returncode == 1: @@ -282,7 +281,7 @@ def tools_changelog(): Show Changelog """ - + win_msg(_("TODO Show Changelog")) def tools_upgrade(): @@ -290,7 +289,6 @@ def tools_upgrade(): Upgrade distribution """ - if os.path.isfile('/tmp/update_status'): os.system('at now -f /etc/yunohost/upgrade') else: From f64a9bc3497cc2536805816038a930fc3885e73e Mon Sep 17 00:00:00 2001 From: abeudin Date: Tue, 11 Mar 2014 18:12:58 +0100 Subject: [PATCH 15/36] Create checkupdate --- checkupdate | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 checkupdate diff --git a/checkupdate b/checkupdate new file mode 100644 index 00000000..85a9d9d2 --- /dev/null +++ b/checkupdate @@ -0,0 +1,62 @@ +#!/bin/bash + +if [ -f /tmp/changelog ]; +then + rm /tmp/changelog +fi + +apt-get update -y > /dev/null 2>&1 +if [[ $? != 0 ]]; +then + exit 2 +else + echo OK > /tmp/update_status +fi + +# Set $DIRCACHE +eval `/usr/bin/apt-config shell DIRCACHE Dir::Cache` + + +# get the list of packages which are pending an upgrade +PKGNAMES=`/usr/bin/apt-get -q -y --ignore-hold --allow-unauthenticated -s dist-upgrade | \ + /bin/grep ^Inst | /usr/bin/cut -d\ -f2 | /usr/bin/sort` + +if [[ $PKGNAMES = "" ]]; +then + exit 1 +fi + +if [ -n "$PKGNAMES" ] ; then + + # do the upgrade downloads + /usr/bin/apt-get --ignore-hold -qq -d --allow-unauthenticated --force-yes dist-upgrade > /dev/null +fi + + +PKGPATH="/${DIRCACHE}archives/" +for PKG in $PKGNAMES ; do + VER=`LC_ALL=C /usr/bin/apt-cache policy $PKG |\ + /bin/grep Candidate: | /usr/bin/cut -f 4 -d \ ` + OLDVER=`LC_ALL=C /usr/bin/apt-cache policy $PKG |\ + /bin/grep Installed: | /usr/bin/cut -f 4 -d \ ` + VERFILE=`echo "$VER" | /bin/sed -e "s/:/%3a/g"` + if ls ${PKGPATH}${PKG}_${VERFILE}_*.deb >& /dev/null ; then + DEBS="$DEBS ${PKGPATH}${PKG}_${VERFILE}_*.deb" + fi + echo -e "$PKG $OLDVER -> $VER" +done + +MISSING_DEBS=`apt-get -y --ignore-hold --allow-unauthenticated --print-uris dist-upgrade \ + | grep "file:" \ + | sed "s/'file:\(.*\)' .*/\1/g"` + +DEBS=`echo $MISSING_DEBS $DEBS | /usr/bin/sort` + +if [[ $DEBS = "" ]]; +then + exit 3 +else + if [ -x /usr/bin/apt-listchanges ] ; then + /usr/bin/apt-listchanges --which=both -f text $DEBS > /tmp/changelog 2>/dev/null + fi +fi From 76b2809f08dd9c5647d83deccc66da299cabaa15 Mon Sep 17 00:00:00 2001 From: abeudin Date: Tue, 11 Mar 2014 18:15:39 +0100 Subject: [PATCH 16/36] Update yunohost_tools.py --- yunohost_tools.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/yunohost_tools.py b/yunohost_tools.py index c3253af0..df427938 100644 --- a/yunohost_tools.py +++ b/yunohost_tools.py @@ -276,12 +276,15 @@ def tools_update(): else: return { "Update" : stdout.splitlines() } + def tools_changelog(): """ Show Changelog """ - win_msg(_("TODO Show Changelog")) + with open('/tmp/changelog', 'r') as f: + read_data = f.read() + return { "Changelog" : read_data.splitlines() } def tools_upgrade(): From 7f8b1f601b188b11d9917a90f43da9e52ef92b78 Mon Sep 17 00:00:00 2001 From: abeudin Date: Tue, 11 Mar 2014 18:15:55 +0100 Subject: [PATCH 17/36] Update yunohost_tools.py --- yunohost_tools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yunohost_tools.py b/yunohost_tools.py index df427938..468c074c 100644 --- a/yunohost_tools.py +++ b/yunohost_tools.py @@ -267,7 +267,7 @@ def tools_update(): Update distribution """ - process = Popen("/usr/local/bin/checkupdate", stdout=PIPE) + process = Popen("./checkupdate", stdout=PIPE) stdout, stderr = process.communicate() if process.returncode == 1: win_msg( _("Not upgrade found")) From 0d814d2ea10f74c0b05ad545ce04a670b301bca4 Mon Sep 17 00:00:00 2001 From: abeudin Date: Tue, 11 Mar 2014 18:18:21 +0100 Subject: [PATCH 18/36] Update yunohost_tools.py --- yunohost_tools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yunohost_tools.py b/yunohost_tools.py index 468c074c..14bc4f5f 100644 --- a/yunohost_tools.py +++ b/yunohost_tools.py @@ -293,6 +293,6 @@ def tools_upgrade(): """ if os.path.isfile('/tmp/update_status'): - os.system('at now -f /etc/yunohost/upgrade') + os.system('at now -f /usr/share/pyshared/yunohost-cli/upgrade') else: raise YunoHostError(17, _("Launch update before upgrade")) From 6dbf50e77ef2e995fc77e249e9ba407cf3fff9a9 Mon Sep 17 00:00:00 2001 From: abeudin Date: Tue, 11 Mar 2014 18:18:48 +0100 Subject: [PATCH 19/36] Create upgrade --- upgrade | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 upgrade diff --git a/upgrade b/upgrade new file mode 100644 index 00000000..1a035218 --- /dev/null +++ b/upgrade @@ -0,0 +1,3 @@ +rm /tmp/update_status +sudo apt-get upgrade -y > /tmp/update_log 2>&1 +if [[ $? = 0 ]]; then echo "OK" > /tmp/upgrade_status; else echo "NOK" > /tmp/upgrade_status; fi From 034de511d3553b5cce141d2911a44b03ccab7f5a Mon Sep 17 00:00:00 2001 From: Adrien Beudin Date: Tue, 11 Mar 2014 18:23:58 +0100 Subject: [PATCH 20/36] add safe update --- checkupdate => bash/checkupdate | 0 upgrade => config/upgrade | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename checkupdate => bash/checkupdate (100%) rename upgrade => config/upgrade (100%) diff --git a/checkupdate b/bash/checkupdate similarity index 100% rename from checkupdate rename to bash/checkupdate diff --git a/upgrade b/config/upgrade similarity index 100% rename from upgrade rename to config/upgrade From e42ede89d46a82de772ab70984f62cb7a717069f Mon Sep 17 00:00:00 2001 From: abeudin Date: Tue, 11 Mar 2014 18:27:06 +0100 Subject: [PATCH 21/36] Update yunohost_tools.py --- yunohost_tools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yunohost_tools.py b/yunohost_tools.py index 14bc4f5f..134b9b8b 100644 --- a/yunohost_tools.py +++ b/yunohost_tools.py @@ -267,7 +267,7 @@ def tools_update(): Update distribution """ - process = Popen("./checkupdate", stdout=PIPE) + process = Popen("./bash/checkupdate", stdout=PIPE) stdout, stderr = process.communicate() if process.returncode == 1: win_msg( _("Not upgrade found")) From 706880f03c3336d9d6cf9852fe43b3ca27c1e092 Mon Sep 17 00:00:00 2001 From: abeudin Date: Wed, 12 Mar 2014 10:13:06 +0100 Subject: [PATCH 22/36] Update yunohost_tools.py --- yunohost_tools.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/yunohost_tools.py b/yunohost_tools.py index 134b9b8b..ebe67101 100644 --- a/yunohost_tools.py +++ b/yunohost_tools.py @@ -267,7 +267,7 @@ def tools_update(): Update distribution """ - process = Popen("./bash/checkupdate", stdout=PIPE) + process = Popen("/usr/bin/checkupdate", stdout=PIPE) stdout, stderr = process.communicate() if process.returncode == 1: win_msg( _("Not upgrade found")) @@ -293,6 +293,6 @@ def tools_upgrade(): """ if os.path.isfile('/tmp/update_status'): - os.system('at now -f /usr/share/pyshared/yunohost-cli/upgrade') + os.system('at now -f /etc/yunohost/upgrade') else: raise YunoHostError(17, _("Launch update before upgrade")) From c84406583ef1491dcf183c078e76dfe8885db540 Mon Sep 17 00:00:00 2001 From: abeudin Date: Thu, 13 Mar 2014 11:15:58 +0100 Subject: [PATCH 23/36] Update yunohost_tools.py --- yunohost_tools.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/yunohost_tools.py b/yunohost_tools.py index ebe67101..7c8c9a19 100644 --- a/yunohost_tools.py +++ b/yunohost_tools.py @@ -276,23 +276,28 @@ def tools_update(): else: return { "Update" : stdout.splitlines() } - def tools_changelog(): """ Show Changelog """ - with open('/tmp/changelog', 'r') as f: + with open('/tmp/yunohost/changelog', 'r') as f: read_data = f.read() return { "Changelog" : read_data.splitlines() } - def tools_upgrade(): """ Upgrade distribution """ - if os.path.isfile('/tmp/update_status'): + if os.path.isfile('/tmp/yunohost/update_status'): os.system('at now -f /etc/yunohost/upgrade') + with open('/tmp/yunohost/upgrade_status', 'r') as f: + read_data = f.read() + os.system('rm /tmp/yunohost/upgrade_status') + if read_data.strip() == "OK": + win_msg( _("YunoHost has been successfully upgraded")) + else: + raise YunoHostError(17, _("Error during upgrade")) else: raise YunoHostError(17, _("Launch update before upgrade")) From 4d7398622fe1893af4ab8a4d45a672205007a181 Mon Sep 17 00:00:00 2001 From: abeudin Date: Thu, 13 Mar 2014 11:17:01 +0100 Subject: [PATCH 24/36] Update checkupdate --- bash/checkupdate | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/bash/checkupdate b/bash/checkupdate index 85a9d9d2..30534bdf 100644 --- a/bash/checkupdate +++ b/bash/checkupdate @@ -1,8 +1,13 @@ #!/bin/bash -if [ -f /tmp/changelog ]; +if [ ! -d /tmp/yunohost ]; then - rm /tmp/changelog + mkdir /tmp/yunohost +fi + +if [ -f /tmp/yunohost/changelog ]; +then + rm /tmp/yunohost/changelog fi apt-get update -y > /dev/null 2>&1 @@ -10,7 +15,7 @@ if [[ $? != 0 ]]; then exit 2 else - echo OK > /tmp/update_status + echo OK > /tmp/yunohost/update_status fi # Set $DIRCACHE @@ -57,6 +62,6 @@ then exit 3 else if [ -x /usr/bin/apt-listchanges ] ; then - /usr/bin/apt-listchanges --which=both -f text $DEBS > /tmp/changelog 2>/dev/null + /usr/bin/apt-listchanges --which=both -f text $DEBS > /tmp/yunohost/changelog 2>/dev/null fi fi From 524489edaa106bcb92e315e857ce7c073d344b51 Mon Sep 17 00:00:00 2001 From: abeudin Date: Thu, 13 Mar 2014 12:04:37 +0100 Subject: [PATCH 25/36] Update yunohost_tools.py --- yunohost_tools.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/yunohost_tools.py b/yunohost_tools.py index 7c8c9a19..e9a695ea 100644 --- a/yunohost_tools.py +++ b/yunohost_tools.py @@ -281,9 +281,12 @@ def tools_changelog(): Show Changelog """ - with open('/tmp/yunohost/changelog', 'r') as f: - read_data = f.read() - return { "Changelog" : read_data.splitlines() } + if os.path.isfile('/tmp/yunohost/update_status'): + with open('/tmp/yunohost/changelog', 'r') as f: + read_data = f.read() + return { "Changelog" : read_data.splitlines() } + else: + raise YunoHostError(17, _("Launch update before upgrade")) def tools_upgrade(): """ From 6a9a8f082d1ec684c579698f23ffe92e272c589c Mon Sep 17 00:00:00 2001 From: abeudin Date: Thu, 13 Mar 2014 12:22:54 +0100 Subject: [PATCH 26/36] Update yunohost_tools.py --- yunohost_tools.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/yunohost_tools.py b/yunohost_tools.py index e9a695ea..36116de5 100644 --- a/yunohost_tools.py +++ b/yunohost_tools.py @@ -293,14 +293,17 @@ def tools_upgrade(): Upgrade distribution """ - if os.path.isfile('/tmp/yunohost/update_status'): - os.system('at now -f /etc/yunohost/upgrade') - with open('/tmp/yunohost/upgrade_status', 'r') as f: - read_data = f.read() - os.system('rm /tmp/yunohost/upgrade_status') - if read_data.strip() == "OK": - win_msg( _("YunoHost has been successfully upgraded")) - else: - raise YunoHostError(17, _("Error during upgrade")) + if os.path.isfile('/tmp/yunohost/upgrade.run'): + win_msg( _("Upgrade in progress")) else: - raise YunoHostError(17, _("Launch update before upgrade")) + if os.path.isfile('/tmp/yunohost/update_status'): + os.system('at now -f /etc/yunohost/upgrade') + with open('/tmp/yunohost/upgrade_status', 'r') as f: + read_data = f.read() + os.system('rm /tmp/yunohost/upgrade_status') + if read_data.strip() == "OK": + win_msg( _("YunoHost has been successfully upgraded")) + else: + raise YunoHostError(17, _("Error during upgrade")) + else: + raise YunoHostError(17, _("Launch update before upgrade")) From a2e02c56cff67d8f4100986ca85b23c72c9b2a1a Mon Sep 17 00:00:00 2001 From: abeudin Date: Thu, 13 Mar 2014 12:23:21 +0100 Subject: [PATCH 27/36] Update upgrade --- config/upgrade | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/config/upgrade b/config/upgrade index 1a035218..0d0323b0 100644 --- a/config/upgrade +++ b/config/upgrade @@ -1,3 +1,5 @@ -rm /tmp/update_status -sudo apt-get upgrade -y > /tmp/update_log 2>&1 -if [[ $? = 0 ]]; then echo "OK" > /tmp/upgrade_status; else echo "NOK" > /tmp/upgrade_status; fi +/bin/bash +rm /tmp/yunohost/update_status +sudo apt-get upgrade -y -s > /tmp/yunohost/update_log 2>&1 +if [ $(echo $?) = 0 ]; then echo "OK" > /tmp/yunohost/upgrade_status; else echo "NOK" > /tmp/yunohost/upgrade_status; fi +rm /tmp/yunohost/upgrade.run From 8fbfb57ffbeafd64c24911a3f74730ec4c31880f Mon Sep 17 00:00:00 2001 From: abeudin Date: Thu, 13 Mar 2014 12:37:51 +0100 Subject: [PATCH 28/36] Update yunohost_tools.py --- yunohost_tools.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/yunohost_tools.py b/yunohost_tools.py index 36116de5..0bf35932 100644 --- a/yunohost_tools.py +++ b/yunohost_tools.py @@ -275,6 +275,7 @@ def tools_update(): raise YunoHostError(17, _("Error during update")) else: return { "Update" : stdout.splitlines() } + def tools_changelog(): """ @@ -287,6 +288,7 @@ def tools_changelog(): return { "Changelog" : read_data.splitlines() } else: raise YunoHostError(17, _("Launch update before upgrade")) + def tools_upgrade(): """ @@ -296,8 +298,7 @@ def tools_upgrade(): if os.path.isfile('/tmp/yunohost/upgrade.run'): win_msg( _("Upgrade in progress")) else: - if os.path.isfile('/tmp/yunohost/update_status'): - os.system('at now -f /etc/yunohost/upgrade') + if os.path.isfile('/tmp/yunohost/upgrade_status'): with open('/tmp/yunohost/upgrade_status', 'r') as f: read_data = f.read() os.system('rm /tmp/yunohost/upgrade_status') @@ -305,5 +306,8 @@ def tools_upgrade(): win_msg( _("YunoHost has been successfully upgraded")) else: raise YunoHostError(17, _("Error during upgrade")) + elif os.path.isfile('/tmp/yunohost/update_status'): + os.system('at now -f /etc/yunohost/upgrade') + win_msg( _("Upgrade in progress")) else: raise YunoHostError(17, _("Launch update before upgrade")) From 34e03c437cb038668de9711fb949b7f8c14b1427 Mon Sep 17 00:00:00 2001 From: abeudin Date: Thu, 13 Mar 2014 12:45:28 +0100 Subject: [PATCH 29/36] Update action_map.yml --- action_map.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/action_map.yml b/action_map.yml index adfba131..0325ee30 100644 --- a/action_map.yml +++ b/action_map.yml @@ -869,6 +869,11 @@ tools: upgrade: action_help: YunoHost upgrade api: POST /upgrade + + ### tools_upgradelog() + upgradelog: + action_help: Show dpkg log + api: POST /upgradelog ############################# From f40f386add31b5f9c621c3ef72633abc72fee711 Mon Sep 17 00:00:00 2001 From: abeudin Date: Thu, 13 Mar 2014 12:46:08 +0100 Subject: [PATCH 30/36] Update yunohost_tools.py --- yunohost_tools.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/yunohost_tools.py b/yunohost_tools.py index 0bf35932..b831f9d0 100644 --- a/yunohost_tools.py +++ b/yunohost_tools.py @@ -311,3 +311,16 @@ def tools_upgrade(): win_msg( _("Upgrade in progress")) else: raise YunoHostError(17, _("Launch update before upgrade")) + + +def tools_upgradelog(): + """ + Show upgrade log + + """ + if os.path.isfile('/tmp/yunohost/upgrade.run'): + win_msg( _("Upgrade in progress")) + else: + with open('/tmp/yunohost/update_log', 'r') as f: + read_data = f.read() + return { "DPKG LOG" : read_data.splitlines() } From 9452c95dc692bebafa24031110a83d05f9ebb260 Mon Sep 17 00:00:00 2001 From: abeudin Date: Thu, 13 Mar 2014 16:18:55 +0100 Subject: [PATCH 31/36] Update yunohost_tools.py --- yunohost_tools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yunohost_tools.py b/yunohost_tools.py index b831f9d0..2f2fce6c 100644 --- a/yunohost_tools.py +++ b/yunohost_tools.py @@ -307,7 +307,7 @@ def tools_upgrade(): else: raise YunoHostError(17, _("Error during upgrade")) elif os.path.isfile('/tmp/yunohost/update_status'): - os.system('at now -f /etc/yunohost/upgrade') + os.system('at now -f /usr/share/yunohost/upgrade') win_msg( _("Upgrade in progress")) else: raise YunoHostError(17, _("Launch update before upgrade")) From 2604a2457fe8e007ec7033ebd7b00186a0127399 Mon Sep 17 00:00:00 2001 From: abeudin Date: Thu, 13 Mar 2014 20:57:04 +0100 Subject: [PATCH 32/36] Update yunohost_tools.py Add import subprocess --- yunohost_tools.py | 1 + 1 file changed, 1 insertion(+) diff --git a/yunohost_tools.py b/yunohost_tools.py index 2f2fce6c..8035ac90 100644 --- a/yunohost_tools.py +++ b/yunohost_tools.py @@ -31,6 +31,7 @@ import getpass import subprocess import requests import json +from subprocess import Popen, PIPE from yunohost import YunoHostError, YunoHostLDAP, validate, colorize, get_required_args, win_msg from yunohost_domain import domain_add, domain_list from yunohost_dyndns import dyndns_subscribe From 7135266452342ad8a7d8a75b5eb12a26b55df9d7 Mon Sep 17 00:00:00 2001 From: abeudin Date: Thu, 13 Mar 2014 21:06:38 +0100 Subject: [PATCH 33/36] Update upgrade remove simulate option --- config/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/upgrade b/config/upgrade index 0d0323b0..b8a81cce 100644 --- a/config/upgrade +++ b/config/upgrade @@ -1,5 +1,5 @@ /bin/bash rm /tmp/yunohost/update_status -sudo apt-get upgrade -y -s > /tmp/yunohost/update_log 2>&1 +sudo apt-get upgrade -y > /tmp/yunohost/update_log 2>&1 if [ $(echo $?) = 0 ]; then echo "OK" > /tmp/yunohost/upgrade_status; else echo "NOK" > /tmp/yunohost/upgrade_status; fi rm /tmp/yunohost/upgrade.run From c040956e4d116e56c5e6222d7c4c6218d6921c63 Mon Sep 17 00:00:00 2001 From: Jerome Lebleu Date: Fri, 14 Mar 2014 18:36:20 +0100 Subject: [PATCH 34/36] Fix #99 partly - awaiting something better --- yunohost_monitor.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/yunohost_monitor.py b/yunohost_monitor.py index 9875ae77..3256d26f 100644 --- a/yunohost_monitor.py +++ b/yunohost_monitor.py @@ -61,7 +61,19 @@ def monitor_disk(units=None, mountpoint=None, human_readable=False): # Get mounted block devices devices = {} - output = subprocess.check_output('lsblk -o NAME,MOUNTPOINT -l -n'.split()) + try: + output = subprocess.check_output('lsblk -o NAME,MOUNTPOINT -l -n'.split()) + except subprocess.CalledProcessError: + output = '' + + # Try to find at least root partition + if not output: + for p in psutil.disk_partitions(all=True): + if p.mountpoint == '/': + output = '%s /' % p.device.replace('/dev/', '') + break + + # Format results for d in output.split('\n'): m = re.search(r'([a-z]+[0-9]*)[ ]+(\/\S*)', d) # Extract device name (1) and its mountpoint (2) if m and (mountpoint is None or m.group(2) == mountpoint): From 34869a523d6eb45a4e6bf510afc44afbea1dc539 Mon Sep 17 00:00:00 2001 From: Alexis Gavoty Date: Wed, 19 Mar 2014 10:04:59 +0100 Subject: [PATCH 35/36] Update yunohost_firewall.py --- yunohost_firewall.py | 1 + 1 file changed, 1 insertion(+) diff --git a/yunohost_firewall.py b/yunohost_firewall.py index 13413111..78dee3b4 100644 --- a/yunohost_firewall.py +++ b/yunohost_firewall.py @@ -37,6 +37,7 @@ except ImportError: sys.stderr.write('apt-get install python-yaml\n') sys.exit(1) from yunohost import YunoHostError, win_msg +from yunohost_hook import hook_callback def firewall_allow(protocol=None, port=None, ipv6=None, upnp=False): From f175d48c276215f77d724ed2f80551960b893dcb Mon Sep 17 00:00:00 2001 From: Julien Malik Date: Thu, 20 Mar 2014 00:13:31 +0100 Subject: [PATCH 36/36] fetchlist makes cron verbose and send mails --- yunohost_app.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yunohost_app.py b/yunohost_app.py index 36074183..61a13e8d 100644 --- a/yunohost_app.py +++ b/yunohost_app.py @@ -66,8 +66,8 @@ def app_fetchlist(url=None, name=None): Fetch application list from app server Keyword argument: - name -- Name of the list (default fapp) - url -- URL of remote JSON list (default http://fapp.yunohost.org/app/list/raw) + name -- Name of the list (default yunohost) + url -- URL of remote JSON list (default http://app.yunohost.org/list.json) """ # Create app path if not exists @@ -89,7 +89,7 @@ def app_fetchlist(url=None, name=None): os.rename(list_file +'.tmp', list_file) os.system("touch /etc/cron.d/yunohost-applist-"+ name) - os.system("echo '00 00 * * * root yunohost app fetchlist -u "+ url +" -n "+ name +" --no-ldap >> /dev/null' >/etc/cron.d/yunohost-applist-"+ name) + os.system("echo '00 00 * * * root yunohost app fetchlist -u "+ url +" -n "+ name +" --no-ldap > /dev/null 2>&1' >/etc/cron.d/yunohost-applist-"+ name) win_msg(_("List successfully fetched"))