aboutsummaryrefslogtreecommitdiffstats
path: root/trunk/add-service
diff options
context:
space:
mode:
Diffstat (limited to 'trunk/add-service')
-rwxr-xr-xtrunk/add-service91
1 files changed, 91 insertions, 0 deletions
diff --git a/trunk/add-service b/trunk/add-service
new file mode 100755
index 0000000..f42907a
--- /dev/null
+++ b/trunk/add-service
@@ -0,0 +1,91 @@
+#!/bin/sh
+#---------------------------------------------------------------
+# Project : Mandriva Linux
+# Module : rpm-helper
+# File : add-service
+# Version : $Id$
+# Author : Frederic Lepied
+# Created On : Mon Jul 8 08:14:34 2002
+# Purpose : helper script for rpm scriptlets to add a
+# service.
+#---------------------------------------------------------------
+
+if [ $# != 3 ]; then
+ echo "usage: $0 <pkg name> <number installed> <service name>" 1>&2
+ exit 1
+fi
+
+pkg=$1 # name of the package
+num=$2 # number of packages installed
+srv=$3 # name of the service
+
+add_chkconfig_service() {
+ srv=$1
+
+ /sbin/chkconfig --add $srv
+
+ if [ -r /etc/sysconfig/system ]; then
+ . /etc/sysconfig/system
+ fi
+
+ if [ -z "$ADD_SERVICES_TO_CURRENT_PROFILE_ONLY" ]; then
+ # add the service to all the profiles at once
+ if [ -d /etc/netprofile/profiles/default/services ]; then
+ for dir in /etc/netprofile/profiles/*/services; do
+ touch $dir/$srv
+ done
+ fi
+ fi
+}
+
+add_service() {
+ # Add the service
+ if [ -r /etc/sysconfig/msec ]; then
+ . /etc/sysconfig/msec
+ fi
+
+ # High security: add only authorized services
+ LIST=/etc/security/msec/server
+
+ # during the install the symlink isn't done so find the right file
+ # by ourselves
+ if [ -n "$DURING_INSTALL" -a ! -f $LIST ]; then
+ LIST=/etc/security/msec/server.$SECURE_LEVEL
+ fi
+
+ if [ -f $LIST ]; then
+ if grep -q "^${srv}$" $LIST ; then
+ add_chkconfig_service $srv
+ fi
+ else
+ # Low security: install all the services
+ add_chkconfig_service $srv
+ fi
+}
+
+if [ $num = 1 ]; then
+ # First install mode
+ add_service
+else
+ # Upgrade mode
+
+ # if the service is activated, add it again to be able to handle
+ # changes in start/stop levels
+ set -- /etc/rc3.d/S??$srv
+ if [ $# -gt 1 ]; then
+ echo 1>&2 "add-service: Error: $srv appears multiple times: $*"
+ fi
+
+# [FIXME] disabling code below for MDV2008.1 to workaround butchered services
+# which have "chkconfig: - ..." and "Default-Start" dropped (#39720)
+# if [ -f "$1" ]; then
+# /sbin/chkconfig --add $srv
+# fi
+
+ # restart the service if already running
+ if [ -f /var/lock/subsys/$srv ]; then
+ /sbin/service $srv restart > /dev/null || :
+ fi
+fi
+
+# add-service ends here