Hi, For anything RA, I revised it with some function addition.
The list of the change is as follows. * I added the option which could choose whether you used a login shell to want to let a command inherit an environment variable of Resource Agent. * I revised it to handle an escape character in character string set by cmdline_options such as follows adequately. --- for example: --- primitive AAAAA ocf:heartbeat:anything \ params \ binfile="XXXXX" \ cmdline_options="-V -c \"openssl des-ede3 -d -base64 -k 'yy y'\" -i" \ --- --- * Strip off the trailing clone marker. - quotations from the following. http://hg.clusterlabs.org/pacemaker/stable-1.0/file/94515b3503b5/extra/resources/Dummy#l143 Best Regards, Yuusuke IIDA -- ---------------------------------------- METRO SYSTEMS CO., LTD YuusukeIida Mail: iiday...@intellilink.co.jp ----------------------------------------
--- anything 2010-06-30 19:53:06.000000000 +0900 +++ ../extra/anything 2010-06-30 19:55:42.000000000 +0900 @@ -74,14 +74,14 @@ if [ -n "$logfile" -a -n "$errlogfile" ] then # We have logfile and errlogfile, so redirect STDOUT und STDERR to different files - cmd="su - $user -c \"nohup $binfile $cmdline_options >> $logfile 2>> $errlogfile & \"'echo \$!' " + cmd="su $use_login_shell $user -c \"nohup $binfile $cmdline_options >> $logfile 2>> $errlogfile & \"'echo \$!' " else if [ -n "$logfile" ] then # We only have logfile so redirect STDOUT and STDERR to the same file - cmd="su - $user -c \"nohup $binfile $cmdline_options >> $logfile 2>&1 & \"'echo \$!' " + cmd="su $use_login_shell $user -c \"nohup $binfile $cmdline_options >> $logfile 2>&1 & \"'echo \$!' " else # We have neither logfile nor errlogfile, so we're not going to redirect anything - cmd="su - $user -c \"nohup $binfile $cmdline_options & \"'echo \$!'" + cmd="su $use_login_shell $user -c \"nohup $binfile $cmdline_options & \"'echo \$!'" fi fi ocf_log debug "Starting $process: $cmd" @@ -165,15 +165,24 @@ fi } -# FIXME: Attributes special meaning to the resource id -process="$OCF_RESOURCE_INSTANCE" +if [ ${OCF_RESKEY_CRM_meta_globally_unique} = "false" ]; then + # Strip off the trailing clone marker + process=`echo ${OCF_RESOURCE_INSTANCE} | sed s/:[0-9][0-9]//` +else + process="$OCF_RESOURCE_INSTANCE" +fi binfile="$OCF_RESKEY_binfile" -cmdline_options="$OCF_RESKEY_cmdline_options" +cmdline_options=`echo "$OCF_RESKEY_cmdline_options" | sed 's/\\\/\\\\\\\/g' | sed 's/\"/\\\"/g'` pidfile="$OCF_RESKEY_pidfile" [ -z "$pidfile" ] && pidfile=${HA_VARRUN}/anything_${process}.pid logfile="$OCF_RESKEY_logfile" errlogfile="$OCF_RESKEY_errlogfile" user="$OCF_RESKEY_user" +if [ ocf_is_true $OCF_RESKEY_use_login_shell ]; then + use_login_shell="-" +else + use_login_shell="" +fi [ -z "$user" ] && user=root anything_validate() { @@ -268,6 +277,13 @@ <shortdesc lang="en">Seconds to wait after having sent SIGTERM before sending SIGKILL in stop operation</shortdesc> <content type="string" default=""/> </parameter> +<parameter name="use_login_shell"> +<longdesc lang="en"> +It is setting to decide whether you use a login shell in a user carrying out a command. +</longdesc> +<shortdesc lang="en">Setting whether or not I use a login shell</shortdesc> +<content type="string" default="true"/> +</parameter> </parameters> <actions> <action name="start" timeout="20s" />
_______________________________________________________ Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev Home Page: http://linux-ha.org/