From 764c344f830e99385f04434cc2c6ab110c14aa83 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Mon, 23 Jun 2014 23:05:31 +0200 Subject: [PATCH] MT#6485 Container detection in init script Core dump configuratino and certain ulimit operations don't work when running inside a container like docker, lxc or openvz: | # /etc/init.d/sems status | /etc/init.d/sems: 53: /etc/init.d/sems: cannot create /proc/sys/kernel/core_pattern: Permission denied | /etc/init.d/sems: 54: /etc/init.d/sems: cannot create /proc/sys/fs/suid_dumpable: Permission denied | /etc/init.d/sems: 59: ulimit: error setting limit (Operation not permitted) --- debian/control | 2 ++ debian/ngcp-sems.init | 24 ++++++++++++++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/debian/control b/debian/control index 1490c0aa..10ca8ad1 100644 --- a/debian/control +++ b/debian/control @@ -21,6 +21,8 @@ Standards-Version: 3.9.5 Package: ngcp-sems Architecture: any +Pre-Depends: ngcp-system-tools, + ${misc:Pre-Depends} Depends: adduser, ngcp-sems-prompts, python, diff --git a/debian/ngcp-sems.init b/debian/ngcp-sems.init index 4bdadd9f..a5b6ed07 100644 --- a/debian/ngcp-sems.init +++ b/debian/ngcp-sems.init @@ -63,16 +63,24 @@ if test "$SEMS_CFG_FILE" ; then fi if test "$SEMS_CREATE_CORE" = "yes" ; then - # directory for the core dump files - [ -d $SEMS_COREDIR ] || mkdir $SEMS_COREDIR - chmod 777 $SEMS_COREDIR - echo "$SEMS_COREDIR/core.%e.sig%s.%p" > /proc/sys/kernel/core_pattern - echo 2 > /proc/sys/fs/suid_dumpable - ulimit -c unlimited + if /usr/sbin/ngcp-virt-identify --type container; then + echo "Container environment detected. Skipping core dump configuration." + else + # directory for the core dump files + [ -d $SEMS_COREDIR ] || mkdir $SEMS_COREDIR + chmod 777 $SEMS_COREDIR + echo "$SEMS_COREDIR/core.%e.sig%s.%p" > /proc/sys/kernel/core_pattern + echo 2 > /proc/sys/fs/suid_dumpable + ulimit -c unlimited + fi fi -# raise file descriptors limit - call hold consumes two fds for RTP ports and one for moh file -ulimit -n 100000 +if /usr/sbin/ngcp-virt-identify --type container; then + echo "Container environment detected. Skipping file descriptors limit configuration." +else + # raise file descriptors limit - call hold consumes two fds for RTP ports and one for moh file + ulimit -n 100000 +fi if ! test -f $DAEMON ; then echo "Error: cannot find $DAEMON"