Commit 885af051 authored by Seblu's avatar Seblu
Browse files

up


git-svn-id: https://seblu.net/s/archpkg@256 02741741-5192-46b8-8916-7152b19231d9
parent b06b4489
Loading
Loading
Loading
Loading

libcgroup/PKGBUILD

0 → 100644
+57 −0
Original line number Diff line number Diff line
# $Id$
# Maintainer: Sébastien Luttringer <seblu@aur.archlinux.org>
# Contributor: Jan "heftig" Steffens <jan.steffens@gmail.com>

pkgname=libcgroup
pkgver=0.38
pkgrel=0.1
pkgdesc='Library that abstracts the control group file system in Linux'
arch=(i686 x86_64)
url='http://libcg.sourceforge.net'
license=(LGPL)
backup=('etc/conf.d/cgred' 'etc/conf.d/cgconfig' 'etc/cgconfig.conf' 'etc/cgrules.conf')
options=('!emptydirs' '!libtool')
install=libcgroup.install
source=("http://downloads.sourceforge.net/libcg/$pkgname-$pkgver.tar.bz2"
        cgred cgconfig cgconfig.conf)
md5sums=('f0f7d4060bf36ccc19d75dbf4f1695db'
         '72abd2fd52853579b91e1ca6ea87197a'
         '8e2ee870398dd62d3c4730330bbf6c21'
         'cf4244ed9a413fa888be66bf0bc6d055')

build() {
  cd $pkgname-$pkgver
  ./configure \
    --prefix=/usr \
    --sysconfdir=/etc \
    --localstatedir=/var
  make
}

package() {
  cd $pkgname-$pkgver

  make DESTDIR="$pkgdir" pkgconfigdir=/usr/lib/pkgconfig install

  # install samples
  install -Dm644 samples/cgred.conf "$pkgdir/etc/conf.d/cgred"
  install -Dm644 samples/cgconfig.conf "$pkgdir/etc/cgconfig.conf"
  install -Dm644 samples/cgrules.conf "$pkgdir/etc/cgrules.conf"
  install -Dm644 samples/cgsnapshot_blacklist.conf "$pkgdir/etc/cgsnapshot_blacklist.conf"

  # fix naming of pam library
  cd "$pkgdir/usr/lib/security"
  mv pam_cgroup.so.*.*.* pam_cgroup.so
  rm -f pam_cgroup.so.*

  cd "$srcdir"
  install -Dm755 "$srcdir/cgred" etc/rc.d/cgred
  install -Dm755 "$srcdir/cgconfig" etc/rc.d/cgconfig
  install -Dm644 "$srcdir/cgconfig.conf" etc/conf.d/cgconfig
#
#  # Make cgexec setgid cgred
#  chown root:160 "$pkgdir/bin/cgexec"
#  chmod 2755 "$pkgdir/bin/cgexec"
}

# vim:set ts=2 sw=2 ft=sh et:

libcgroup/cgconfig

0 → 100755
+101 −0
Original line number Diff line number Diff line
#!/bin/bash

. /etc/rc.conf
. /etc/rc.d/functions

. /etc/conf.d/cgconfig

