diff options
author | James Meyer <james.meyer@operamail.com> | 2011-12-07 19:26:35 (GMT) |
---|---|---|
committer | James Meyer <james.meyer@operamail.com> | 2011-12-07 19:26:35 (GMT) |
commit | 8f9766814d4ac032887c160cd98528c531a97067 (patch) | |
tree | 94a7e722f5ca7f1ebd7f3f374f94e9c7e434cea3 /abs/core | |
parent | 46710e350b11efbb36ab455d07f8248bfec2d620 (diff) | |
download | linhes_pkgbuild-8f9766814d4ac032887c160cd98528c531a97067.zip linhes_pkgbuild-8f9766814d4ac032887c160cd98528c531a97067.tar.gz linhes_pkgbuild-8f9766814d4ac032887c160cd98528c531a97067.tar.bz2 |
func: first build
Used by the backend to issue commands on any given system of the cluster.
Diffstat (limited to 'abs/core')
-rw-r--r-- | abs/core/func/PKGBUILD | 44 | ||||
-rw-r--r-- | abs/core/func/failed_func.sh | 19 | ||||
-rw-r--r-- | abs/core/func/fe_restart.py | 35 | ||||
-rw-r--r-- | abs/core/func/func-0.24.tar.gz | bin | 0 -> 130319 bytes | |||
-rw-r--r-- | abs/core/func/func-0.25.tar.gz | bin | 0 -> 152871 bytes | |||
-rw-r--r-- | abs/core/func/func.install | 56 | ||||
-rw-r--r-- | abs/core/func/minion.conf | 8 | ||||
-rw-r--r-- | abs/core/func/msg.cfg | 6 | ||||
-rw-r--r-- | abs/core/func/msg.py | 135 | ||||
-rw-r--r-- | abs/core/func/pacman.py | 36 | ||||
-rw-r--r-- | abs/core/func/power.py | 35 |
11 files changed, 374 insertions, 0 deletions
diff --git a/abs/core/func/PKGBUILD b/abs/core/func/PKGBUILD new file mode 100644 index 0000000..b406ab0 --- /dev/null +++ b/abs/core/func/PKGBUILD @@ -0,0 +1,44 @@ +pkgname=func +pkgver=0.25 +pkgrel=1 +pkgdesc="fedora unifed network controller" +url="" +license="gpl" +depends=(pyopenssl certmaster python_aosd) +makedepends=() +conflicts=() +replaces=() +backup=() +moddir="pkg/usr/lib/python2.6/site-packages/func/minion/modules/" +install=func.install +source=($pkgname-$pkgver.tar.gz minion.conf power.py pacman.py failed_func.sh fe_restart.py msg.py msg.cfg) +arch=('i686') + +build() { + cd $startdir/src/$pkgname-${pkgver} + python setup.py build + python setup.py install --prefix=$startdir/pkg/usr + cd $startdir/src + install -m755 -D minion.conf $startdir/pkg/etc/func/minion.conf + install -m755 -D $startdir/src/$pkgname-$pkgver/etc/async_methods.conf $startdir/pkg/etc/func/async_methods.conf + install -m755 -D $startdir/src/$pkgname-${pkgver}/etc/sample.acl $startdir/pkg/etc/func/minion-acl.d/sample.acl + install -m755 -D $startdir/src/$pkgname-${pkgver}/etc/Test.conf $startdir/pkg/etc/func/modules/Test.conf + install -m755 -D $startdir/src/power.py ${startdir}/${moddir}/power.py + install -m755 -D $startdir/src/pacman.py ${startdir}/${moddir}/pacman.py + install -m755 -D $startdir/src/msg.py ${startdir}/${moddir}/msg.py + install -m755 -D $startdir/src/msg.cfg ${startdir}/pkg/usr/MythVantage/etc/msg.cfg + install -m755 -D $startdir/src/fe_restart.py ${startdir}/${moddir}/fe_restart.py + install -m755 -D $startdir/src/failed_func.sh $startdir/pkg/usr/MythVantage/bin/failed_func.sh + mkdir -p $startdir/pkg/var/log/func + + cd $startdir/pkg + find ./ -name "*.pyc" -print | xargs rm -f +} +md5sums=('892252004f122c61bb58bb4607553ffe' + '1e2905074203d5c0557f143a6c50c497' + '1393088fa64823606e0b1c02296041f4' + '65a602524cb85773740840eaa513ce15' + 'f31e494ddc23eb8079650f6c6bae7861' + 'b02a733b7a74569e57521bc3708724a5' + '572bb6737cb03dee7e9d11ed40481bd2' + '4f189262b2a686c5ac9485c6e5134045') diff --git a/abs/core/func/failed_func.sh b/abs/core/func/failed_func.sh new file mode 100644 index 0000000..519265e --- /dev/null +++ b/abs/core/func/failed_func.sh @@ -0,0 +1,19 @@ +. /etc/profile +. /etc/systemconfig + +if [ x$SystemType = "xMaster_backend" -o x$SystemType = "xStandAlone" ] +then + exit 0 +fi +curl -# http://$dbhost/failed_func_hosts|grep -q `hostname` +status=$? +if [ $status = 0 ] +then + echo "removing ca (failed_func.sh)" + rm -f /etc/pki/func/* + echo "restarting func" + sv stop funcd + sleep 3 + sv start funcd +fi + diff --git a/abs/core/func/fe_restart.py b/abs/core/func/fe_restart.py new file mode 100644 index 0000000..a75b0c5 --- /dev/null +++ b/abs/core/func/fe_restart.py @@ -0,0 +1,35 @@ +## +# other modules +import sub_process + +# our modules +import func_module + +# ================================= + +class re_restart(func_module.FuncModule): + + version = "0.0.1" + api_version = "0.0.1" + description = "Restart the frontend" + + def killX (self,flags="restart frontend"): + """ + Restart X + """ + flags.replace(";","") # prevent stupidity + cmd = sub_process.Popen("/sbin/sv %s " % flags,stdout=sub_process.PIPE,shell=True) + data = cmd.communicate()[0] + results = ['Restarted UI'] + return (cmd.returncode, results) + + def killmyth (self,flags="-9 mythfrontend"): + """ + kill the mythfrontend process server + """ + flags.replace(";","") # prevent stupidity + cmd = sub_process.Popen("/usr/bin/killall %s" % flags,stdout=sub_process.PIPE,shell=True) + data = cmd.communicate()[0] + results = ['killed mythfrontend'] + return (cmd.returncode, results) + diff --git a/abs/core/func/func-0.24.tar.gz b/abs/core/func/func-0.24.tar.gz Binary files differnew file mode 100644 index 0000000..baa8eef --- /dev/null +++ b/abs/core/func/func-0.24.tar.gz diff --git a/abs/core/func/func-0.25.tar.gz b/abs/core/func/func-0.25.tar.gz Binary files differnew file mode 100644 index 0000000..381e0b6 --- /dev/null +++ b/abs/core/func/func-0.25.tar.gz diff --git a/abs/core/func/func.install b/abs/core/func/func.install new file mode 100644 index 0000000..1fcf6b1 --- /dev/null +++ b/abs/core/func/func.install @@ -0,0 +1,56 @@ +# This is a default template for a post-install scriptlet. You can +# remove any functions you don't need (and this header). + +# arg 1: the new package version +pre_install() { +/bin/true +mkdir -p /var/log/func +} + +# arg 1: the new package version +post_install() { + if [ ! -e /etc/cron.tenminutes ] + then + mkdir /etc/cron.tenminutes + fi + if [ ! -e /etc/cron.tenminutes/failed_func ] + then + ln -s /usr/MythVantage/bin/failed_func.sh /etc/cron.tenminutes/failed_func + fi + + if [ ! -e /var/log/func ] + then + mkdir -p /var/log/func + fi + + +} + +# arg 1: the new package version +# arg 2: the old package version +pre_upgrade() { + /bin/true + + + +} + +# arg 1: the new package version +# arg 2: the old package version +post_upgrade() { + post_install +} + +# arg 1: the old package version +pre_remove() { + /bin/true +} + +# arg 1: the old package version +post_remove() { + /bin/true +} + +op=$1 +shift +$op $* diff --git a/abs/core/func/minion.conf b/abs/core/func/minion.conf new file mode 100644 index 0000000..d1665f1 --- /dev/null +++ b/abs/core/func/minion.conf @@ -0,0 +1,8 @@ +[main] +log_level = INFO +acl_dir = /etc/func/minion-acl.d + +listen_addr = +listen_port = 51234 +minion_name = + diff --git a/abs/core/func/msg.cfg b/abs/core/func/msg.cfg new file mode 100644 index 0000000..b6de8b5 --- /dev/null +++ b/abs/core/func/msg.cfg @@ -0,0 +1,6 @@ +[default] +font_color=green +display_time=5000 +position=5 +font_type=Times New Roman Italic 48 + diff --git a/abs/core/func/msg.py b/abs/core/func/msg.py new file mode 100644 index 0000000..43214f3 --- /dev/null +++ b/abs/core/func/msg.py @@ -0,0 +1,135 @@ +## +# other modules +import sub_process +import sys +import aosd +import ConfigParser + + +# our modules +import func_module + + +# ================================= + +class msg(func_module.FuncModule): + + version = "0.0.1" + api_version = "0.0.1" + description = "Display messages" + +#class msg(): + def scroll(self,osd, width, height, display_time,position): + pos = position + step = 1 + + osd.set_position(pos, width, height) + (x, y, _, _) = osd.get_geometry() + osd.set_position_offset(width, height) + osd.show() + + x -= 1 + y += height - 1; + for i in range(1, height + 1, step): + osd.loop_for(5) + y -= step + osd.set_geometry(x, y, width, i) + + osd.set_position(pos, width, height) + osd.set_position_offset(-1, -1) + (x, y, _, _) = osd.get_geometry() + #time to display + osd.loop_for(display_time) + + for i in range(height, 0, -step): + y += step + osd.set_geometry(x, y, width, i); + osd.loop_for(1); + + osd.hide(); + + def setup(self,font_color,font_type): + osd = aosd.AosdText() + osd.set_transparency(aosd.TRANSPARENCY_COMPOSITE) + if osd.get_transparency() != aosd.TRANSPARENCY_COMPOSITE: + osd.set_transparency(aosd.TRANSPARENCY_NONE) + + osd.geom_x_offset = 10 + osd.geom_y_offset = 0 + + osd.back_color = "white" + osd.back_opacity = 50 + + osd.shadow_color = "black" + osd.shadow_opacity = 127 + osd.shadow_x_offset = 2 + osd.shadow_y_offset = 2 + + osd.fore_color = font_color + osd.fore_opacity = 255 + + osd.set_font(font_type) + osd.wrap = aosd.PANGO_WRAP_WORD_CHAR + osd.alignment = aosd.PANGO_ALIGN_LEFT + osd.set_layout_width(osd.get_screen_wrap_width()) + return osd + + def set_string(self, osd, text): + osd.set_text(text) + return osd.get_text_size() + + def setup_config(self): + module_config = ConfigParser.RawConfigParser() + try: + module_config.read('/usr/MythVantage/etc/msg.cfg') + except: + pass + return module_config + + + + def display (self,flags): + """ + parse the msg for display. + """ + try: + text,config_section=flags.split("|") + if config_section == '': + config_section="default" + except: + text=flags + config_section="default" + + module_config = self.setup_config() + + display_time=5000 + position=6 + font_color="green" + font_type="Times New Roman Italic 36" + try: + display_time = int(module_config.get(config_section,"display_time")) + except: + pass + try: + position = int(module_config.get(config_section,"position")) + except: + pass + try: + font_color = module_config.get(config_section,"font_color") + except: + pass + try: + font_type = module_config.get(config_section,"font_type") + except: + pass + + + cmd = sub_process.Popen("/usr/bin/wall %s" % text,stdout=sub_process.PIPE,shell=True) + data = cmd.communicate()[0] + osd = self.setup(font_color, font_type) + width, height = self.set_string(osd, text) + self.scroll(osd, width, height, display_time, position) + + return ("Message delivered") + + diff --git a/abs/core/func/pacman.py b/abs/core/func/pacman.py new file mode 100644 index 0000000..c8f2e13 --- /dev/null +++ b/abs/core/func/pacman.py @@ -0,0 +1,36 @@ +#!/usr/bin/python + + +# other modules +import sub_process + +# our modules +import func_module + +# ================================= + +class pacman(func_module.FuncModule): + version = "0.0.1" + api_version = "0.0.1" + description = "update the server" + + + def update_system(self,flags): + flags.replace(";","") # prevent stupidity + cmd = sub_process.Popen("/usr/bin/update_system %s" % flags,stdout=sub_process.PIPE,shell=True) + data = cmd.communicate()[0] + results = [] + for x in data.split("\n"): + results.append(x) + return (cmd.returncode, results) + + def pkgversion(self,flags): + flags.replace(";","") # prevent stupidity + cmd = sub_process.Popen("/usr/bin/pacman -Q %s | grep -v error" % flags,stdout=sub_process.PIPE,shell=True) + data = cmd.communicate()[0] + results = [] + for x in data.split("\n"): + results.append(x) + return (cmd.returncode, results) + + diff --git a/abs/core/func/power.py b/abs/core/func/power.py new file mode 100644 index 0000000..668965a --- /dev/null +++ b/abs/core/func/power.py @@ -0,0 +1,35 @@ +## +# other modules +import sub_process + +# our modules +import func_module + +# ================================= + +class power(func_module.FuncModule): + + version = "0.0.1" + api_version = "0.0.1" + description = "Reboot the server" + + def reboot(self,flags="-q onecheck"): + """ + Reboot the server + """ + flags.replace(";","") # prevent stupidity + cmd = sub_process.Popen("/sbin/reboot") + data = cmd.communicate()[0] + results = ['reboot'] + return (cmd.returncode, results) + + def poweroff (self,flags="-q onecheck"): + """ + Reboot the server + """ + flags.replace(";","") # prevent stupidity + cmd = sub_process.Popen("/sbin/poweroff") + data = cmd.communicate()[0] + results = ['off'] + return (cmd.returncode, results) + |