zoukankan      html  css  js  c++  java
  • jenkins 更新脚本之expect交互

    这个是备份更新脚本

    #!/bin/bash

    ROOT_DIR=/var/www/shuyou
    APP=www.shuyou.com
    BACKUP_DIR=/var/www/backup/shuyou
    curr_date=`date +%F-%H-%M-%S`

    # 判断备份目录是否存在
    if [ ! -d $BACKUP_DIR ];then
    mkdir $BACKUP_DIR -p
    fi

    # 保留一个月的备份
    cd $BACKUP_DIR && find . -mtime +30 -name "*.tar.gz" | xargs rm -rf {}

    # 备份目录并更新代码
    cd $ROOT_DIR && tar zcf $BACKUP_DIR/leyou.$curr_date.tar.gz $APP && cd $APP && svn up && echo "leyou更新完成,备份目录:$BACKUP_DIR/leyou.$curr_date.tar.gz"

    #!/bin/bash
    username=shuyouyun
    apiKey="shuyounbkey"
    date=`env LANG="en_US.UTF-8" date -u "+%a, %d %b %Y %H:%M:%S GMT"`
    password=`echo -en "$date" | openssl dgst -sha1 -hmac $apiKey -binary | openssl enc -base64`
    expect << EOF
    set timeout 500
    spawn ssh -o StrictHostKeyChecking=no root@192.168.1.1
    expect "password" {send "shuyounb@110"}
    expect "#" {send "cd /home/client "}
    expect "#" {send "zip -rp game`date +"%Y%m%d%H"`.zip game "}
    expect "#" {send "cd game "}
    expect "#" {send "svn up "}
    expect "#" {send "cd game "}
    EOF
    curl -i --url "http://open.chinanetcenter.com/ccm/purge/ItemIdReceiver"
    -X "POST"
    -u "$username:$password"
    -H "Date:$date"
    -H "Content-Type: application/xml"
    -d'<?xml version="1.0" encoding="utf-8"?>
    <purge>
    <dirs>
    <dir>https://www.nb.com/</dir>
    <dir>http://www.nb.com/</dir>
    <dir>http://www.nb.com/</dir>
    </dirs>
    <dir-action>expire</dir-action>
    </purge>'

    魅力男神
  • 相关阅读:
    usaco 1.11
    当数组时全局变量时。。。怎样进行循环初始化
    hdu 1097 用到了位的移动
    hdu 1006
    HNOI2008]神奇的国度
    App测试基本流程详解(汇总整理)
    IOS测试Fastmonkey
    pytest+allure2+jenkins环境部署
    如何在cmd查看文件内容的md5值
    软件测试学习linux基础
  • 原文地址:https://www.cnblogs.com/capable/p/11345838.html
Copyright © 2011-2022 走看看