summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorDhaval Giani <dhaval@linux.vnet.ibm.com>2009-03-26 20:53:17 +0530
committerDhaval Giani <dhaval@linux.vnet.ibm.com>2009-03-26 20:53:17 +0530
commitbd7e85ee1a7a794c6c447d64306b6df7f1d84eec (patch)
treeaab9de4f611b5a9d9c22ca497d72a10667fb4461 /scripts
parent04bb98f8bd9751dd8a514b0e3a6c4862ceabeae9 (diff)
parentde11c7f7bb8a79c86e680d169ed414471e5ef7d2 (diff)
downloadlibcg-bd7e85ee1a7a794c6c447d64306b6df7f1d84eec.tar.gz
libcg-bd7e85ee1a7a794c6c447d64306b6df7f1d84eec.tar.xz
libcg-bd7e85ee1a7a794c6c447d64306b6df7f1d84eec.zip
Merge branch 'automake' of git://fedorapeople.org/~jsafrane/libcg
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Makefile.am1
-rw-r--r--scripts/Makefile.in327
-rw-r--r--scripts/README4
-rw-r--r--scripts/doc/howto.txt76
-rw-r--r--scripts/etc/cgconfig.conf18
-rw-r--r--scripts/etc/cgconfig/cpu.conf14
-rw-r--r--scripts/etc/cgconfig/cpuacct.conf14
-rw-r--r--scripts/etc/wlm.conf16
-rw-r--r--scripts/etc/wlm/cpu.conf14
-rw-r--r--scripts/etc/wlm/cpuacct.conf14
-rwxr-xr-xscripts/init.d/wlm288
11 files changed, 328 insertions, 458 deletions
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
new file mode 100644
index 0000000..b5270fb
--- /dev/null
+++ b/scripts/Makefile.am
@@ -0,0 +1 @@
+EXTRA_DIST = init.d/cgconfig init.d/cgred
diff --git a/scripts/Makefile.in b/scripts/Makefile.in
new file mode 100644
index 0000000..adf93e6
--- /dev/null
+++ b/scripts/Makefile.in
@@ -0,0 +1,327 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = scripts
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+SOURCES =
+DIST_SOURCES =
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBOBJS = @LIBOBJS@
+LIBRARY_VERSION = @LIBRARY_VERSION@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+EXTRA_DIST = init.d/cgconfig init.d/cgred
+all: all-am
+
+.SUFFIXES:
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu scripts/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --gnu scripts/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+tags: TAGS
+TAGS:
+
+ctags: CTAGS
+CTAGS:
+
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+ -rm -f Makefile
+distclean-am: clean-am distclean-generic
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: all all-am check check-am clean clean-generic clean-libtool \
+ distclean distclean-generic distclean-libtool distdir dvi \
+ dvi-am html html-am info info-am install install-am \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-html install-html-am \
+ install-info install-info-am install-man install-pdf \
+ install-pdf-am install-ps install-ps-am install-strip \
+ installcheck installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-generic \
+ mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/scripts/README b/scripts/README
deleted file mode 100644
index 8007b60..0000000
--- a/scripts/README
+++ /dev/null
@@ -1,4 +0,0 @@
-NOTE: These are temporary intermediate scripts, till libcg is up and running
-on its own. The current parser works, but has a lot of band-aid around it.
-We need a good cleanroom implementation of the parser. Doing so, would
-enable us to build a good daemon and a set of init scripts around it.
diff --git a/scripts/doc/howto.txt b/scripts/doc/howto.txt
deleted file mode 100644
index d72994a..0000000
--- a/scripts/doc/howto.txt
+++ /dev/null
@@ -1,76 +0,0 @@
-initscripts - Initialization scripts; they are used to initialize the workload
-management system. The script consists of two major components
-
-Configuration files
--------------------
-
-The main configuraiton file /etc/cgconfig.conf. This file has a format
-
-mount <mountpoint> <list of controllers>
-<controller> <controller configuration file>
-
-A sample configuration file is included below
-
-#
-# controller file
-#
-mount /container cpu
-cpu /etc/cgconfig/cpu.conf
-
-NOTE: Any line beginning with '#' is ignored as comments. The sample
-configuration above, mounts the cpu controller at mount point /container.
-It then parses /etc/cgconfig/cpu.conf as the configuration file for the
-cpu controller.
-
-The controller configuration file is of the format
-
-<name of the class> <options>
-
-In the case of the CPU controller a sample configuration would look
-like
-
-class1 cpu.shares=1024
-class2 cpu.shares=512
-
-The configuration below creates two classes class1 and class2 and
-assigns shares of 1024 to class1 and 512 to class1.
-
-The other options that can be specified are
-
-tuid = owner of the tasks file
-tgid = group permissions of the tasks file
-cuid = owner of the newly created node
-cgid = group permissions of the newly created node
-
-Example
-
-class1 cpu.shares = 1024 tuid=root tgid=root cuid=database cgid=database.
-
-By default all these files are owned by root. The flexibilty of specifying
-owners makes it easier for other applications to use resource management.
-
-Intialization script
---------------------
-
-The initialization script is installed in /etc/init.d, it is called
-"cgconfig". Depending on the run-level, it is installed in the appropriate
-/etc/rc.d/rc<N>.d. The script comes with two options
-
-a. start
-
-start, starts the workload management, parses the configuration file.
-If required creates the mount point directory and then mounts the
-cgroup filesystem with the controllers specified.
-
-b. stop
-
-stops workload management, moves all tasks from various groups to
-the root class. It then removes all other classes and then unmounts
-the workload management system.
-
-Assumptions
------------
-
-1. The kernel is compiled in with the correct options to support
- cgroups and the CPU controller.
-2. This version has been tested with 2.6.25 only.
diff --git a/scripts/etc/cgconfig.conf b/scripts/etc/cgconfig.conf
deleted file mode 100644
index 43f9004..0000000
--- a/scripts/etc/cgconfig.conf
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# Copyright IBM Corporation. 2008
-#
-# Authors: Balbir Singh <balbir@linux.vnet.ibm.com>
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of version 2.1 of the GNU Lesser General Public License
-# as published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it would be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-#
-# controller file
-#
-mount /tmp/cpu cpu
-mount /tmp/cpuacct cpuacct
-cpu /etc/wlm/cpu.conf
-cpuacct /etc/wlm/cpuacct.conf
diff --git a/scripts/etc/cgconfig/cpu.conf b/scripts/etc/cgconfig/cpu.conf
deleted file mode 100644
index 7e76dea..0000000
--- a/scripts/etc/cgconfig/cpu.conf
+++ /dev/null
@@ -1,14 +0,0 @@
-#
-# Copyright IBM Corporation. 2008
-#
-# Authors: Balbir Singh <balbir@linux.vnet.ibm.com>
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of version 2.1 of the GNU Lesser General Public License
-# as published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it would be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-#
-class1 cpu.shares=1024 tuid=balbir tgid=balbir cuid=root cgid=root
-class2 cpu.shares=512 tuid=root tgid=root cuid=balbir cgid=balbir
diff --git a/scripts/etc/cgconfig/cpuacct.conf b/scripts/etc/cgconfig/cpuacct.conf
deleted file mode 100644
index 8c382e1..0000000
--- a/scripts/etc/cgconfig/cpuacct.conf
+++ /dev/null
@@ -1,14 +0,0 @@
-#
-# Copyright IBM Corporation. 2008
-#
-# Authors: Balbir Singh <balbir@linux.vnet.ibm.com>
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of version 2.1 of the GNU Lesser General Public License
-# as published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it would be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-#
-caclass1 tuid=root tgid=root cuid=root cgid=root
-caclass2 tuid=balbir tgid=balbir cuid=balbir cgid=balbir
diff --git a/scripts/etc/wlm.conf b/scripts/etc/wlm.conf
deleted file mode 100644
index 01a12b3..0000000
--- a/scripts/etc/wlm.conf
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# Copyright IBM Corporation. 2008
-#
-# Authors: Balbir Singh <balbir@linux.vnet.ibm.com>
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of version 2.1 of the GNU Lesser General Public License
-# as published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it would be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-#
-# controller file
-#
-mount /tmp/container cpu
-cpu /etc/wlm/cpu.conf
diff --git a/scripts/etc/wlm/cpu.conf b/scripts/etc/wlm/cpu.conf
deleted file mode 100644
index 10ac391..0000000
--- a/scripts/etc/wlm/cpu.conf
+++ /dev/null
@@ -1,14 +0,0 @@
-#
-# Copyright IBM Corporation. 2008
-#
-# Authors: Balbir Singh <balbir@linux.vnet.ibm.com>
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of version 2.1 of the GNU Lesser General Public License
-# as published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it would be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-#
-class1 cpu.shares=1024 tuid=balbir tgid=balbir cuid=root cgid=root
-class2 cpu.shares=512 tuid=root tgid=root cuid=balbir cgid=balbir
diff --git a/scripts/etc/wlm/cpuacct.conf b/scripts/etc/wlm/cpuacct.conf
deleted file mode 100644
index 10ac391..0000000
--- a/scripts/etc/wlm/cpuacct.conf
+++ /dev/null
@@ -1,14 +0,0 @@
-#
-# Copyright IBM Corporation. 2008
-#
-# Authors: Balbir Singh <balbir@linux.vnet.ibm.com>
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of version 2.1 of the GNU Lesser General Public License
-# as published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it would be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-#
-class1 cpu.shares=1024 tuid=balbir tgid=balbir cuid=root cgid=root
-class2 cpu.shares=512 tuid=root tgid=root cuid=balbir cgid=balbir
diff --git a/scripts/init.d/wlm b/scripts/init.d/wlm
deleted file mode 100755
index 65d51bd..0000000
--- a/scripts/init.d/wlm
+++ /dev/null
@@ -1,288 +0,0 @@
-#
-# Start/Stop the workload manager
-#
-# Copyright IBM Corporation. 2008
-#
-# Authors: Balbir Singh <balbir@linux.vnet.ibm.com>
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of version 2.1 of the GNU Lesser General Public License
-# as published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it would be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-#
-#
-# TODO: Make this code more robust, add error checking and recovery
-# for invalid configuration or interrupted execution
-#
-# Make the script LSB compliant
-#
-
-CONF_FILE=/etc/wlm.conf
-PROC_CGROUPS_FILE=/proc/cgroups
-CGROUP_FS=cgroup
-IGNORE_OPTS="ns cpuset"
-
-# support multiple mount points
-
-declare -a MOUNTPOINT
-declare -a MOUNTOPTS
-maxindex=0
-
-parse_controller_file() {
- ctlr=$1
- file=$2
- tuid="root"
- tgid="root"
- cuid="root"
- cgid="root"
-
- pushd $PWD 2>&1 > /dev/null
- while read name opts
- do
- case $name in
- 'mount')
- ;;
- *)
- if ! echo $name | grep -q ^#
- then
- echo "Creating class $name"
- class=$name
- index=1
- for i in `seq 1 $maxindex`
- do
- echo "mount pt ${MOUNTPOINT[$i]}"
- mkdir -p ${MOUNTPOINT[$i]}/$class
- cd ${MOUNTPOINT[$i]}/$class
-
- if echo $opts | grep -q "="
- then
- for single_opt in $opts
- do
- cf=`echo $single_opt | cut -d '=' -f1`
- co=`echo $single_opt | cut -d '=' -f2`
- case $cf in
- "tuid")
- tuid=$co
- ;;
- "cuid")
- cuid=$co
- ;;
- "tgid")
- tgid=$co
- ;;
- "cgid")
- cgid=$co
- ;;
- *)
- echo -n $co > $cf
- ;;
- esac
- done
- chown -R $cuid:$cgid ${MOUNTPOINT[$i]}/$class
- chown -R $tuid:$tgid ${MOUNTPOINT[$i]}/$class/tasks
- fi
- done
- fi
- esac
- done < $file
- popd 2>&1 > /dev/null
-}
-
-parse_controller_opts() {
- name=$1;
- file=$2;
-
- if [ ! -r $PROC_CGROUPS_FILE ]
- then
- echo "$PROC_CGROUPS_FILE does not exist, please compile"
- echo "cgroups into the kernel"
- exit 1
- else
- line=`grep -w $name $PROC_CGROUPS_FILE`
- if [ $? -ne 0 ]
- then
- echo "$name controller not enabled"
- exit 1
- fi
-
- active=`echo $line | awk '{print $2}'`
- if [[ $active -eq 0 ]]
- then
- echo "$name controller not mounted"
- else
- parse_controller_file $name $file
- fi
- fi
-}
-
-parse_conf_file() {
- while read name conf
- do
- # skip all comments
- if ! echo $name | grep -q ^#
- then
- case $name in
- 'mount')
- maxindex=$(($maxindex+1))
- MOUNTPOINT[$maxindex]=`echo $conf | cut -d ' ' -f1`;
- MOUNTOPTS[$maxindex]=`echo $conf | cut -d ' ' -f2`;
- ;;
- esac
- fi
- done < $CONF_FILE
-
- return 0;
-}
-
-mount_fs() {
- if [ ! -r $PROC_CGROUPS_FILE ]
- then
- echo "$PROC_CGROUPS_FILE does not exist, please compile"
- echo "cgroups into the kernel"
- exit 1
- #else
- #while read name hierarchy num_cgroups
- #do
- # if ! echo $name | grep -q ^#
- # then
- # echo $IGNORE_OPTS | grep -wq $name
- # if [[ $? -ne 0 ]]
- # then
- # MOUNT_OPTS=$name","$MOUNT_OPTS
- # fi
- # fi
- #done < $PROC_CGROUPS_FILE
- #MOUNT_OPTS=${MOUNT_OPTS%%","}
- #line=`grep -w $MOUNT_OPTS $PROC_CGROUPS_FILE`
- #if [ $? -ne 0 ]
- #then
- # echo "$name controller not enabled"
- # exit 1
- #fi
- fi
- for i in `seq 1 $maxindex`
- do
- mkdir -p ${MOUNTPOINT[$i]}
- echo "mounting ${MOUNTPOINT[$i]} with ${MOUNTOPTS[$i]}"
- mount -t $CGROUP_FS $CGROUP_FS -o ${MOUNTOPTS[$i]} ${MOUNTPOINT[$i]}
- #
- # Give root tasks read/write permission to all, since tasks
- # tasks will be moved to root frequently
- #
- chmod ago+rwx ${MOUNTPOINT[$i]}/tasks
- chmod ago+rwx ${MOUNTPOINT[$i]}
- chmod +t ${MOUNTPOINT[$i]}
- done
- return $?
-}
-
-umount_fs() {
- for i in `seq 1 $maxindex`
- do
- umount ${MOUNTPOINT[$i]}
- rmdir ${MOUNTPOINT[$i]}
- done
-}
-
-create_classes() {
- while read name conf
- do
- # skip all comments
- if ! echo $name | grep -q ^#
- then
- case $name in
- 'mount')
- ;;
- *)
- parse_controller_opts $name $conf
- esac
- fi
-
- done < $CONF_FILE
-}
-
-start() {
- echo "Starting wlm service: "
- mount_fs
- if [ $? -eq 0 ]
- then
- create_classes
- fi
- [ $? == 0 ] && touch /var/lock/subsys/wlm
- return $?
-}
-
-move_all_to_init_class() {
- for i in `seq 1 $maxindex`
- do
- cd ${MOUNTPOINT[$i]}
- cat /proc/mounts | grep -wq ${MOUNTPOINT[$i]}
- if [ $? -ne 0 ]
- then
- echo "resource control filesystem not mounted"
- exit 1
- fi
-
- for i in `find . -type d`
- do
- case $i in
- '.')
- ;;
- *)
- class=${i#./*}
- echo "Removing class $class"
- sed -nu p < ./$i/tasks > tasks
- rmdir $i
- ;;
- esac
- done
- cd - > /dev/null
- done
-}
-
-
-stop() {
- move_all_to_init_class
- umount_fs
-}
-
-trapped() {
- #
- # Do nothing
- #
- true
-}
-
-usage() {
- echo "$0 <start|stop>"
- exit 1
-}
-
-common() {
- #
- # main script work done here
- #
- trap "trapped ABRT" ABRT
- trap "trapped QUIT" QUIT
- trap "trapped TERM" TERM
- trap "trapped INT" INT
-
- parse_conf_file
-}
-
-case $1 in
- 'start')
- common
- start;
- ;;
- 'stop')
- common
- stop;
- ;;
- *)
- usage
- ;;
-esac
-