drdbdisk script

#!/bin/bash

#

# This script is inteded to be used as resource script by heartbeat

#

# Copright 2003-2008 LINBIT Information Technologies

# Philipp Reisner, Lars Ellenberg

#

###

DEFAULTFILE="/etc/default/drbd"

DRBDADM="/sbin/drbdadm"

if [ -f $DEFAULTFILE ]; then

. $DEFAULTFILE

fi

if [ "$#" -eq 2 ]; then

RES="$1"

CMD="$2"

else

RES="all"

CMD="$1"

fi

## EXIT CODES

# since this is a "legacy heartbeat R1 resource agent" script,

# exit codes actually do not matter that much as long as we conform to

#  http://wiki.linux-ha.org/HeartbeatResourceAgent

# but it does not hurt to conform to lsb init-script exit codes,

# where we can.

#  http://refspecs.linux-foundation.org/LSB_3.1.0/

#       LSB-Core-generic/LSB-Core-generic/iniscrptact.html

####

drbd_set_role_from_proc_drbd()

{

local out

if ! test -e /proc/drbd; then

ROLE="Unconfigured"

return

fi

dev=$( $DRBDADM sh-dev $RES )

minor=${dev#/dev/drbd}

if [[ $minor = *[!0-9]* ]] ; then

# sh-minor is only supported since drbd 8.3.1

minor=$( $DRBDADM sh-minor $RES )

fi

if [[ -z $minor ]] || [[ $minor = *[!0-9]* ]] ; then

ROLE=Unknown

return

fi

if out=$(sed -ne "/^ *$minor: cs:/ { s/:/ /g; p; q; }" /proc/drbd); then

set -- $out

ROLE=${5%/*}

: ${ROLE:=Unconfigured} # if it does not show up

else

ROLE=Unknown

fi

}

case "$CMD" in

start)

# try several times, in case heartbeat deadtime

# was smaller than drbd ping time

try=6

while true; do

$DRBDADM primary $RES && break

let "--try" || exit 1 # LSB generic error

sleep 1

done

;;

stop)

# heartbeat (haresources mode) will retry failed stop

# for a number of times in addition to this internal retry.

try=3

while true; do

$DRBDADM secondary $RES && break

# We used to lie here, and pretend success for anything != 11,

# to avoid the reboot on failed stop recovery for "simple

# config errors" and such. But that is incorrect.

# Don‘t lie to your cluster manager.

# And don‘t do config errors...

let --try || exit 1 # LSB generic error

sleep 1

done

;;

status)

if [ "$RES" = "all" ]; then

echo "A resource name is required for status inquiries."

exit 10

fi

ST=$( $DRBDADM role $RES )

ROLE=${ST%/*}

case $ROLE in

Primary|Secondary|Unconfigured)

# expected

;;

*)

# unexpected. whatever...

# If we are unsure about the state of a resource, we need to

# report it as possibly running, so heartbeat can, after failed

# stop, do a recovery by reboot.

# drbdsetup may fail for obscure reasons, e.g. if /var/lock/ is

# suddenly readonly.  So we retry by parsing /proc/drbd.

drbd_set_role_from_proc_drbd

esac

case $ROLE in

Primary)

echo "running (Primary)"

exit 0 # LSB status "service is OK"

;;

Secondary|Unconfigured)

echo "stopped ($ROLE)"

exit 3 # LSB status "service is not running"

;;

*)

# NOTE the "running" in below message.

# this is a "heartbeat" resource script,

# the exit code is _ignored_.

echo "cannot determine status, may be running ($ROLE)"

exit 4 #  LSB status "service status is unknown"

;;

esac

;;

*)

echo "Usage: drbddisk [resource] {start|stop|status}"

exit 1

;;

esac

exit 0

时间: 2024-08-29 00:01:10

drdbdisk script的相关文章

使用RemObjects Pascal Script (转)

http://www.cnblogs.com/MaxWoods/p/3304954.html 摘自RemObjects Wiki 本文提供RemObjects Pascal Script的整体概要并演示如何创建一些简单的脚本. Pascal Script包括两个不同部分: 编译器 (uPSCompiler.pas) 运行时 (uPSRuntime.pas) 两部分彼此独立.可以分开使用,或通过TPSScript 控件使用他们,这个控件定义在uPSComponent.pas单元,对这两个部分进行简

-Dmaven.multiModuleProjectDirectory system property is not set. Check $M2_HOME environment variable and mvn script match.chan

第一次使用Maven ,在eclipse中执行pom.xml文件的时候报错. -Dmaven.multiModuleProjectDirectory system propery is not set. Check $M2_HOME environment variable and mvn script match. 参考网上的解决方案: 设一个环境变量M2_HOME指向你的maven安装目录 M2_HOME=D:\Apps\apache-maven-3.3.1 然后在Window->Prefe

salt cmd.script

salt '*' cmd.script cmd.run  这个前面说了 cmd.script 这个是比较强大的命令,意思是可以从远程下载一个脚本在客户端执行 CLIExample: salt '*' cmd.script salt://scripts/runme.sh salt '*' cmd.script salt://scripts/runme.sh 'arg1 arg2 "arg 3"' 帮助文档说Thescript can be located on the salt mast

vs 2012 调试不了js -- solution 中script document显示不出来

背景: 因为项目的需要,从ie8升级到ie11(并且自动更新安装了几个ie11的补丁),升级后想用vs2012 调试asp.net项目中的js 但是发现solution中script document项目没有在项目中运行时启动,js不能打断点(***的空心圈). 解决过程: 这个同组的同事以前遇到过,并且解决了,所以向他请教,无果,不知道怎么解决的... 搜索了一下不能打断点的提示信息,网上给的说法是高级设置ie中禁掉第三方的调试工具选项前面的勾去掉,无果:这个和我的问题没有关系. 之前有同事更

Why to Write Shell Script

Why to Write Shell Script ? Shell script can take input from user, file and output them on screen. Useful to create our own commands. Save lots of time. To automate some task of day today life. System Administration part can be also automated.

学习shell script

如果你的想要管理好你的主机,那么就要好好学习自动管理系统的有效工具--hell script!基本上,shell script有点像早期的批处理文件,即将很多命令整合起来一次执行,但是shell script拥有更强大的功能,它可以进行类似程序的编写,并且不需要经过编译就能够执行,非常方便我们对系统进行管理. 今天我们主要通过对一些shell script的习题来加深对脚本知识的学习. 习题1:对成绩进行判断,要求输入一个正整数,以60分,85分为界输出不同的评语. #!/bin/bash #

编译脚本支持(Build script support)

查看原文:Build Script Support 有些包需要编译第三方的非Rust代码,比如说C库.其他包需要链接到C库,这些C库可能位于系统磁盘上,也有可能需要从源代码中构建.其他人仍然需要一些功能,比如在构建之前的代码生成(考虑解释器生成器)(没明白是什么意思). Cargo并不是为了取代这些针对这些任务进行了良好优化的其他工具,但是它确实与构建配置选项集成在一起了: 一.如何使用构建脚本 在Cargo.toml文件中 [package] # ... build = "build.rs&q

Eclipse运行Maven命令时出现:-Dmaven.multiModuleProjectDirectory system property is not set. Check $M2_HOME environment variable and mvn script match.问题解决

错误: -Dmaven.multiModuleProjectDirectory system property is not set. Check $M2_HOME environment variable and mvn script match. 这个错误是由于Maven版本与当前IDE不兼容导致的,解决方法如下: 1.Maven降级. 2.升级IDE. 3.可以尝试这个方法:

zabbix 通过执行script发送告警消息

一.写在配置步骤前的话 可以在zabbix web前端设置自动消息告警机制,在http://afterdawn.blog.51cto.com/7503144/1923812 文档中已经介绍过了,下面介绍zabbix通过自动执行Linux主机上的script脚本来进行告警,该告警方式zabbix会传递三个参数并执行定义脚本. script:用来定义信息通道,完成信息传递的脚本: (1)脚本放置位置zabbix_server端:/etc/zabbix/zabbix_server.conf Alert