diff --git a/Makefile.am b/Makefile.am index f1dc47e..d687fd2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -88,7 +88,7 @@ memkind_pmtt_SOURCES = src/memkind_pmtt.c memkind_pmtt_LDADD = libmemkind.la EXTRA_DIST = autogen.sh \ - init.d/memkind \ + memkind.service \ gtest-1.7.0.zip \ examples/README \ test/check.sh \ diff --git a/init.d/memkind b/init.d/memkind deleted file mode 100755 index 4ef2f80..0000000 --- a/init.d/memkind +++ /dev/null @@ -1,137 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2014, 2015 Intel Corporation. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# 1. Redistributions of source code must retain the above copyright notice(s), -# this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright notice(s), -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY EXPRESS -# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO -# EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -# -# This shell script takes care creating and deleting accesible -# bandwidth files from PMTT tables -### BEGIN INIT INFO -# Provides: memkind -# Required-Start: -# Required-Stop: -# Short-Description: Sets up memkind library -# Description: Parses the PMTT table and creates the file /var/run/memkind/node-bandwidth. -# -# start - Create bandwidth file from PMTT table. -# -# stop - Delete bandwidth file from /var/run/memkind. -# -# restart - Delete and recreate bandwidth file from PMTT table. -# -# status - Print existance of bandwidth file -# Default-Start: 3 4 5 -# Default-Stop: 0 1 2 6 -### END INIT INFO - -if [ -s /etc/rc.status ]; then - . /etc/rc.status - echo_success() { - echo $1 - rc_failed 0 - rc_status -v1 - } - echo_failure() { - echo $1 - rc_failed 1 - rc_status -v1 - } -elif [ -s /etc/rc.d/init.d/functions ]; then - . /etc/rc.d/init.d/functions -else - echo_success() { - echo $1 - } - echo_failure() { - echo ERROR: $1 - } -fi - -err=0 -MEMKIND_FILE=/var/run/memkind/node-bandwidth -MEMKIND_DIR=`dirname $MEMKIND_FILE` -MEMKIND_BIN=/usr/sbin/memkind-pmtt - -start() { - echo_success "creating bandwidth values file" - if [ -f $MEMKIND_FILE ]; then - echo_success "bandwidth values file exists, atemptting to delete before - creation." - stop - fi - - if [ ! -f $MEMKIND_FILE ]; then - $MEMKIND_BIN - err=$? - if [ $err -eq 0 ] && [ -f $MEMKIND_FILE ] - then - echo_success "created file: $MEMKIND_FILE" - else - echo_failure "could not create file: $MEMKIND_FILE" - fi - fi -} - -stop() { - echo_success "deleting bandwidth values file" - rm -f $MEMKIND_FILE - err=$? - if [ $err -eq 0 ] && [ ! -f $MEMKIND_FILE ] - then - echo_success "deleted file: $MEMKIND_FILE" - else - echo_failure "could not delete file: $MEMKIND_FILE" - fi -} - -restart() { - if [ -f $MEMKIND_FILE ]; then - stop - fi - start -} - -case $1 in - start) - start - ;; - stop) - stop - ;; - restart|force-reload|reload|condrestart|try-restart) - restart - ;; - status) - if [ -f $MEMKIND_FILE ]; - then - echo_success "file $MEMKIND_FILE exists" - err=0 - else - echo_failure "file $MEMKIND_FILE does not exist" - err=3 - fi - ;; - *) - echo "Usage: $0 {start|stop|restart|status|force-reload|reload|condrestart|try-restart}" - err=2 -esac -exit $err diff --git a/memkind.service b/memkind.service new file mode 100644 index 0000000..4fcc39d --- /dev/null +++ b/memkind.service @@ -0,0 +1,35 @@ +# +# Copyright (C) 2014, 2015 Intel Corporation. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# 1. Redistributions of source code must retain the above copyright notice(s), +# this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright notice(s), +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY EXPRESS +# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +# EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +[Unit] +Description=Service which parses PMTT table for memkind + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/usr/sbin/memkind-pmtt +ExecStop=/usr/bin/rm -f /var/run/memkind/node-bandwidth + +[Install] +WantedBy=multi-user.target