diff --git a/debian/postinst b/debian/postinst new file mode 100644 index 0000000..2cedb78 --- /dev/null +++ b/debian/postinst @@ -0,0 +1,29 @@ +#!/bin/sh +# postinst script for ahenk +# +# see: dh_installdeb(1) + +set -e + + +case "$1" in + configure) + + systemctl --system daemon-reload + systemctl enable ahenk.service + + update-rc.d ahenk defaults + /etc/init.d/ahenk start + + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +exit 0 diff --git a/etc/init.d/ahenk b/etc/init.d/ahenk new file mode 100644 index 0000000..15d1417 --- /dev/null +++ b/etc/init.d/ahenk @@ -0,0 +1,45 @@ +#! /bin/bash +### BEGIN INIT INFO +# Provides: ahenk +# Required-Start: $remote_fs $syslog $network +# Required-Stop: $remote_fs $syslog $network +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Manages ahenk service. +# Description: Debian init script for the ahenk executables +# scheduler +### END INIT INFO +# +# Author: S Suleyman Arslan +# + +# Activate the python virtual environment +# . /path_to_virtualenv/activate +case "$1" in + start) + echo "Starting server" + # Start the daemon + #python $AHENKDPATH start + systemctl start ahenk.service + ;; + stop) + echo "Stopping server" + systemctl stop ahenk.service + ;; + restart) + echo "Restarting server" + systemctl restart ahenk.service + ;; + status) + echo "Server Status" + # Status of the daemon + systemctl status ahenk.service + ;; + *) + # Refuse to do other stuff + echo "Usage: /etc/init.d/ahenk.sh {start|stop|restart|status}" + exit 1 + ;; +esac + +exit 0 \ No newline at end of file diff --git a/lib/systemd/system/ahenk.service b/lib/systemd/system/ahenk.service new file mode 100644 index 0000000..4efe333 --- /dev/null +++ b/lib/systemd/system/ahenk.service @@ -0,0 +1,12 @@ +[Unit] +Description=Starts Ahenk at system startup +After=network.target + +[Service] +Type=forking +ExecStart=python "/opt/ahenk/ahenkd.py start" +ExecStop=python "/opt/ahenk/ahenkd.py stop" +PIDFile=/var/run/ahenkd.pid + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/opt/ahenk/ahenkd.py b/opt/ahenk/ahenkd.py new file mode 100644 index 0000000..e69de29 diff --git a/opt/ahenk/api/service/ps_util.py b/opt/ahenk/api/service/ps_util.py new file mode 100644 index 0000000..2f25859 --- /dev/null +++ b/opt/ahenk/api/service/ps_util.py @@ -0,0 +1,7 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Author: İsmail BAŞARAN +import psutil + +if __name__ == '__main__': + diff --git a/opt/ahenk/base/plugin/AbstractPlugin.py b/opt/ahenk/base/plugin/AbstractPlugin.py new file mode 100644 index 0000000..526a676 --- /dev/null +++ b/opt/ahenk/base/plugin/AbstractPlugin.py @@ -0,0 +1,34 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Author: İsmail BAŞARAN +import imp,os +""" + class AbstractPlugin(object): + This is base class for plugins + def __init__(self, arg): + super(AbstrackPlugin, self).__init__() + self.arg = arg +""" +pluginFolder = '/home/ismail/devzone/workspace/LiderAhenk/ahenk/opt/ahenk/plugins' +mainModule = 'main' + +def getPlugins(): + plugins = [] + possibleplugins = os.listdir(pluginFolder) + for i in possibleplugins: + location = os.path.join(pluginFolder, i) + if not os.path.isdir(location) or not mainModule + ".py" in os.listdir(location): + continue + info = imp.find_module(mainModule, [location]) + plugins.append({"name": i, "info": info}) + return plugins + +def loadPlugin(plugin): + return imp.load_module(mainModule, *plugin["info"]) + + +if __name__ == '__main__': + for i in getPlugins(): + print("Loading plugin " + i["name"]) + plugin = loadPlugin(i) + plugin.run("tabisi") diff --git a/opt/ahenk/plugins/plugin1/main.py b/opt/ahenk/plugins/plugin1/main.py new file mode 100644 index 0000000..d01e893 --- /dev/null +++ b/opt/ahenk/plugins/plugin1/main.py @@ -0,0 +1,8 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Author: İsmail BAŞARAN + + + +def run(val): + print "oo yeah plugin1 " + str(val) diff --git a/opt/ahenk/plugins/plugin1/main.pyc b/opt/ahenk/plugins/plugin1/main.pyc new file mode 100644 index 0000000..fe32482 Binary files /dev/null and b/opt/ahenk/plugins/plugin1/main.pyc differ diff --git a/opt/ahenk/plugins/plugin2/main.py b/opt/ahenk/plugins/plugin2/main.py new file mode 100644 index 0000000..0465cf4 --- /dev/null +++ b/opt/ahenk/plugins/plugin2/main.py @@ -0,0 +1,6 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Author: İsmail BAŞARAN + +def run(val): + print "oo yeah plugin2 " + str(val) diff --git a/opt/ahenk/plugins/plugin2/main.pyc b/opt/ahenk/plugins/plugin2/main.pyc new file mode 100644 index 0000000..72d90e8 Binary files /dev/null and b/opt/ahenk/plugins/plugin2/main.pyc differ