-
Notifications
You must be signed in to change notification settings - Fork 134
/
start.sh
103 lines (97 loc) · 2.57 KB
/
start.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
#########################################################################
# File Name: start.sh
# Author: meetbill
# mail: [email protected]
# Created Time: 2016-12-30 14:49:49
#########################################################################
#!/bin/bash
CUR_DIR=$(cd `dirname $0`; pwd)
cd ${CUR_DIR}
# Check if user is root
if [ $(id -u) != "0" ]; then
echo "Error: You must be root to run this script, please use root to install"
exit 1
fi
##########################################################process
x=''
NUM=3
function ProcessBar()
{
x=##########$x
printf "install-ZabbixTool:[%-${NUM}0s]\r" $x
sleep 0.1
}
##########################################################process_end
g_BACKUP_DIR=/opt/ZabbixTool_oldbackup
function check_dir()
{
if [[ -d /opt/ZabbixTool ]]
then
if [ ! -d ${g_BACKUP_DIR} ]
then
mkdir -p ${g_BACKUP_DIR}
else
rm -rf ${g_BACKUP_DIR}
mkdir -p ${g_BACKUP_DIR}
fi
mv /opt/ZabbixTool ${g_BACKUP_DIR}/
cp -rf ./ZabbixTool /opt/
else
cp -rf ./ZabbixTool /opt/
fi
ProcessBar
}
function check_config()
{
if [[ ! -f /etc/zabbix_tool/zabbix_config.ini ]]
then
mkdir -p /etc/zabbix_tool
cp ./ZabbixTool/lib_zabbix/etc/zabbix_config.ini /etc/zabbix_tool/
fi
if [[ ! -f /etc/zabbix_tool/zabbix_setting.ini ]]
then
mkdir -p /etc/zabbix_tool
cp ./ZabbixTool/lib_zabbix/etc/zabbix_setting.ini /etc/zabbix_tool/
fi
if [[ ! -f /etc/zabbix_tool/zabbix_tool.ini ]]
then
mkdir -p /etc/zabbix_tool
cp ./ZabbixTool/py_tool/config/zabbix_tool.ini /etc/zabbix_tool/
fi
ProcessBar
}
function check_command()
{
# zabbix_api
if [[ -f /usr/bin/zabbix_api ]]
then
unlink /usr/bin/zabbix_api
ln -s /opt/ZabbixTool/lib_zabbix/zabbix_api.py /usr/bin/zabbix_api
else
ln -s /opt/ZabbixTool/lib_zabbix/zabbix_api.py /usr/bin/zabbix_api
fi
chmod +x /usr/bin/zabbix_api
# zabbix_menu
if [[ -f /usr/bin/zabbix_menu ]]
then
unlink /usr/bin/zabbix_menu
ln -s /opt/ZabbixTool/main.sh /usr/bin/zabbix_menu
else
ln -s /opt/ZabbixTool/main.sh /usr/bin/zabbix_menu
fi
chmod +x /usr/bin/zabbix_menu
# zabbix_tool
if [[ -f /usr/bin/zabbix_tool ]]
then
unlink /usr/bin/zabbix_tool
ln -s /opt/ZabbixTool/main.py /usr/bin/zabbix_tool
else
ln -s /opt/ZabbixTool/main.py /usr/bin/zabbix_tool
fi
chmod +x /usr/bin/zabbix_tool
ProcessBar
}
check_dir
check_config
check_command
echo