最近的爬虫是在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

最新文章

  1. JavaScript 正则表达式语法
  2. Android开发--ListView的应用
  3. Linux 安装git
  4. js关于函数调用
  5. 【转载】Ubuntu下SVN安装和配置
  6. Linux中mod相关的命令 内核模块化 mod相关命令都是用来动态加载内核模块/驱动程序模块
  7. Flex 播放视频
  8. 使用eclipse与jLink V8调试exynos 4412 u-boot
  9. BootStrap2学习日记14----导航
  10. 自定义EditText实现一键删除数据
  11. sscanf用法简析
  12. 读取 xml 文件 获取其中保存的数据信息
  13. swift 点击button改变其内填充图片,达到选中的效果
  14. LightOJ 1095 Arrange the Numbers-容斥
  15. MSDN-9月杂志推荐
  16. LeetCode之“链表”:Rotate List
  17. 学以致用二十九-----python3连接mysql
  18. GCC编译器原理(三)------编译原理三:编译过程(3)---编译之汇编以及静态链接【2】
  19. shell编程学习笔记(三):Shell中局部变量的使用
  20. C# 使用 protobuf 进行对象序列化与反序列化

热门文章

  1. ssh repo ----> struts+hibernate+spring( jar包和源码)各版本下载链接
  2. English trip M1 - AC3 Teacher:Corrine
  3. elasticsearch查询语句
  4. 77. Combinations (java 求C(n,k)的组合,排除重复元素)
  5. 第一阶段——站立会议总结DAY07
  6. 详解 java socket
  7. ubuntu Sublime Text 2编辑器安装
  8. win10 中redis client提示 ERR Client sent AUTH,but no password is set
  9. Hadoop---目录结构介绍
  10. Mysql for Linux安装配置之—— rpm(bundle)安装