基于https通信,可以使用OCS的IPdiscover功能。
-rw-r--r--. 1 root root 59M 8月 20 16:57 linux-ocs-agent.tar.gz
链接:http://pan.baidu.com/s/1pJKK4w7 密码:a0re
Ready Go!
===================================================
tar xf OCS_Agent0812.1028.tar.gz
2,【执行安装】【没有root权限会报错,提示用 sudo su】
root@debian:/home# cd linux/
root@debian:/home/linux/# ./install.sh
3,【输入机器的资产编号,不要输错!】
Vobile: Enter TAG on this machine :
【显示Successful! 说明客户端安装成功,下面会显示这个机器的当前分钟是多少】
Successful!
57
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
| #!/bin/bash
# cacert.pem
# deb.txt
# yum packages
# Ocsinventory-agent
# fix cron time
# fix sync time
# if test ok,modify debug=0
# 2015.08.14 fix redhat linux yum depend problems
# 2015.08.14 fix seting cron time
# 2015.08.17 grep Successful or break
#
export PATH=$PATH:.
clear
setterm -blank 0
root_id=`id -u`
if [ $root_id -ne 0 ] ; then
{
clear
echo -e "\033[40;37mWarning: you are not root user ! \n\n[Please use Command line ]$ sudo su \n\n \033[0m"
exit 10
}
fi
#judenment operation OS ************************************
rm -rf /etc/ocsinventory* #rm old agent conf
if [ -f /etc/redhat-release ]
then
OS=1
elif [ -f /etc/debian_version ]
then
OS=2
else
clear
echo "No support Operating system !"
fi
# Debian ********************************
if [ $OS -eq 2 ] ;then
echo "Debian Linux"
sleep 1
cp /etc/apt/sources.list /etc/apt/sources.listbak
sed -i '1r deb.txt' /etc/apt/sources.list
mkdir /etc/ocsinventory-agent
cp -f ./cacert.pem /etc/ocsinventory-agent/
apt-get -y install ntpdate dmidecode libxml-simple-perl libnet-ip-perl libwww-perl perl libnet-ssleay-perl libcrypt-ssleay-perl libnet-snmp-perl libproc-pid-file-perl libproc-daemon-perl net-tools libsys-syslog-perl pciutils smartmontools read-edid nmap make
stat=`echo $?`
clear
cp -f /etc/apt/sources.listbak /etc/apt/sources.list
fi
# RedHat OS ********************************
if [ $OS -eq 1 ] ;then
echo "Redhat Linux "
sleep 1
mkdir -p /etc/ocsinventory-agent
cp -f ./cacert.pem /etc/ocsinventory-agent/
yum -y --nogpgcheck localinstall ./packages/*.rpm
stat=`echo $?`
fi
# sync time ****************************************
echo "sync time......"
ntpdate 210.72.145.44
ntpdate cn.pool.ntp.org
# make && make install *******************************
if [ $stat -eq 0 ] ;then
# read input Parameter
clear
while [ 1 ]
do
echo -en "\033[47;34;7mWarning: Enter TAG on this machine :\033[0m"
read tag
leng1=`echo ${tag} | wc -L|bc`
if [ $leng1 -lt 5 ]
then
clear
echo -e "\033[40;36;7mWarning:TAG more than 5 length.:\033[0m"
else
break
fi
done
# read input time for cron
while [ 1 ]
do
echo -en "\033[47;34;7mHello: How many hours do you want executive OCS Agent ?\033[0m [1-23]/ [2]?:"
read time1
if [ -z "$time1" ];then
time1=2
fi
time2=`echo ${time1} |bc`
if [ $time2 -ge 1 -a $time2 -le 23 ]
then
time3=$time2
break
else
echo "Warning: input error ,please try again."
fi
done
cd Ocsinventory-Unix-Agent-2.1.1
make clean
env PERL_AUTOINSTALL=1 perl Makefile.PL && make && make install && perl postinst.pl --nowizard --remove-old-linux-agent --server=https://your_OCSNG-Server_IP/ocsinventory --crontab --tag=$tag --debug --logfile=/etc/ocsinventory-agent/ocs.log --ca=/etc/ocsinventory-agent/cacert.pem --snmp --now
grep Cannot /etc/ocsinventory-agent/ocs.log > /dev/null 2>&1
stat2=`echo $?`
else
clear
echo "warning:Dependency relationship No solution ."
exit 2
fi
# set for cron *********************************************************
if [ $stat2 -ne 0 ] ;then
clear
echo "install ocsinventory-agent Successful !"
sleep 2
# modify ocsNG agent conf.file debug=0
sed -i "s#debug=1#debug=0#g" /etc/ocsinventory-agent/ocsinventory-agent.cfg
a=`date +%M`
b=`echo "$a"|bc`
sed -i '2d' /etc/cron.d/ocsinventory-agent
echo "$b */$time3 * * * root /usr/local/bin/ocsinventory-agent --lazy > /dev/null 2>&1" >> /etc/cron.d/ocsinventory-agent
stat3=`echo $?`
if [ $stat3 -eq 0 ] ;then
if [ $OS -eq 2 ] ;then #debian
/etc/init.d/cron restart
stat4=`echo $?`
fi
if [ $OS -eq 1 ] ;then #redHat
service crond reload
stat4=`echo $?`
fi
fi
else
clear
date
echo "Warning:install error ,please try again [ ./install.sh ]"
exit 2
fi
if [ $stat4 -eq 0 ] ;then
clear
echo "your machine TAG :$tag"
grep debug=0 /etc/ocsinventory-agent/ocsinventory-agent.cfg
echo -en "install ocsinventory-agent Successful!\n\nThe current time: "
tail -n 1 /etc/cron.d/ocsinventory-agent | cut -d " " -f1
else
clear
echo "Warning:cron error "
exit 2
fi
|
=======一键自动化安装脚本结束==============================================
|