| Voir le sujet précédent :: Voir le sujet suivant |
| Auteur |
Message |
ecantin Administrateur


Inscrit le: 09 Déc 2004 Messages: 1273 Localisation: Canada, Québec, Lévis
|
Posté le: Jeu Aoû 27, 2009 1:17 pm Sujet du message: OpenDS 1.2 SMF (service management facility) |
|
|
Comment faire pour ajouter OpenDS au service SMF.
* Ajouter au service
| Code: | # ./OpenDS-smf.bash -a enable -n ds1 -i /opt/OpenDS-1.2.0
# ./OpenDS-smf.bash -a list
STATE STIME FMRI
offline* 13:45:12 svc:/network/OpenDS/server:ds1 |
* Mettre le service désactivé
| Code: | # ./OpenDS-smf.bash -a disable -n ds1
# ./OpenDS-smf.bash -a list
STATE STIME FMRI
disabled 13:47:02 svc:/network/OpenDS/server:ds1 |
* Afficher l'état du service
| Code: | # svcs -x ds1
svc:/network/OpenDS/server:ds1 (OpenDS LDAP directory server)
State: disabled since August 27, 2009 1:47:02 PM EDT
Reason: Disabled by an administrator.
See: http://Sun.com/msg/SMF-8000-05
See: /var/svc/log/network-OpenDS-server:ds1.log
Impact: This service is not running.
|
* démarrer le service
| Code: | # svcadm enable ds1
# svcs -x ds1
svc:/network/OpenDS/server:ds1 (OpenDS LDAP directory server)
State: online since August 27, 2009 1:48:40 PM EDT
See: /var/svc/log/network-OpenDS-server:ds1.log
Impact: None.
|
* Supprimer de service du SMF
| Code: | # ./OpenDS-smf.bash -a unconfigure -n ds1
# ./OpenDS-smf.bash -a list
STATE STIME FMRI |
| Code: | # vi OpenDS-smf.bash
# chmod +x OpenDS-smf.bash |
| Code: | #!/bin/bash
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (the "License"). You may not use this file except in compliance
# with the License.
#
# You can obtain a copy of the license at
# trunk/OpenDS/resource/legal-notices/OpenDS.LICENSE
# or https://OpenDS.dev.java.net/OpenDS.LICENSE.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at
# trunk/OpenDS/resource/legal-notices/OpenDS.LICENSE. If applicable,
# add the following below this CDDL HEADER, with the fields enclosed
# by brackets "[]" replaced with your own identifying information:
# Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2006-2008 Sun Microsystems, Inc.
##############################################################################
#
# The purpose of this script is to provide a single script to provide the
# following Solaris 10 Service Management Facility (SMF) capabilities to
# OpenDS 2.0.0:
# * Configure a specific OpenDS instance for SMF
# * [Enable|Start] a specific OpenDS instance via SMF
# * [Disable|Stop] a specific OpenDS instance via SMF
# * Unconfigure an OpenDS instance from SMF
# * List OpenDS instances
#
##############################################################################
#
# Define global default variables
#
manifest="$HOME/.opends_manifest.$$"
##############################################################################
#
# Find pager
#
findpager() {
#
# Set the page command
#
pgcmd='cat - '
ck4less=`which less 2>&1 | /usr/bin/grep -v "no less"`
if [ -n "${ck4less}" ]
then
pgcmd='less'
else
ck4more=`which more 2>&1 | /usr/bin/grep -v "no more"`
if [ -n "${ck4more}" ]
then
pgcmd='more'
fi
fi
}
##############################################################################
#
# Define appropriate usage
#
usage() {
errmsg=${1}
findpager
cat <
System Administration Commands OpenDS-smf(1M)
NAME
OpenDS-smf - set up and manage OpenDS SMF instances
SYNOPSIS
Normal usage:
OpenDS-smf -a [options]
See proper usage:
OpenDS-smf -h
DESCRIPTION
The purpose of OpenDS-smf is to simplify Solaris 10 zones
management. There are many pre-defined actions that can be
applied to one or more zones depending on the action.
The purpose of OpenDS-smf is to provide a single script to
provide simplified integration of OpenDS instances into the
Solaris 10 Service Management Facility (SMF).
OPTIONS
The following options are supported:
-a Specify the action to be performed
-n SMF Instance Name
-i Directory of the OpenDS instance.
-u Specify the run-time user of the OpenDS instance.
-g Specify the run-time group of the OpenDS instance.
-h See this usage information
ACTIONS
The following actions are supported:
list: List SMF enabled OpenDS instances
configure: Create an SMF manifest and import it for a particular OpenDS instance.
unconfigure: Export the SMF configuration for a particular OpenDS instance.
enable|start: Enable or start a particular OpenDS instance
disable|stop: Disable or stop a particular OpenDS instance
restart: Disable or stop a particular OpenDS instance followed by Enable or starting
of the same OpenDSinstance.
EXIT STATUS
The following exit values are returned:
0 Successful completion.
1 An error occurred.
2 Invalid usage.
SEE ALSO
smf(5), pfexec(1)
EOF
if [ -n "${errmsg}" ]; then echo "${errmsg}";fi
exit 2
}
############################################################################
#
# Define exit level error message routine
#
error_message() {
if [ -f "${manifest}" ]; then rm -f "${manifest}"; fi
errmsg=${1}
if [ -n "${errmsg}" ]
then
echo -e "Error: ${errmsg}"
exit 1
fi
}
##############################################################################
#
# Validate the user and group existence and OpenDS ownership
#
validate_ownership() {
ck4user=`/usr/bin/grep "^$user:" /etc/passwd`
if [ -z "${ck4user}" ]; then error_message "The operating system user ($user) must exist."; fi
ck4uowner=`/usr/bin/ls -ald $inst_dir | /usr/bin/awk '{ print $3 }'`
if [ "$ck4uowner" != "$user" ]; then error_message "The specified user ($user) does not match the OpenDS instance user ownership ($ck4uowner)."; fi
ck4group=`/usr/bin/grep "^$group:" /etc/group`
if [ -z "${ck4group}" ]; then error_message "The operating system group ($group) must exist."; fi
ck4gowner=`/usr/bin/ls -ald $inst_dir | /usr/bin/awk '{ print $4 }'`
if [ "$ck4gowner" != "$group" ]; then error_message "The specified group ($group) does not match the OpenDS instance group ownership ($ck4gowner)."; fi
}
##############################################################################
#
# Make and import manifest
#
configure_smf() {
# Qualify the import request
if [ -z "${inst_name}" ]; then error_message "Must provide instance name via -n "; fi
ck4smf=`/usr/bin/svcs -a svc:/network/OpenDS/server:$inst_name 2>&1 | /usr/bin/grep "svc:/network/OpenDS/server:$inst_name$"`
if [ -n "$ck4smf" ]; then error_message "OpenDS instance \"$inst_name\" already exists."; fi
if [ -z "${inst_dir}" ]; then error_message "Must provide instance path via -i "; fi
if [ -d "${inst_dir}" ]; then true; else error_message "OpenDS Instance directory \"${inst_dir}\" does not exist."; fi
validate_ownership;
cat << EOF > "$manifest"
OpenDS LDAP directory server
EOF
/usr/sbin/svccfg import "$manifest"
if [ "$?" -ne 0 ]
then
error_message "SMF Import Failed!"
fi
}
enable_smf() {
validate_ownership
ck4smf=`/usr/bin/svcs -a svc:/network/OpenDS/server:$inst_name 2>&1 | /usr/bin/grep "doesn't match any instances"`
if [ -n "$ck4smf" ]; then configure_smf; fi
if [ -z "${inst_name}" ]; then error_message "Must provide instance name via -n "; fi
/usr/sbin/svcadm enable $inst_name
}
disable_smf() {
if [ -z "${inst_name}" ]; then error_message "Must provide instance name via -n "; fi
# Don't exit until the service finishes shutting down
ck4state=`/usr/bin/svcs -aH svc:/network/OpenDS/server:$inst_name 2> /dev/null | awk '{ print $1 }'`
if [ -n "$ck4state" ]
then
/usr/sbin/svcadm disable svc:/network/OpenDS/server:$inst_name
while [ "$ck4state" != 'disabled' ]
do
sleep 3
/usr/sbin/svcadm disable svc:/network/OpenDS/server:$inst_name
ck4state=`/usr/bin/svcs -aH svc:/network/OpenDS/server:$inst_name 2> /dev/null | awk '{ print $1 }'`
done
fi
}
unconfigure_smf() {
if [ -z "${inst_name}" ]; then error_message "Must provide instance name via -n "; fi
disable_smf
/usr/sbin/svccfg delete $inst_name
}
list_smf() {
/usr/bin/svcs -a | /usr/bin/egrep "FMRI|svc:/network/OpenDS/server:$inst_name"
}
##############################################################################
#
# Ensure this program is run as the root user
#
ck4root=`id | cut -d'(' -f2 | cut -d ')' -f1`
if [ "$ck4root" != 'root' ];then error_message "Must run as root user."; fi
##############################################################################
#
# If any parameters were passed evaluate their usage...
#
while getopts ha:n:i:u:g: OPT
do
case ${OPT} in
h|+h) usage;;
a|+a) if [ -z "${OPTARG}" ];then error_message "Must provide a valid action with the -a flag";fi
action="${OPTARG}"
;;
n|+n) if [ -z "${OPTARG}" ];then error_message "Must provide a valid OpenDS instance name with the -n flag";fi
inst_name="${OPTARG}"
;;
i|+i) if [ -z "${OPTARG}" ];then error_message "Must provide a valid OpenDS instance directory with the -i flag";fi
inst_dir="${OPTARG}"
;;
u|+u) if [ -z "${OPTARG}" ];then error_message "Must provide a valid and unused user name with the -u flag";fi
user="${OPTARG}"
;;
g|+g) if [ -z "${OPTARG}" ];then error_message "Must provide a valid and unused group name with the -g flag";fi
group="${OPTARG}"
;;
*) usage;;
esac
done
shift `expr ${OPTIND} - 1`
##############################################################################
#
# Test usage
#
if [ -z "${action}" ]; then error_message "Must provide action via -a "; fi
##############################################################################
#
# Set user and group info
#
if [ -z "$user" ]
then
user=`/usr/bin/svcprop -p start/user svc:/network/OpenDS/server:$inst_name 2> /dev/null`
if [ -z "$user" ]
then
if [ -n "$inst_dir" ]
then
user=`/usr/bin/ls -ald $inst_dir | /usr/bin/awk '{ print $3 }'`
fi
fi
if [ -z "$user" ]; then user='ldap'; fi
fi
if [ -z "$group" ]
then
group=`/usr/bin/svcprop -p start/group svc:/network/OpenDS/server:$inst_name 2> /dev/null`
if [ -z "$group" ]
then
if [ -n "$inst_dir" ]
then
group=`/usr/bin/ls -ald $inst_dir | /usr/bin/awk '{ print $4 }'`
fi
fi
if [ -z "$group" ]; then group='ldap'; fi
fi
case ${action} in
'configure') configure_smf;;
'unconfigure') unconfigure_smf;;
'enable') enable_smf;;
'start') enable_smf;;
'disable') disable_smf;;
'stop') disable_smf;;
'restart') disable_smf; enable_smf;;
'list') list_smf;;
*) usage;;
esac |
_________________
Sun Fire 3800 - 8x UltraSPARC-III+ 900 MHz - Solaris 10 U8 (à vendre)
Sun Fire v120 - 1x UtraSPARC-IIi 550MHz - Solaris 10 U8
Sun StorEdge T3+
Sun Fire V20Z - 2 x AMD Opteron 2.4 GHz - Solaris 10 U8
4 X SunRay 1(G) - SRSS v4.1
Sun Fire v100 - 1x UtraSPARC-IIi 550MHz - Solaris 10 U8
Sun Netra x1 - 1x UtraSPARC-IIe 500MHz - Solaris 10 U8
Sun Netra x1 - 1x UtraSPARC-IIe 500MHz - Solaris 10 U8
|
|
| Revenir en haut |
|
 |