# From cgconfig init.d script
create_default_groups() {
  declare defaultcgroup

  if [ -f /etc/cgrules.conf ]; then
    grep -m1 '^\*[[:space:]]\+' /etc/cgrules.conf | \
      read user ctrl defaultcgroup
    if [ -n $defaultcgroup -a $defaultcgroup = "*" ]; then
      defaultcgroup=
    fi
  fi

  if [ -z $defaultcgroup ]; then
    defaultcgroup=sysdefault/
  fi

  #
  # Find all mounted subsystems and create comma-separated list
  # of controllers.
  #
  controllers=$(lssubsys 2>/dev/null | tr '\n' ',' | sed s/.$//)

  #
  # Create the default group, ignore errors when the default group
  # already exists.
  #
  cgcreate -f 664 -d 775 -g $controllers:$defaultcgroup 2>/dev/null

  #
  # special rule for cpusets
  #
  if echo $controllers | grep -q -w cpuset; then
    cpus=$(cgget -nv -r cpuset.cpus /)
    cgset -r cpuset.cpus=$cpus $defaultcgroup
    mems=$(cgget -nv -r cpuset.mems /)
    cgset -r cpuset.mems=$mems $defaultcgroup
  fi

  #
  # special rule for cpus
  #
  if echo $controllers | grep -q -w cpu; then
    rt_runtime_us=$(cgget -nv -r cpu.rt_runtime_us /)
    cgset -r cpu.rt_runtime_us=$rt_runtime_us $defaultcgroup
  fi

  #
  # Classify everything to default cgroup. Ignore errors, some processes
  # may exit after ps is run and before cgclassify moves them.
  #
  classify_all -g $controllers:$defaultcgroup || :
}

classify_all() {
  cgclassify "$@" $(ps --no-headers -eL o tid) 2>/dev/null
}

case "$1" in
  start)
    stat_busy "Starting CGroups configuration"
    cgconfigparser -l /etc/cgconfig.conf
    if [ $? -gt 0 ]; then
      stat_fail
    else
      if [ $CREATE_DEFAULT == "yes" ]; then
        create_default_groups
      fi
      if [ $CLASSIFY == "yes" ]; then
        classify_all
      fi
      add_daemon cgconfig
      stat_done
    fi
    ;;
  stop)
    stat_busy "Clearing CGroups configuration"
    cgclear
    if [ $? -gt 0 ]; then
      stat_fail
    else
      rm_daemon cgconfig
      stat_done
    fi
    ;;
  restart)
    $0 stop
    sleep 1
    $0 start
    ;;
  *)
    echo "usage: $0 {start|stop|restart}"  
esac

# vim:set ft=sh:
+21 −0
Original line number Diff line number Diff line
# Service cgconfig can create a default group in all mounted hierarchies and
# move all processes there on boot. If no default rule is specified in
# /etc/cgrules.conf, the default group is named '/sysdefault'.
# This automatically created group(s) can be useful e.g. when using 'cpu'
# controller to limit cpu.shares of this default group and allowing some more
# important group take most of the CPU.
#
# By default, create these groups:
CREATE_DEFAULT=yes

# Uncomment following line to disable creation of the default group on startup:
#CREATE_DEFAULT=no

# Service cgconfig can classify all processes according to /etc/cgrules.conf on
# boot.
#
# By default, classify all processes:
CLASSIFY=yes

# Uncomment following line to disable classification of processes on boot:
#CLASSIFY=no

libcgroup/cgred

0 → 100755
+54 −0
Original line number Diff line number Diff line
#!/bin/bash

. /etc/rc.conf
. /etc/rc.d/functions

. /etc/conf.d/cgred
OPTIONS="$NODAEMON $LOG"
if [ -n "$LOG_FILE" ]; then
  OPTIONS="$OPTIONS --logfile=$LOG_FILE"
fi
if [ -n "$SOCKET_USER" ]; then
  OPTIONS="$OPTIONS -u $SOCKET_USER"
fi
if [ -n "$SOCKET_GROUP" ]; then
  OPTIONS="$OPTIONS -g $SOCKET_GROUP"
fi

PID=`pidof -o %PPID /usr/sbin/cgrulesengd`
case "$1" in
  start)
    stat_busy "Starting CGroups rules engine daemon"
    if [ -z "$PID" ]; then 
      # Load Connector support
      modprobe cn
      sleep 0.1
      cgrulesengd $OPTIONS
    fi
    if [ ! -z "$PID" -o $? -gt 0 ]; then
      stat_fail
    else
      add_daemon cgred
      stat_done
    fi
    ;;
  stop)
    stat_busy "Stopping CGroups rules engine daemon"
    [ ! -z "$PID" ]  && kill $PID &> /dev/null
    if [ $? -gt 0 ]; then
      stat_fail
    else
      rm_daemon cgred
      stat_done
    fi
    ;;
  restart)
    $0 stop
    sleep 1
    $0 start
    ;;
  *)
    echo "usage: $0 {start|stop|restart}"  
esac

# vim:set ft=sh:
+11 −0
Original line number Diff line number Diff line
post_install() {
  getent group cgred &>/dev/null || groupadd -r -g 160 cgred >/dev/null
}

post_upgrade() {
  post_install
}

post_remove() {
  getent group cgred &>/dev/null && groupdel cgred >/dev/null
}