Skip to content

Commit f2f21ca

Browse files
committed
add manager.sh & fix Readme.md 👌
1 parent f81655b commit f2f21ca

File tree

2 files changed

+104
-1
lines changed

2 files changed

+104
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
[![GitHub forks](https://img.shields.io/github/forks/aimerforreimu/AUXPI.svg)](https://github.com/aimerforreimu/AUXPI/network)
1010
[![GitHub stars](https://img.shields.io/github/stars/aimerforreimu/AUXPI.svg)](https://github.com/aimerforreimu/AUXPI/stargazers)
1111
[![GitHub license](https://img.shields.io/github/license/aimerforreimu/AUXPI.svg)](https://github.com/aimerforreimu/AUXPI)
12+
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Faimerforreimu%2Fauxpi.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Faimerforreimu%2Fauxpi?ref=badge_shield)
13+
1214

1315
![Snipaste_2019-05-12_22-16-26.png](https://i.loli.net/2019/05/12/5cd82ac5cd74d.png)
1416
</div>
@@ -27,7 +29,6 @@
2729
## 项目截图
2830

2931
![首页](https://ws2.sinaimg.cn/large/007DFgJwgy1g10ecblh1dj31hc0nw770.jpg)
30-
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Faimerforreimu%2Fauxpi.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Faimerforreimu%2Fauxpi?ref=badge_shield)
3132

3233
![管理员后台](https://ws3.sinaimg.cn/large/007DFgJwgy1g10eavu2zqj31ha0obdii.jpg)
3334

manager.sh

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
#!/bin/bash
2+
3+
SERVER="auxpi"
4+
BASE_DIR=$PWD
5+
INSTALL_DIR="/root/auxpi"
6+
INTERVAL=2
7+
8+
ARGS=""
9+
10+
#color
11+
INFO_FONT_PREFIX="\033[32m"
12+
ERROR_FONT_PREFIX="\033[31m"
13+
INFO_BACKGROUND_PREFIX="\033[42;37m"
14+
ERROR_BACKGROUND_PREFIX="\033[41;37m"
15+
FONT_SUFFIX="\033[0m"
16+
17+
18+
#text block
19+
INFO_BLOCK=${INFO_FONT_PREFIX}"[INFO]:"${FONT_SUFFIX}
20+
ERROR_BLOCK=${ERROR_FONT_PREFIX}"[ERROR]:"${FONT_SUFFIX}
21+
22+
function start()
23+
{
24+
if [[ "`pgrep $SERVER -u $UID`" != "" ]];then
25+
echo -e ${ERROR_BLOCK} "$SERVER already running"
26+
exit 1
27+
fi
28+
nohup ${BASE_DIR}/${SERVER} &> ${INSTALL_DIR}/auxpi.out &
29+
30+
echo -e ${INFO_BLOCK} "sleeping & checking ..." && sleep ${INTERVAL}
31+
32+
# check status
33+
if [[ "`pgrep $SERVER -u $UID`" == "" ]];then
34+
echo -e ${ERROR_BLOCK} "$SERVER start failed"
35+
echo -e ${INFO_BLOCK} "start by install dir"
36+
nohup ${INSTALL_DIR}/${SERVER} &> ${INSTALL_DIR}/auxpi.out &
37+
exit 1
38+
else
39+
echo -e ${INFO_BLOCK} "start success"
40+
exit 1
41+
fi
42+
43+
echo -e ${INFO_BLOCK} "sleeping & checking ......" && sleep ${INTERVAL}
44+
45+
# check status
46+
if [[ "`pgrep $SERVER -u $UID`" == "" ]];then
47+
echo -e ${ERROR_BLOCK} "$SERVER start failed"
48+
exit 1
49+
else
50+
echo -e ${INFO_BLOCK} "start success"
51+
fi
52+
53+
}
54+
55+
function status()
56+
{
57+
if [[ "`pgrep $SERVER -u $UID`" != "" ]];then
58+
echo -e ${ERROR_BLOCK} ${SERVER} is running
59+
else
60+
echo -e ${INFO_BLOCK} ${SERVER} is not running
61+
fi
62+
}
63+
64+
function stop()
65+
{
66+
67+
68+
if [[ "`pgrep $SERVER -u $UID`" != "" ]];then
69+
kill -9 `pgrep ${SERVER} -u $UID`
70+
else
71+
echo -e ${ERROR_BLOCK} ${SERVER} has already stopped.
72+
exit 1
73+
fi
74+
75+
echo -e ${INFO_BLOCK} "sleeping & checking ......" && sleep ${INTERVAL}
76+
77+
if [[ "`pgrep $SERVER -u $UID`" != "" ]];then
78+
echo -e ${ERROR_BLOCK} "$SERVER stop failed"
79+
exit 1
80+
else
81+
echo -e ${INFO_BLOCK} "stop success"
82+
fi
83+
}
84+
85+
case "$1" in
86+
'start')
87+
start
88+
;;
89+
'stop')
90+
stop
91+
;;
92+
'status')
93+
status
94+
;;
95+
'restart')
96+
stop && start
97+
;;
98+
*)
99+
echo "usage: $0 {start|stop|restart|status}"
100+
exit 1
101+
;;
102+
esac

0 commit comments

Comments
 (0)