Julien Administrateur


Inscrit le: 23 Nov 2007 Messages: 167 Localisation: Québec
|
Posté le: Mar Fév 02, 2010 10:55 am Sujet du message: |
|
|
Tu ne m'en voudra pas Éric si j'ajoute ma méthode
C'est juste pour la représentation des minorités visible sur ce forum
Alors pour ma part je fait comme ça :
Le fichier OpenDS.xml :
| Code: |
<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<!--
ident "@(#)OpenDS.xml 1.2 02/02/10 Julien Levasseur"
-->
<service_bundle type='manifest' name='OPTnew:OpenDS'>
<service
name='application/OpenDS'
type='service'
version='1'>
<single_instance/>
<dependency
name='usr'
type='service'
grouping='require_all'
restart_on='none'>
<service_fmri value='svc:/system/filesystem/local' />
</dependency>
<dependent
name='OpenDS'
grouping='require_all'
restart_on='none'>
<service_fmri value='svc:milestone/multi-user' />
</dependent>
<exec_method
type='method'
name='start'
exec='/opt/svc/method/OpenDS start'
timeout_seconds='30' />
<exec_method
type='method'
name='stop'
exec='/opt/svc/method/OpenDS stop'
timeout_seconds='30' />
<exec_method
type='method'
name='refresh'
exec='/opt/svc/method/OpenDS restart'
timeout_seconds='30' />
<property_group name='startd' type='framework'>
<propval name='duration' type='astring' value='transient'
/>
</property_group>
<instance name='default' enabled='true' />
<stability value='Unstable' />
<template>
<common_name>
<loctext xml:lang='C'>
OpenDS service
</loctext>
</common_name>
</template>
</service>
</service_bundle>
|
Le script de gestion :
| Code: |
#!/sbin/sh
#
#ident "@(#)OpenDS 1.14 02/02/10 Julien Levasseur"
INSTALLDIR="/opt/OpenDS/"
export INSTALLDIR
case "$1" in
'start')
${INSTALLDIR}/bin/start-ds --quiet &
;;
'stop')
${INSTALLDIR}/bin/stop-ds &
;;
'restart')
${INSTALLDIR}/bin/stop-ds --restart &
;;
*)
echo "Usage: $0 { start | stop | restart}"
;;
esac
exit 0
|
Et l'installateur de tout ce bazard :
| Code: |
#!/bin/bash
##################################################################
## ------------------------------------------------------------ ##
## Autor: Julien Levasseur ##
## Date: 2009-03-16 ##
## Version: 1.2.1 ##
## Contact: julien.levasseur@free.fr ##
## ##
## For Java version, contact the autor. ##
## ##
## ------------------------------------------------------------ ##
## Modifications: ##
## ##
## 2010-01-18: Creation of script ##
## ------------------------------------------------------------ ##
##################################################################
#
# Variables definitions
SERVICE="OpenDS"
export SERVICE
XMLEXT=".xml"
export XMLEXT
XMLFILE=${SERVICE}${XMLEXT}
# Main
echo " "
echo "###############################################"
echo "# Install new SMF service from" ${XMLFILE} " #"
echo "###############################################"
echo " "
echo "copying management script"
mkdir -p /opt/svc/method/
cp ${SERVICE} /opt/svc/method
chmod +x /opt/svc/method/${SERVICE}
echo "xml service configuration file copy ..."
cp ${XMLFILE} /var/svc/manifest/system
chmod 0444 /var/svc/manifest/system/${XMLFILE}
echo "Done !"
echo "Load new service configuration onto SMF ..."
svccfg import /var/svc/manifest/system/${XMLFILE}
echo "Done !"
|
Alors comment ça marche ? Et bien vous mettez les trois fichiers dans le même répertoire (où ça vous chante), vous faites un chmod +x install_svc.sh (ou le nom que vous avez donné à l'installateur) puis un ./install_svc.sh.
Et voilà c'est finit  _________________ Sun Fire Blade 1600 - 3 Fire B100s @1xUS IIi 650MHz, 1/2Go RAM, HDD 30Go
Sun Fire 3800 @8xUS III 900MHz, 26Go RAM
Sun W2100z @2xOpteron 252 2.6GHz, 6Go RAM, 546Go
Sun Enterprise 250 @1xUS II 400MHz
Ultra 2 @2x296MHz, 1Go RAM, 2x18Go HDD RAID 1 SVM
Storedge T3+, SS20 - 3 Sunray 1, 1 Sunray 150, 1 SPARCStorage L400
http://hokkaido.homeunix.net |
|
| Revenir en haut |
|
 |
|
|
Vous ne pouvez pas poster de nouveaux sujets dans ce forum Vous ne pouvez pas répondre aux sujets dans ce forum Vous ne pouvez pas éditer vos messages dans ce forum Vous ne pouvez pas supprimer vos messages dans ce forum Vous ne pouvez pas voter dans les sondages de ce forum
|
|
 |
Copyright © 2010, SunQuebec (www.sunquebec.com), tous droits réservés.
Protégé par les lois du copyright des États-Unis et du Canada et par
des traités internationaux.
|
|
 |
|