最近的爬虫是在linux下运行的,使用的是云立方的代理服务器,需要自动切换一下ip。

#!/bin/bash
# coding:utf8

aa="sources.list"

#主流程
if [ -n $aa ];then
touch $aa
echo "1->ali(ubuntu16) 2->ali(ubuntu14) 3->nyist(ubuntu14)"
echo "choose :"
read sou_name #由键盘读入源类型,切换源

if [ "$sou_name" = 1 ];then
echo "${aa}文件已经创建完毕。。。开始写入${sou_name}源地址"
echo "deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse " >> $aa
echo "deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse" >> $aa
echo "deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse" >> $aa
echo "deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse" >> $aa
echo "deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse" >> $aa

elif [ "$sou_name" = 2 ];then
echo "${aa}文件已经创建完毕。。。开始写入${sou_name}源地址"
echo "deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse" > $aa
echo "deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse" >> $aa
echo "deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse" >> $aa
echo "deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse" >> $aa
echo "deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse" >> $aa

elif [ "$sou_name" = 3 ];then
echo "${aa}文件已经创建完毕。。。开始写入${sou_name}源地址"
echo "deb http://59.69.128.21/ubuntu/ trusty main restricted universe multiverse" > $aa
echo "deb http://59.69.128.21/ubuntu/ trusty-security main restricted universe multiverse" >> $aa
echo "deb http://59.69.128.21/ubuntu/ trusty-updates main restricted universe multiverse" >> $aa
echo "deb http://59.69.128.21/ubuntu/ trusty-proposed main restricted universe multiverse" >> $aa
echo "deb http://59.69.128.21/ubuntu/ trusty-backports main restricted universe multiverse" >> $aa
else
exit 1
fi
rm -rf /etc/apt/sources.list
mv $aa /etc/apt/
else
echo "error"
fi

#测试写入源是否成功
if test -s /etc/apt/sources.list;then
cat /etc/apt/sources.list
apt-get update

echo "Do you need to upgrade the software? y/n"
read option
if [ "$option" = 'y' ];then
apt-get upgrade -y
else
echo "not upgrade"
fi
else
echo "empty"
fi

一个在linxu自动切换ip的脚本的更多相关文章

  1. window自动切换ip的脚本

    因为总要切换ip,所以百度了一下脚本 如下http://jingyan.baidu.com/article/d2b1d1029d21b95c7e37d4fa.html 动态ip netsh inter ...

  2. 写一个shell,自动执行jmeter测试脚本

    贡献一个自己写的shell脚本,很简单,但又可以高效率的自动执行jmeter压测脚本. #!/bin/bash #author:zhangyl #version:V1 #该脚本放置于压测脚本的上一层目 ...

  3. Ubuntu 设定壁纸自动切换的shell脚本

    升级到Ubuntu14.04后,感觉bug的确比12.04少多了.顶部任务栏支持半透明效果,所以整个桌面也看上去漂亮了很多.这样的桌面也是值得瞎捣鼓一下的,想到换壁纸,但是没找到设定动态更换壁纸的选项 ...

  4. 一个简单爬免费代理IP的脚本

  5. 【我们开发有力量之二】利用javascript制作批量网络投票机器人(自动改IP)

    帮朋友忙网络投票,粗粗地看了下,投票没有什么限制,仅有一个ip校验:每天每个ip仅能投票一次. 也就是说,可以写一个程序,自动更换IP地址(伪造IP地址),实现批量刷票的目的.于是我写了一个投票机器人 ...

  6. IP自动切换脚本

    @echo off & cls & color 47 & mode con cols=80 lines=25 & title [IP自动切换工具]clsecho. ec ...

  7. 脚本设置IP bat 命令行设置自动获取IP和固定IP

    由于办公室网络需要固定IP和DNS才能上网, 在连接公共网络或者家里又需要自动获取IP和DNS才能上网. 频繁手动切换很麻烦,就搞了两个脚本一键设置. 1.新建文本文件, 命名为固定IP.bat 复制 ...

  8. Nginx+keepalived 脚本安装主从双机热备自动切换解决方案

    Nginx+keepalived 脚本安装主从双机热备自动切换解决方案 2013-07-02 19:24:13 标签:filesnginx keepalived 原创作品,允许转载,转载时请务必以超链 ...

  9. windows10 自动配置切换IP

    办公室与家里的ip网段不一样.每次都要来回修改本地无线WLAN IP段.写了个脚本bat,自动配置WLAN IP,方便切换. 建立 auto-set-ip.bat,保存格式需为ANSI,否则中文会乱码 ...

随机推荐

  1. (原创)PBS | SGE 智能任务投递系统monitor | python实现

    之前看到过高手写的一个monitor,用python面向对象实现的,依赖几个核心的python包,drmaa,zodb,理论上来说解决了所有的任务投递问题. 但是在复杂的集群环境下还是会经常出问题,这 ...

  2. python3-知识扩展扫盲易忘-zip的用法

    >>>a = [1,2,3] >>> b = [4,5,6]>>> c = [4,5,6,7,8]>>> zipped = zi ...

  3. 安装Jade

    1.安装node.js 直接有安装程序:http://nodejs.cn/ 2.安装git 直接的安装程序:http://jingyan.baidu.com/article/90895e0fb3495 ...

  4. vue, vux调用微信点击图片,上传图片,删除图片,接口,其中选图接口,苹果手机显示有问题,查看不到图片,提交会提示fail not exist,解决如下

    <template> <div v-cloak v-show="show"> <div v-show="mailbox"> ...

  5. RFBnet论文笔记

    论文:Receptive Field Block Net for Accurate and Fast Object Detection 论文链接:https://arxiv.org/abs/1711. ...

  6. linux网络配置命令(二)——ip

    ip命令 查看/设置路由.设备.路由策略和渠道信息 格式 ip [ OPTIONS ] OBJECT { COMMAND | help } OBJECT := { link | addr | addr ...

  7. mybatis使用@param("xxx")注解传参和不使用的区别

    public interface SystemParameterMapper { int deleteByPrimaryKey(Integer id); int insert(SystemParame ...

  8. python使用SQLAlchemy模块连接MySQL

    ORM技术:Object-Relational Mapping,负责把关系数据库的表结构映射到对象上. 1.安装SQLAlchemy,MySQLdb模块 MySQLdb安装教程:http://www. ...

  9. URL to load resources from the classpath in Java

    In Java, you can load all kinds of resources using the same API but with different URL protocols: fi ...

  10. commonJS 和 ES6 模块化的不同

    commonjs 导出 module.exports={ add:function(){ console.log('add测试') } } 导入 var add=require('./add.js') ...