From ba2f8622f8e1a3568b01be5271c2dcdff30048d7 Mon Sep 17 00:00:00 2001 From: Mario Fetka Date: Thu, 25 Jun 2015 14:09:33 +0200 Subject: [PATCH] Add Master --- metadata/layout.conf | 1 + net-nds/netiq-ndsserv/files/ndsd88.service | 12 + net-nds/netiq-ndsserv/files/new/ndsd | 482 +++++++++++++++++++ net-nds/netiq-ndsserv/files/nldapd88.initd | 139 ++++++ net-nds/netiq-ndsserv/files/nldapd88.service | 11 + 5 files changed, 645 insertions(+) create mode 100644 metadata/layout.conf create mode 100644 net-nds/netiq-ndsserv/files/ndsd88.service create mode 100755 net-nds/netiq-ndsserv/files/new/ndsd create mode 100755 net-nds/netiq-ndsserv/files/nldapd88.initd create mode 100644 net-nds/netiq-ndsserv/files/nldapd88.service diff --git a/metadata/layout.conf b/metadata/layout.conf new file mode 100644 index 00000000..d43e61ca --- /dev/null +++ b/metadata/layout.conf @@ -0,0 +1 @@ +masters = gentoo diff --git a/net-nds/netiq-ndsserv/files/ndsd88.service b/net-nds/netiq-ndsserv/files/ndsd88.service new file mode 100644 index 00000000..16fbb89d --- /dev/null +++ b/net-nds/netiq-ndsserv/files/ndsd88.service @@ -0,0 +1,12 @@ +[Unit] +Description=Martin Stover Netware Emulator +After=network.target + +[Service] +Type=forking +EnvironmentFile=/etc/conf.d/ndsd +PIDFile=/var/run/mars_nwe/nwserv.pid +ExecStart=/usr/sbin/nwserv + +[Install] +WantedBy=multi-user.target diff --git a/net-nds/netiq-ndsserv/files/new/ndsd b/net-nds/netiq-ndsserv/files/new/ndsd new file mode 100755 index 00000000..ed42bebc --- /dev/null +++ b/net-nds/netiq-ndsserv/files/new/ndsd @@ -0,0 +1,482 @@ +#!/bin/sh +# +# Copyright (c) 2013 NetIQ Corporation and its affiliates. All Rights Reserved. +# +# Startup for Server +# +# Do not put runlevel info. for ndsd since it is started by "nds" +# Add LSB INIT and chkconfig Info to ndsd script +# chkconfig: 35 75 54 +# description: NetIQ eDirectory Server +# processname: ndsd +# pidfile: /var/nds/ndsd.pid +# config: /etc/opt/novell/eDirectory/conf/nds.conf + +### BEGIN INIT INFO +# Provides: ndsd +# Required-Start: $local_fs $network +# Should-Start: $time +# Should-Stop: $null +# Required-Stop: $null +# Default-Start: 2 3 5 +# Default-Stop: 0 1 4 6 +# Short-Description: NetIQ eDirectory Server +# Description: NetIQ eDirectory Server +### END INIT INFO + +PRINT_SUCCESS="echo \`gettext nds \"Done\"\`" +PRINT_FAILED= +PRINT_SKIPPED= + +if [ -f /etc/sysconfig/language ]; then + . /etc/sysconfig/language + + locale_vars="\ + LANG \ + LC_ALL \ + LC_MESSAGES \ + LC_CTYPE \ + LC_COLLATE \ + LC_TIME \ + LC_NUMERIC \ + LC_MONETARY" + + for var in $locale_vars + do + if eval test -z "\$$var"; then + eval $var="\$RC_$var" + export $var + fi + done +fi + +# Store the language as there is every chance it being reset +tmpLANG=$LANG +tmpLC_ALL=$LC_ALL + +if [ -f /etc/rc.status ]; then + . /etc/rc.status + PRINT_SUCCESS="rc_reset;rc_status -v" + PRINT_FAILED="rc_failed 1;rc_status -v" + PRINT_SKIPPED="rc_status -s" +else +if [ -f /etc/rc.d/init.d/functions ]; then + . /etc/rc.d/init.d/functions + PRINT_SUCCESS="echo_success;echo """ + PRINT_FAILED="echo_failure;echo """ + PRINT_SKIPPED="echo_failure;echo """ +else +if [ -f /etc/init.d/functions ]; then + . /etc/init.d/functions + PRINT_SUCCESS="echo_success;echo """ + PRINT_FAILED="echo_failure;echo """ + PRINT_SKIPPED="echo_failure;echo """ +fi +fi +fi +LANG=$tmpLANG +LC_ALL=$tmpLC_ALL +export LANG +export LC_ALL +userID=`id -u` +if [ -d /opt/novell/xad/lib/nds-modules ]; then +NDSD_TRY_NMASLOGIN_FIRST=true +export NDSD_TRY_NMASLOGIN_FIRST +fi +if [ -d /opt/novell/afptcpd ]; then +NDSD_TRY_NMASLOGIN_FIRST=true +export NDSD_TRY_NMASLOGIN_FIRST +fi + +# Template configuration variables +AWK=awk + +firstchar=`echo $0 | cut -c1` +dir=`dirname $0` +if [ "$firstchar" != "/" ] +then + dir="`pwd`/$dir" +fi + +#echo $dir +NDSHOME=`echo $dir | $AWK -F"/etc" '{print $1}'` +basenam=`basename $0` +if [ "$basenam" = "rcndsd" ] +then + NDSHOME="" +fi + + +default_conf=$NDSHOME/etc/opt/novell/eDirectory/conf +default_prefix=$NDSHOME/opt/novell/eDirectory +default_vardir=$NDSHOME/var/opt/novell/eDirectory/data +TEXTDOMAINDIR="$NDSHOME/opt/novell/eDirectory/share/locale" +export TEXTDOMAINDIR + +ownername=`ls -l $0 |awk '{print $3;}'` +ownerUid=`id $ownername | cut -d'=' -f2|cut -d'(' -f1 2>/dev/null` +default_config_file=`head -1 $default_conf/.edir/instances.$ownerUid 2> /dev/null` + +if [ "$default_config_file" = "" ] +then + default_config_file=$default_conf/nds.conf +fi + +: ${NDS_CONF=$default_config_file} +: ${prefix=$default_prefix} + +export NDS_CONF + +configdir=`cat ${NDS_CONF=$default_config_file} |grep "^n4u.*configdir" | head -n 1 | sed 's/^.*=//'` +if [ -z "$configdir" ]; then + configdir=$default_conf +fi + +localstatedir=`cat ${NDS_CONF=$default_config_file} |grep "^n4u.*vardir" | head -n 1 | sed 's/^.*=//'` +if [ -z "$localstatedir" ]; then + localstatedir=$default_vardir +fi + +locallogfile=`cat ${NDS_CONF=$default_config_file} |grep "^n4u.server.log-file" | head -n 1 | sed 's/^.*=//'` +if [ -z "$locallogfile" ]; then + locallogfile=`echo $localstatedir | sed 's/data$/log\/ndsd.log/'` +fi +libdir=`cat ${NDS_CONF=$default_config_file} |grep "^n4u.*libdir" | head -n 1 | sed 's/^.*=//'` + +prefix=$default_prefix +exec_prefix=${prefix} +sbindir=${exec_prefix}/sbin +bindir=${exec_prefix}/bin +sysconfdir=/etc +libfldr=lib64 +libdir=${default_prefix}/$libfldr +node=`hostname` +now="`date +"%b %d %T"`" + +initdir=$NDSHOME/etc/init.d + +trap 'rm -f /tmp/nds.stat.$$' 0 1 15 + +LD_LIBRARY_PATH=$libdir:$libdir/nds-modules:$libdir/apr:/$NDSHOME/opt/novell/$libfldr:/opt/novell/$libfldr:$LD_LIBRARY_PATH +export LD_LIBRARY_PATH +PATH=$PATH:/usr/local/bin + +LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/nds-modules:/opt/novell/xad/$libfldr/nds-modules:/opt/novell/xad/$libfldr:$default_prefix/lib/nds-modules/jre/lib/i386 +export LD_LIBRARY_PATH + + + + +# +# Start the ndsd daemon +# + +StartNdsd () { + + migrateOldScripts + + #check for n4u.cluster.nodes properties + clusternodes=`cat $default_config_file | grep "^n4u.cluster.nodes" | head -n 1` + + if [ -z "$clusternodes" ] ; then + # no "n4u.cluster.nodes=" config is found + # add the node into the list + echo "n4u.cluster.nodes=$node" >>$default_config_file + else + clusternodes_new=`echo $clusternodes | head -n 1 | grep $node` + + if [ -z "$clusternodes_new" ] + then + # $node is not present in the list, add the $node + sed -i 's/n4u.cluster.nodes=/n4u.cluster.nodes='$node';/' $default_config_file + fi + fi + + # Call custom settings before ndsd start + if [ -f $sbindir/pre_ndsd_start ]; then + echo `gettext nds "Executing customized settings before starting the NetIQ eDirectory server..."` + . $sbindir/pre_ndsd_start + + if [ "$?" -ne 0 ]; then + echo `gettext nds "Validation failed in pre_ndsd_start script."` + string=`gettext nds "Please refer to the following script: "` + echo "$string$sbindir/pre_ndsd_start ." + echo `gettext nds "NetIQ eDirectory server could not start."` + eval $PRINT_SKIPPED + exit 1 + fi + fi + + #log hostname into logfle + str=`gettext nds "About to start NetIQ eDirectory server on host:"` + echo "$now $str $node." >> $locallogfile + + if [ -f $sbindir/ndsd ]; then + echo `gettext nds "Starting NetIQ eDirectory server..."` + + + + if [ "$MALLOC_CHECK_" = "" ] && [ -f /usr/$libfldr/libtcmalloc_minimal.so.0 ]; then + if [ -f /etc/novell-release ]; then + LD_PRELOAD="/usr/$libfldr/libtcmalloc_minimal.so.0" $sbindir/ndsd + else + LD_BIND_NOW=1 LD_PRELOAD="/usr/$libfldr/libtcmalloc_minimal.so.0" $sbindir/ndsd + fi + else + $sbindir/ndsd + fi + rc="$?" + if [ $rc != 0 ]; then + if [ $rc != 2 ]; then + echo `gettext nds "NetIQ eDirectory server startup failed."` + str=`gettext nds "For more information view the following log file :"` + echo "$str $locallogfile" + eval $PRINT_FAILED + exit 1 + fi + eval $PRINT_SUCCESS + exit 0 + fi + sleep 5 # wait for server to initialize + eval $PRINT_SUCCESS + if [ -d /var/lock/subsys ] && [ "$userID" = "0" ] + then + touch /var/lock/subsys/ndsd + fi + else + str=`gettext nds "The following NetIQ eDirectory server is not found."` + echo "$str : $sbindir/ndsd" + eval $PRINT_FAILED + exit 1 + fi + + # Call custom settings after ndsd start + + if [ -f $sbindir/post_ndsd_start ]; then + echo `gettext nds "Executing customized settings after starting the NetIQ eDirectory server..."` + . $sbindir/post_ndsd_start + + if [ "$?" -ne 0 ]; then + echo `gettext nds "Validation failed in post_ndsd_start script."` + echo "$string$sbindir/post_ndsd_start." + fi + fi + #log hostname into logfle + str=`gettext nds " Started NetIQ eDirectory server on host: "` + echo "$now$str$node" >> $locallogfile + +} # StartNdsd + +# +# Stop the ndsd daemon +# Take care of ccs unloading +# + +StopNdsd () { + + # Call custom settings before ndsd stop + if [ -f $sbindir/pre_ndsd_stop ]; then + + echo `gettext nds "Executing customized settings before stopping the NetIQ eDirectory server..."` + . $sbindir/pre_ndsd_stop + + if [ "$?" -ne 0 ]; then + echo `gettext nds "Validation failed in pre_ndsd_stop script."` + echo "$string$sbindir/pre_ndsd_start ." + echo `gettext nds "NetIQ eDirectory server could not stop."` + eval $PRINT_SKIPPED + exit 1 + fi + fi + #log hostname into logfle + str=`gettext nds " About to stop NetIQ eDirectory server on host: "` + echo "$now$str$node" >> $locallogfile + + + if [ ! -f $localstatedir/ndsd.pid ]; then + echo `gettext nds "NetIQ eDirectory server is not running."` + eval $PRINT_FAILED + exit 1 + fi + + echo `gettext nds "Stopping NetIQ eDirectory server..."` # no newline + + # Get the pid from the pid file + pid=`cat $localstatedir/ndsd.pid` + sess=`ps -o session -p $pid --no-headers` + + kill -INT $pid > /dev/null 2>&1 + if [ "$?" -ne 0 ]; then + echo `gettext nds "NetIQ eDirectory server is not running."` + eval $PRINT_FAILED + exit 1 + fi + + count=360 + pidexists=`ps -p $pid | grep -c ndsd` + while [ $pidexists -ne 0 ] && [ -f $localstatedir/ndsd.pid -a $count -ne 0 ] + do + sleep 1 # wait for maximum 30 seconds + printf `gettext nds "."` + count=`expr $count - 1` + pidexists=`ps -p $pid | grep -c ndsd` + done + + if [ -f $localstatedir/ndsd.pid ]; then + echo `gettext nds "WARNING: ndsd process is still running. Killing ndsd."` >> $locallogfile + kill -KILL $pid > /dev/null 2>&1 # we can't wait any longer + rm $localstatedir/ndsd.pid + fi + + kill -KILL `ps -o pid -s $sess --no-headers` > /dev/null 2>&1 + # some threads are still hanging though the mother thread has got killed. + + if [ -f /var/lock/subsys/ndsd ] && [ "$userID" = "0" ] + then + rm -f /var/lock/subsys/ndsd + fi + eval $PRINT_SUCCESS + # Call custom settings after ndsd stop + + if [ -f $sbindir/post_ndsd_stop ]; then + echo `gettext nds "Executing customized settings after stopping the NetIQ eDirectory server..."` + . $sbindir/post_ndsd_stop + + if [ "$?" -ne 0 ]; then + echo `gettext nds "Validation failed in post_ndsd_stop script."` + echo "$string$sbindir/post_ndsd_start ." + fi + fi + #log hostname into logfle + str=`gettext nds " Stopped NetIQ eDirectory server on host: "` + echo "$now$str$node ." >> $locallogfile + +} # StopNdsd + +# Migrate the old scripts (post_ndsd_start/stop and pre_ndsd_start/stop) from initdir to sbindir +migrateOldScripts(){ + scripts="pre_ndsd_start pre_ndsd_stop post_ndsd_start post_ndsd_stop" + for script in $scripts + do + if [ -f "$initdir/$script" ]; then + cat $initdir/$script >> $sbindir/$script + rm -f $initdir/$script >/dev/null + fi + done +} + +# +# print the right usage +# exit with 1 +# + +Usage () { +str=`gettext nds "Usage"` + echo "$str: $0 { start | stop | status | restart | reload }" + exit 1 +} # Usage + +# +# Get status of ndsd running on current host +# +StatusNdsd () { + netstat -ep | grep ndsd > /tmp/nds.netstat.$$ 2>&1 + if [ "$?" -eq 0 ]; then + if [ -f $bindir/ndsstat ] ; then + $bindir/ndsstat --config-file $default_config_file > /tmp/nds.stat.$$ 2>&1 + if [ "$?" -ne 0 ]; then + cat /tmp/nds.stat.$$ + eval $PRINT_FAILED + exit 1 + fi + cat /tmp/nds.stat.$$ + rm /tmp/nds.stat.$$ + else + echo `gettext nds "Unable to get server status"` + fi + else + echo `gettext nds "Unable to get server status"` + exit 1 + fi + rm /tmp/nds.netstat.$$ +} # StatusNdsd + +RestartNdsd () { + if [ -f $localstatedir/ndsd.pid ]; then + kill -0 `cat $localstatedir/ndsd.pid ` > /dev/null 2>&1 + if [ "$?" -ne 1 ]; then + StopNdsd + fi + fi + StartNdsd +} + +# +# Reload not supported currently +# + +ReloadNdsd () { + RestartNdsd +} + +# +# Display version information +# + +VersionNdsd () { + $sbindir/ndsd --version +} + +# +# MAIN FUNCTION +# check number of args +# call start, stop functions +# +case "$#" in +'1') + #valid number of arguments + if [ "$1" = "start" ]; then + StartNdsd + elif [ "$1" = "stop" ]; then + StopNdsd + elif [ "$1" = "status" ]; then + StatusNdsd + elif [ "$1" = "restart" ]; then + RestartNdsd + elif [ "$1" = "reload" ]; then + ReloadNdsd + elif [ "$1" = "--version" ]; then + VersionNdsd + else + Usage + fi + ;; +'2') + if [ "$1" = "start" ]; then + if [ "$2" = "-ndb" ]; then + NDSD_DONT_OPEN_AGENT=Y + export NDSD_DONT_OPEN_AGENT + StartNdsd + elif [ "$2" = "-rdb" ]; then + RESTRICTED_MODE=Y + export RESTRICTED_MODE + StartNdsd + elif [ "$2" = "-igrfl" ]; then + NDSD_IGNORE_RFL=Y + export NDSD_IGNORE_RFL + StartNdsd + else + Usage + fi + else + Usage + fi + ;; +*) + #invalid number of arguments + Usage + ;; +esac +if [ -f /etc/rc.status ]; then + rc_exit +fi diff --git a/net-nds/netiq-ndsserv/files/nldapd88.initd b/net-nds/netiq-ndsserv/files/nldapd88.initd new file mode 100755 index 00000000..250ceb92 --- /dev/null +++ b/net-nds/netiq-ndsserv/files/nldapd88.initd @@ -0,0 +1,139 @@ +#!/sbin/runscript +# +# Copyright (c) 2004 Novell, Inc. +# All rights reserved. +# +# Script to wait till nldap TLS port comes up or timeout after 60 secs approx. +# +# Simplyfied and Gentooized by Mario Fetka + + +depend() { + need ndsd + use ndsd + after ndsd +} + +checkconfig() { + if [ ! -e /var/nds/ndsd.pid ] ; then + eerror "Novell eDirectory server has not been started." + return 1 + fi +} + +# +# Get nldap TCP Port status +# Cases: +# 1. nldap not loaded (nldap -c return 1 to the shell) +# 2. nldap TCP port is not listening (nldap -c returns 176 to the shell) +# 3. nldap 389 is disabled (nldap -c return 255 to the shell) +# 4. nldap TCP port is listning (nldap -c return 0 to the shell) + +GetTCPPortStatus () { +count=1 +while [ $count -ne 30 ] +do + if [ -f /opt/novell/eDirectory/sbin/nldap ]; then + /opt/novell/eDirectory/sbin/nldap -c > /dev/null 2>&1 # check the status + returnValue=$? + if [ $returnValue -eq 0 ]; then + ebegin "Novell eDirectory LDAP Server TCP port is listening" + eend 0 + break + fi + else + ebegin "Novell eDirectory /opt/novell/eDirectory/sbin/nldap not found" + eend 1 + fi + + sleep 1 # wait for maximum 60 seconds + count=`expr $count + 1` +done + + if [ $returnValue -eq 255 ]; then + ebegin "Novell eDirectory LDAP Server TCP port is disabled" + eend 1 + elif [ $returnValue -ne 0 ]; then + ebegin "Novell eDirectory LDAP Server TCP port is not listening" + eend 1 + fi +} # GetTCPPortStatus + +# +# Get nldap TLS Port status +# Cases: +# 1. nldap not loaded (nldap -s return 1 to the shell) +# 2. nldap TLS port is not listening (nldap -s returns 176 to the shell) +# 3. nldap 636 is disabled (nldap -s return 255 to the shell) +# 4. nldap TLS port is listning (nldap -s return 0 to the shell) + +GetTLSPortStatus () { + +count=1 +while [ $count -ne 30 ] +do + if [ -f /opt/novell/eDirectory/sbin/nldap ]; then + /opt/novell/eDirectory/sbin/nldap -s > /dev/null 2>&1 # check the status + returnValue=$? + if [ $returnValue -eq 0 ]; then + ebegin "Novell eDirectory LDAP Server TLS port is listening" + eend 0 + fi + + if [ $returnValue -eq 204 ]; then + if [ $count -ge 10 ]; then + ebegin "LDAP Server is not associated with Certificate" + eend 1 + fi + fi + + if [ $returnValue -eq 255 ]; then + ebegin "Novell eDirectory LDAP Server TLS port is disabled" + eend 1 + fi + else + ebegin "Novell eDirectory $sbindir/nldap not found" + eend 1 + fi + + sleep 1 # wait for maximum 60 seconds + count=`expr $count + 1` +done + + /opt/novell/eDirectory/sbin/nldap -c > /dev/null 2>&1 # check the status + if [ "$?" -eq 1 ]; then + ebegin "Novell eDirectory LDAP services are not running" + eend 1 + else + ebegin "Novell eDirectory LDAP Server TLS port is not listening" + eend 1 + fi +} # GetTLSPortStatus + +# +# MAIN FUNCTION +# + +start() { +if [ -f /var/nds/ndsd.pid ]; then + GetTCPPortStatus # TCP Port status + GetTLSPortStatus # TLS Port status +else + eend 1 +fi +} + +stop() { + /opt/novell/eDirectory/sbin/nldap -u > /dev/null 2>&1 # check the status + if [ "$?" -eq 1 ]; then + ebegin "Novell eDirectory LDAP services are not running" + eend 1 + else + ebegin "Novell eDirectory LDAP Server TCP and TLS port is not listening" + eend 0 + fi +} + +#restart() { +# (Commands necessary to restart the service) +#} diff --git a/net-nds/netiq-ndsserv/files/nldapd88.service b/net-nds/netiq-ndsserv/files/nldapd88.service new file mode 100644 index 00000000..c8cfef35 --- /dev/null +++ b/net-nds/netiq-ndsserv/files/nldapd88.service @@ -0,0 +1,11 @@ +[Unit] +Description=Martin Stover Netware Emulator +After=network.target + +[Service] +Type=forking +PIDFile=/var/run/mars_nwe/nwserv.pid +ExecStart=/usr/sbin/nwserv + +[Install] +WantedBy=multi-user.target