Skip to content

Commit 99dab2b

Browse files
committed
2 parents 9e39162 + d277231 commit 99dab2b

File tree

3 files changed

+36
-3
lines changed

3 files changed

+36
-3
lines changed

bashrc/AUTHORS.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#! /bin/sh
2+
3+
# Create the AUTHORS file, by searching the git history.
4+
5+
# Run as "AUTHORS.sh" to get complete history
6+
# Run with "AUTHORS.sh commitish..commitish" for history between tags
7+
8+
# shortlog will canonicalize the names using the file .mailmap
9+
git shortlog -s ${1-} |
10+
cut -b8- # strip the commit counts

bashrc/oneline_cmd

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,3 +197,9 @@ ps aux | awk '{if($1=="root") print $(NF-1)}'
197197
#127.0.0.1:6379> config set maxclients 10000
198198
#127.0.0.1:6379> monitor
199199

200+
# rpm usage
201+
# rpm -qa --nosignature | grep elastic # skip signature query
202+
# rpm -e -vv --nosignature elasticsearch-1.5.2-1 # skip signature uninstall
203+
# cd /var/lib/rpm && rm -rf __db* # rm lock file for rpm no respose.
204+
# rpm -ivh -vv --force --nosignature elasticsearch-1.5.1.rpm
205+

bashrc/threads.sh

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@ CURDIR=$(cd "$(dirname "$0")"; pwd);
1111
g_HOST_LIST=$1
1212
g_THREAD_NUM=300
1313
g_PORT=22
14+
g_LIMIT=0
1415
TMPFILE="pipe.$$"
1516
SSH="ssh -n -o PasswordAuthentication=no -o StrictHostKeyChecking=no -o ConnectTimeout=5 "
1617
SCP='scp -q -r -o PasswordAuthentication=no -o StrictHostKeyChecking=no -o ConnectTimeout=5 '
1718

19+
RET_OK=0
20+
RET_FAIL=1
21+
1822
##################### function #########################
1923
_report_err() { echo "${MYNAME}: Error: $*" >&2 ; }
2024

@@ -46,6 +50,7 @@ Options:
4650
-c, --concurrent num Thread Nummber for run the command at same time, default: 1.
4751
-s, --ssh Use ssh authorized_keys to login without password query from DB.
4852
-p, --port Use port instead of defult port:22.
53+
-l, --limit Limit num for host to run when limit less then all host num.
4954
-h, --help Print this help infomation.
5055
5156
Require:
@@ -56,7 +61,7 @@ Notice:
5661
please check the result output under log/hostname.
5762
USAGE
5863

59-
exit 1
64+
exit $RET_OK
6065
}
6166

6267
#
@@ -81,6 +86,10 @@ _parse_options()
8186
g_PORT=${2}
8287
shift 2
8388
;;
89+
-l|--limit)
90+
g_LIMIT=${2}
91+
shift 2
92+
;;
8493
-h|--help)
8594
usage
8695
exit
@@ -103,7 +112,7 @@ _parse_options()
103112

104113
case ${#argv[@]} in
105114
2)
106-
g_HOST_LIST=$(readlink -f "${argv[0]}")
115+
command -v greadlink >/dev/null 2>&1 && g_HOST_LIST=$(greadlink -f "${argv[0]}") || g_HOST_LIST=$(readlink -f "${argv[0]}")
107116
g_CMD="${argv[1]}"
108117
;;
109118
0|*)
@@ -148,6 +157,7 @@ INDEX=0
148157

149158
while read -r HOST
150159
do
160+
HOST=${HOST#*(:space:)}
151161
(( INDEX++ ))
152162
fchar=`echo ${HOST} | cut -c -1`
153163

@@ -162,10 +172,17 @@ do
162172
fi
163173
unset fchar
164174

175+
if [ "x$g_LIMIT" != "x0" ]; then
176+
if [ "$g_LIMIT" -lt "$INDEX" ]; then
177+
_trace "Reach limit num of $g_LIMIT"
178+
break
179+
fi
180+
fi
181+
165182
_trace "[$INDEX] start ${HOST} ......"
166183
read <&9
167184

168-
ping -c 1 -w 3 ${HOST} &>/dev/null
185+
ping -c 1 -W 3 ${HOST} &>/dev/null
169186

170187
if [ $? -ne 0 ]; then
171188
_print_fatal "[$INDEX] Error: ${HOST} is unreachable."

0 commit comments

Comments
 (0)