Browse Source

Added requirements, setup and sample config

Óscar García Amor 4 years ago
parent
commit
2e3344d7d2
4 changed files with 103 additions and 1 deletions
  1. 2 0
      requirements.txt
  2. 53 0
      setup.py
  3. 40 0
      sysdweb.conf
  4. 8 1
      sysdweb/main.py

+ 2 - 0
requirements.txt

@@ -0,0 +1,2 @@
+bottle >= 0.12.10
+dbus-python >= 1.2.4

+ 53 - 0
setup.py

@@ -0,0 +1,53 @@
+#! /usr/bin/env python
+# -*- coding: utf-8 -*-
+# vim:fenc=utf-8
+#
+# Copyright © 2016 Óscar García Amor <ogarcia@connectical.com>
+#
+# Distributed under terms of the GNU GPLv3 license.
+
+import os
+from setuptools import setup
+
+# Utility function to read the README file.
+# Used for the long_description.  It's nice, because now 1) we have a top level
+# README file and 2) it's easier to type in the README file than to put a raw
+# string in below ...
+def read(fname):
+    return open(os.path.join(os.path.dirname(__file__), fname)).read()
+
+setup(
+    name = "sysdweb",
+    version = "0.1",
+    author = "Oscar Garcia Amor",
+    author_email = "ogarcia@connectical.com",
+    description = ("Control systemd services through Web or REST API"),
+    license = "GPLv3",
+    keywords = "systemd web api easy",
+    url = "https://github.com/ogarcia/sysdweb",
+    packages=['sysdweb'],
+    long_description=read('README.md'),
+    package_data={'sysdweb': [
+            'templates/static/css/*',
+            'templates/static/fonts/*',
+            'templates/static/img/*',
+            'templates/static/js/*',
+            'templates/views/*'
+        ]
+    },
+    entry_points={
+        'console_scripts': [
+            'sysdweb = sysdweb.main:main'
+        ]
+    },
+    install_requires = [
+        "bottle>=0.12.10",
+        "dbus-python>=1.2.4"
+    ],
+    classifiers=[
+        "Development Status :: 3 - Alpha",
+        "Topic :: Utilities",
+        "License :: OSI Approved :: GNU General Public License (GPLv3)",
+        'Programming Language :: Python :: 3',
+    ],
+)

+ 40 - 0
sysdweb.conf

@@ -0,0 +1,40 @@
+# sysdweb sample config file
+#
+# This file is defined as standard ini file and must be at least one entry.
+#
+# Entries consist of:
+# - [label]. It maches with URL /api/v1/<label>.
+# - title. Custom description of service for page
+# - unit. systemd unit name (with or without .service)
+# All entries are mandatory
+#
+# Samples.
+# [ngx]
+# title = Nginx
+# unit = nginx.service
+#
+# [nm]
+# title = Network Manager
+# unit = NetworkManager
+
+[DEFAULT]
+# You can set scope here, it can be.
+# - system. for control systemd system units (sysdweb must be run as root),
+#           this is default if scope not is defined
+# - user. for control systemd user units
+scope = system
+
+# Some sample entries
+[ngx]
+title = Nginx
+unit = nginx.service
+
+[nm]
+title = Network Manager
+unit = NetworkManager
+# .service is optional
+
+[sysdweb]
+# Yes, can control sysdweb too!
+title = sysdweb
+unit = sysdweb.service

+ 8 - 1
sysdweb/main.py

@@ -8,5 +8,12 @@
 
 from sysdweb.server import run
 
+import argparse
+
 def main():
-    run(host='127.0.0.1', port='8090')
+    parser = argparse.ArgumentParser()
+    parser.add_argument('-l', '--listen', metavar='host or ip', default='0.0.0.0', help='listen address, default: 0.0.0.0')
+    parser.add_argument('-p', '--port', metavar='port', default='10080', help='listen port, default: 10080')
+    args = parser.parse_args()
+
+    run(host=args.listen, port=args.port)