-
Notifications
You must be signed in to change notification settings - Fork 0
/
pno.sh
executable file
·153 lines (136 loc) · 2.33 KB
/
pno.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#!/bin/bash
APPLIST=(
"thunderbird"
"pidgin"
"goldendict"
"google-chrome"
"eclipse"
)
SRC_LIST=(
"/home/qiaoliyong/sda/code/libvirt"
"/home/qiaoliyong/sda/code/qemu"
)
usage() {
cat << EOF
usage: $0 [options]
-s Show the apps run list.
-l List the app lists.
-r Restart all apps.
-k Kill all apps.
-m Maintain all apps.
Example:
$0
EOF
}
# pull git
function pull_git()
{
cd $1
git pull
cd -
}
# pull all git in SRC_LIST
function pull_all_git()
{
for src in "${SRC_LIST[@]}"; do
pull_git ${src}
done
}
function extr_app()
{
sudo libvirtd -d
sudo virsh start xp
}
# kill $1
function kill_bin()
{
APP=$1
ps -ef | grep ${APP} | grep -v grep | awk '{print $2}' | xargs kill -9 >/dev/null 2>&1
return $?
}
function run_bin()
{
APP=$1
/usr/bin/${APP} &
return $?
}
function show_app()
{
echo "App Running list .... "
for app in "${APPLIST[@]}"; do
ps -ef | grep ${app} | grep -v "grep" >/dev/null 2>&1
if [[ $? -eq 0 ]]; then
echo $app is running...
fi
done
}
function restart_app()
{
echo ""
for app in "${APPLIST[@]}"; do
kill_bin $app
run_bin $app
done
}
function list_app()
{
for app in "${APPLIST[@]}"; do
echo $app
done
}
function maintain_app()
{
for app in "${APPLIST[@]}"; do
ps -ef | grep ${app} | grep -v "grep" >/dev/null 2>&1
if [[ ! $? -eq 0 ]]; then
echo "starting ${app}"
run_bin ${app}
fi
done
}
function kill_all()
{
for app in "${APPLIST[@]}"; do
echo "killing ${app}"
kill_bin $app
done
}
while getopts "hsrlmk" OPTION
do
case $OPTION in
h)
usage
exit 1
;;
s)
show_app
;;
r)
restart_app
;;
l)
list_app
;;
m)
maintain_app
;;
k)
kill_all
;;
?)
usage
exit 1
;;
esac
done
if [[ $# -eq 0 ]]; then
echo "Maintain ..."
maintain_app
fi
pull_all_git
/home/qiaoliyong/mybin/bso.sh ltcphx.austin.ibm.com
/home/qiaoliyong/mybin/bso.sh 9.181.129.110
sleep 10
ssh -qTfnN -D 8080 [email protected]
python /home/qiaoliyong/Downloads/goagent-goagent-6287469/local/proxy.py
#extr_app