欢迎来到代码驿站!

Shell

当前位置:首页 > 脚本语言 > Shell

a10 config backup for aXAPI

时间:2021-03-21 10:31:05|栏目:Shell|点击:
#!/bin/bash 
################################################# 
# 
#   script by Vincent yu 
#   created at 20140306 
#   a10 config backup for aXAPI version: 2.1 
# 
# 
################################################# 
A10IP="1.1.1.1 1.1.1.2"
USER=admin 
PASSWORD=a10 
TODAY=`date "+%Y%m%d"` 
BACKUPDIR=/path/$TODAY 
TIMENOW=`date "+%Y%m%d%H%m"` 
LOG="/tmp/mail"
MAILLIST="ng@ng.com.tw"
 for COUNT in $A10IP do
 METHOD1="method=authenticate&username=$USER&password=$PASSWORD"
 SESSION=`curl -k --data $METHOD1 https://$COUNT/services/rest/V2.1/ | sed -n -e 's/.*\(.*\)<\/session_id>.*/\1/p'` 
 
 if [ ! -d $BACKUPDIR ];then
  mkdir -p $BACKUPDIR 
 fi
 
 GETHOST_M="session_id=$SESSION&method=system.hostname.get"
 GETHOST=`curl -k https://$COUNT/services/rest/V2.1/?$GETHOST_M | sed -n -e 's/.*\(.*\)<\/hostname>.*/\1/p'` 
 FILENAME="$GETHOST-$TIMENOW.tar.gz"
 BACKUP_M="session_id=$SESSION&format=json&method=system.backup"
 BACKUP=`curl -k  https://$COUNT/services/rest/V2.1/?$M -o $BACKUPDIR/$FILENAME` 
 CLOSE_M="session_id=$SESSION&method=session.close"
 CLOSE=`curl -k https://$COUNT/services/rest/V2.1/?$CLOSE_M` done
 cd $BACKUPDIR echo "|----------- A10 System Backup notification ------------------|" > $LOG echo " " >>$LOG ls -la *.gz | awk '{print $5,$6,$7,$8,$9}' >> $LOG echo " " >> $LOG echo "|------------------------------------------------------------------|" >>$LOG

上一篇:shell基础学习中的字符串操作、for循环语句示例

栏    目:Shell

下一篇:shell字符串截取报错:Bad substitution的解决

本文标题:a10 config backup for aXAPI

本文地址:http://www.codeinn.net/misctech/85298.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有