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)
mr3.4.1
Michael Prokop 12 years ago
parent 29a8716aa2
commit 764c344f83

2
debian/control vendored

@ -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,

@ -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"

Loading…
Cancel
Save