基于http的软件仓库

这是企业中常用的方法

比如一台服务器准备好了,公司必然要安装一些应用

这时可以用这种方法批量安装应用  

运行一条命令,服务器就会自己去连接软件仓库,去下载来安装。

[root@webmaster html]# ll
total 2680
-rw-r--r-- 1 root root     788 Sep 13 17:40 update_zabbix_agent.sh
-rw-r--r-- 1 root root 2737299 Sep 13 14:56 zabbix_agent.zip
#一个开启autoindex的nginx
#创建一个安装软件的脚本

 

使用者可以通过网页查看相关内容

[root@webmaster html]# cat update_zabbix_agent.sh 
#!/bin/sh
cd /app
if [ -e "/app/zabbix_agent.zip" ]
then
    sleep 5
    echo '1'
    rm -f /app/zabbix_agent.zip
fi
if [ -d "/app/zabbix" ]
then
    rm -fr /app/zabbix
fi
wget --tries=2 http://192.168.10.10/zabbix_agent.zip >>/tmp/update.`date +%Y%m%d-%H`.log

#update zabbix agent
echo '-------------------------'
unzip  zabbix_agent.zip >/dev/null && echo "zabbix directory downloaded sucessfully"
cd zabbix
./sbin/zabbix_agentd -c etc/zabbix_agentd.conf >>/tmp/update.zabbix.`date +%Y%m%d-%H`.log
if [ $? == 0 ]
then
    echo "zabbix agent update success"
    echo "zabbix agent update success" >>/tmp/update.`date +%Y%m%d-%H`.log
else
    echo "zabbix agent update failed"
    echo "zabbix agent update failed" >>/tmp/update.`date +%Y%m%d-%H`.log
fi

  

[root@mysql app]# wget -O update_zabbix_agent.sh  http://192.168.10.10/update_zabbix_agent.sh;sh update_zabbix_agent.sh
--2018-09-14 01:39:38--  http://192.168.10.10/update_zabbix_agent.sh
Connecting to 192.168.10.10:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 788 [application/octet-stream]
Saving to: ‘update_zabbix_agent.sh’

100%[================================================================================================>] 788         --.-K/s   in 0s      

2018-09-14 01:39:38 (63.3 MB/s) - ‘update_zabbix_agent.sh’ saved [788/788]

1
--2018-09-14 01:39:43--  http://192.168.10.10/zabbix_agent.zip
Connecting to 192.168.10.10:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2737299 (2.6M) [application/zip]
Saving to: ‘zabbix_agent.zip’

100%[================================================================================================>] 2,737,299   --.-K/s   in 0.02s   

2018-09-14 01:39:43 (112 MB/s) - ‘zabbix_agent.zip’ saved [2737299/2737299]

-------------------------
zabbix directory downloaded sucessfully
zabbix agent update success
-------------------------
#在服务器上wget这个脚本并执行

  

猜你喜欢

转载自www.cnblogs.com/jabbok/p/9642020.html