Esempio n. 1
0
def service_action(name=None, action=None):

    if action == "favorite":
        return _service_favorite(name)

    if action not in config.SERVICE_VALID_ACTIONS:
        return "Error! Invalid action!"

    if name not in helpers._execute("ls /etc/init.d/"):
        return "Error! Service not found!"

    result = helpers._execute("sudo %s/scripts/exec.sh service %s %s" % (config.ROOT, name, action))
    return result if result else "No information returned"
Esempio n. 2
0
def services():
    filter_favorites = request.params.get('filter_favorites') == "true"
    helpers.current_tab("services")
    if config.SERVICE_EXECUTION:
        services = helpers._execute("ls /etc/init.d/")
        services = filter(bool, services.split('\n'))
        favorite_services = config.SERVICES_FAVORITES
        if filter_favorites:
            services = favorite_services
    else:
        services, favorite_services = [], []
    return template('services', services=services, favorite_services=favorite_services,
                                filter_favorites=filter_favorites)