[Cluster-devel] cluster/rgmanager/src/resources samba.metadata ...
mgrac at sourceware.org
mgrac at sourceware.org
Tue Sep 26 23:18:44 UTC 2006
CVSROOT: /cvs/cluster
Module name: cluster
Changes by: mgrac at sourceware.org 2006-09-26 23:18:44
Added files:
rgmanager/src/resources: samba.metadata samba.sh
Log message:
Adding Samba resource agent (tag <samba>). We already have resource agent for Samba but this is written in the same way as the other application's RA (mysql, apache, ...). Old-style RA stays available (tag <smb>) so it won't break backward compatibility.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/samba.metadata.diff?cvsroot=cluster&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/samba.sh.diff?cvsroot=cluster&r1=NONE&r2=1.1
/cvs/cluster/cluster/rgmanager/src/resources/samba.metadata,v --> standard output
revision 1.1
--- cluster/rgmanager/src/resources/samba.metadata
+++ - 2006-09-26 23:18:44.542633000 +0000
@@ -0,0 +1,79 @@
+<?xml version="1.0"?>
+<resource-agent version="rgmanager 2.0" name="samba">
+ <version>1.0</version>
+
+ <longdesc lang="en">
+ Dynamic smbd/nmbd resource agent
+ </longdesc>
+ <shortdesc lang="en">
+ Dynamic smbd/nmbd resource agent
+ </shortdesc>
+
+ <parameters>
+ <parameter name="name" unique="1" primary="1">
+ <longdesc lang="en">
+ Samba Symbolic Name.
+ </longdesc>
+ <shortdesc lang="en">
+ Samba Name
+ </shortdesc>
+ <content type="string"/>
+ </parameter>
+
+ <parameter name="config_file">
+ <longdesc lang="en">
+ Define absolute path to configuration file
+ </longdesc>
+ <shortdesc lang="en">
+ Config File
+ </shortdesc>
+ <content type="string" default="/etc/samba/smb.conf"/>
+ </parameter>
+
+ <parameter name="smbd_options">
+ <longdesc lang="en">
+ Other command-line options for smbd
+ </longdesc>
+ <shortdesc lang="en">
+ Other command-line options for smbd
+ </shortdesc>
+ <content type="string" />
+ </parameter>
+
+ <parameter name="nmbd_options">
+ <longdesc lang="en">
+ Other command-line options for nmbd
+ </longdesc>
+ <shortdesc lang="en">
+ Other command-line options for nmbd
+ </shortdesc>
+ <content type="string" />
+ </parameter>
+
+ <parameter name="service_name" inherit="service%name">
+ <longdesc lang="en">
+ Inherit the service name. We need to know
+ the service name in order to determine file
+ systems and IPs for this smb service.
+ </longdesc>
+ <shortdesc lang="en">
+ Inherit the service name.
+ </shortdesc>
+ <content type="string"/>
+ </parameter>
+ </parameters>
+
+ <actions>
+ <action name="start" timeout="0"/>
+ <action name="stop" timeout="0"/>
+
+ <!-- This is just a wrapper for LSB init scripts, so monitor
+ and status can't have a timeout, nor do they do any extra
+ work regardless of the depth -->
+ <action name="status" interval="30s" timeout="0"/>
+ <action name="monitor" interval="30s" timeout="0"/>
+
+ <action name="meta-data" timeout="0"/>
+ <action name="verify-all" timeout="0"/>
+ </actions>
+</resource-agent>
/cvs/cluster/cluster/rgmanager/src/resources/samba.sh,v --> standard output
revision 1.1
--- cluster/rgmanager/src/resources/samba.sh
+++ - 2006-09-26 23:18:44.733417000 +0000
@@ -0,0 +1,244 @@
+#!/bin/bash
+
+#
+# Copyright Red Hat, Inc. 2006
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2, or (at your option) any
+# later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; see the file COPYING. If not, write to the
+# Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
+# MA 02139, USA.
+#
+#
+# Author(s):
+# Marek Grac (mgrac at redhat.com)
+#
+
+export LC_ALL=C
+export LANG=C
+export PATH=/bin:/sbin:/usr/bin:/usr/sbin
+
+. $(dirname $0)/ocf-shellfuncs
+. $(dirname $0)/utils/config-utils.sh
+. $(dirname $0)/utils/messages.sh
+. $(dirname $0)/utils/ra-skelet.sh
+
+declare SAMBA_SMBD=/usr/sbin/smbd
+declare SAMBA_NMBD=/usr/sbin/nmbd
+declare SAMBA_pid_dir="`generate_name_for_pid_dir`"
+declare SAMBA_smbd_pid_file="$SAMBA_pid_dir/smbd.pid"
+declare SAMBA_nmbd_pid_file="$SAMBA_pid_dir/nmbd.pid"
+declare SAMBA_gen_config_file="/tmp/samba.$OCF_RESKEY_name"
+
+verify_all()
+{
+ clog_service_verify $CLOG_INIT
+
+ if [ -z "$OCF_RESKEY_name" ]; then
+ clog_service_verify $CLOG_FAILED "Invalid Name Of Service"
+ return $OCF_ERR_ARGS
+ fi
+
+ if [ -z "$OCF_RESKEY_config_file" ]; then
+ clog_check_file_exist $CLOG_FAILED_INVALID "$OCF_RESKEY_config_file"
+ clog_service_verify $CLOG_FAILED
+ return $OCF_ERR_ARGS
+ fi
+
+ if [ ! -r "$OCF_RESKEY_config_file" ]; then
+ clog_check_file_exist $CLOG_FAILED_NOT_READABLE $OCF_RESKEY_config_file
+ clog_service_verify $CLOG_FAILED
+ return $OCF_ERR_ARGS
+ fi
+
+ clog_service_verify $CLOG_SUCCEED
+
+ return 0
+}
+
+generate_config_file()
+{
+ declare original_file="$1"
+ declare generated_file="$2"
+ declare ip_addresses="$3"
+
+ if [ -f "$generated_file" ]; then
+ sha1_verify "$generated_file"
+ if [ $? -ne 0 ]; then
+ clog_check_sha1 $CLOG_FAILED
+ return 0
+ fi
+ fi
+
+ clog_generate_config $CLOG_INIT "$original_file" "$generated_file"
+
+ generate_configTemplate "$generated_file" "$1"
+
+ echo "pid directory = \"$SAMBA_pid_dir\"" >> $generated_file
+ echo "interfaces = $ip_addresses" >> $generated_file
+ echo "bind interfaces only = Yes" >> $generated_file
+ echo "netbios name = \"$OCF_RESKEY_name\"" >> $generated_file
+ echo >> $generated_file
+ sed 's/^[[:space:]]*pid directory/### pid directory/i;s/^[[:space:]]*interfaces/### interfaces/i;s/^[[:space:]]*bind interfaces only/### bind interfaces only/i;s/^[[:space:]]*netbios name/### netbios name/i' \
+ < "$original_file" >> "$generated_file"
+
+ sha1_addToFile "$generated_file"
+ clog_generate_config $CLOG_SUCCEED "$original_file" "$generated_file"
+
+ return 0;
+}
+
+start()
+{
+ declare ccs_fd;
+
+ clog_service_start $CLOG_INIT
+
+ create_pid_directory
+ mkdir -p "$SAMBA_pid_dir"
+
+ if [ -e "$SAMBA_smbd_pid_file" ]; then
+ clog_check_pid $CLOG_FAILED "$SAMBA_smbd_pid_file"
+ clog_service_start $CLOG_FAILED
+ return $OCF_ERR_GENERIC
+ fi
+
+ if [ -e "$SAMBA_nmbd_pid_file" ]; then
+ clog_check_pid $CLOG_FAILED "$SAMBA_nmbd_pid_file"
+ clog_service_start $CLOG_FAILED
+ return $OCF_ERR_GENERIC
+ fi
+
+ clog_looking_for $CLOG_INIT "IP Addresses"
+
+ ccs_fd=$(ccs_connect);
+ if [ $? -ne 0 ]; then
+ clog_looking_for $CLOG_FAILED_CCS
+ return $OCF_ERR_GENERIC
+ fi
+
+ get_service_ip_keys "$ccs_fd" "$OCF_RESKEY_service_name"
+ ip_addresses=`build_ip_list "$ccs_fd"`
+
+ if [ -z "$ip_addresses" ]; then
+ clog_looking_for $CLOG_FAILED_NOT_FOUND "IP Addresses"
+ return $OCF_ERR_GENERIC
+ fi
+
+ clog_looking_for $CLOG_SUCCEED "IP Addresses"
+
+ generate_config_file "$OCF_RESKEY_config_file" "$SAMBA_gen_config_file" "$ip_addresses"
+
+ $SAMBA_SMBD -D -s "$SAMBA_gen_config_file" $OCF_RESKEY_smbd_options
+
+ if [ $? -ne 0 ]; then
+ clog_service_start $CLOG_FAILED
+ return $OCF_ERR_GENERIC
+ fi
+
+ $SAMBA_NMBD -D -s "$SAMBA_gen_config_file" $OCF_RESKEY_nmbd_options
+
+ if [ $? -ne 0 ]; then
+ clog_service_start $CLOG_FAILED
+ return $OCF_ERR_GENERIC
+ fi
+
+ clog_service_start $CLOG_SUCCEED
+
+ return 0;
+}
+
+stop()
+{
+ clog_service_stop $CLOG_INIT
+
+ stop_generic "$SAMBA_smbd_pid_file"
+
+ if [ $? -ne 0 ]; then
+ clog_service_stop $CLOG_FAILED
+ return $OCF_ERR_GENERIC
+ fi
+
+ stop_generic "$SAMBA_nmbd_pid_file"
+
+ if [ $? -ne 0 ]; then
+ clog_service_stop $CLOG_FAILED
+ return $OCF_ERR_GENERIC
+ fi
+
+ if [ -e "$SAMBA_smbd_pid_file" ]; then
+ rm -f "$SAMBA_smbd_pid_file"
+ fi
+
+ if [ -e "$SAMBA_nmbd_pid_file" ]; then
+ rm -f "$SAMBA_nmbd_pid_file"
+ fi
+
+ clog_service_stop $CLOG_SUCCEED
+ return 0;
+}
+
+status()
+{
+ clog_service_status $CLOG_INIT
+
+ status_check_pid "$SAMBA_smbd_pid_file"
+
+ if [ $? -ne 0 ]; then
+ clog_service_status $CLOG_FAILED "$SAMBA_smbd_pid_file"
+ return $OCF_ERR_GENERIC
+ fi
+
+ status_check_pid "$SAMBA_nmbd_pid_file"
+
+ if [ $? -ne 0 ]; then
+ clog_service_status $CLOG_FAILED "$SAMBA_nmbd_pid_file"
+ return $OCF_ERR_GENERIC
+ fi
+
+ clog_service_status $CLOG_SUCCEED
+ return 0
+}
+
+case $1 in
+ meta-data)
+ cat `echo $0 | sed 's/^\(.*\)\.sh$/\1.metadata/'`
+ exit 0
+ ;;
+ verify-all)
+ verify_all
+ exit $?
+ ;;
+ start)
+ verify_all && start
+ exit $?
+ ;;
+ stop)
+ verify_all && stop
+ exit $?
+ ;;
+ status|monitor)
+ verify_all
+ status
+ exit $?
+ ;;
+ restart)
+ verify_all
+ stop
+ start
+ exit $?
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|status|monitor|restart|meta-data|verify-all}"
+ exit $OCF_ERR_GENERIC
+ ;;
+esac
More information about the Cluster-devel
mailing list