• Shell脚本:debian-speedtest-install,Cygwin自动为Debian/Ubuntu系统安装ookla speedtest测速程序


    #!/bin/bash 
    # Source From: blog.hackkey.net/archives/shell-for-speedtest-install
    SCRIPTPATH=$(realpath $0)
    #SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
    #SCRIPTPATH=$(dirname $(readlink -f "$0"))
    
    display_usage() {
    	echo -e "$SCRIPTPATH
    "
        echo -e "	快速为Debian/Ubuntu系统安装ookla speedtest测速程序."
    	echo -e "	可参考:https://www.speedtest.net/zh-Hans/apps/cli"
        echo -e "
    Usage:
    	debian-speedtest-install [hostname]"
    	echo -e "Example:
    	debian-speedtest-install racknerd"
    }
    # if less than two arguments supplied, display usage
    if [  $# -lt 1 ]
    then
        display_usage
        exit 1
    fi
    
    # check whether user had supplied -h or --help . If yes display usage
    if [[ ( $* == "--help") ||  $* == "-h" ]]
    then
        display_usage
        exit 0
    fi
    
    ssh $1 'lsb_release -a'||{
    echo -e "	 $1 目测不是debian系(Debian/Ubuntu)系统";
    exit 0
    }
    ssh $1 'speedtest -V|grep -i "Speedtest by Ookla 1.0.0.2"' 2>/dev/null && {
    echo -e "	 $1 已经安装 Speedtest,且为官方指定deb版";
    exit 0
    }
    echo -e "-----------------------------"
    ## 安装了非官方版本 speedtest-cli 的情况
    echo "来到了判断其他speedtest版本的情况"
    ssh $1 'speedtest --version|grep -i "Python "' 2>/dev/null && {
    echo -e "	 $1 系统安装了非官方发布 Python 版本的 speedtest-cli";
    echo -e "	 $1 github地址:https://github.com/sivel/speedtest-cli";
    #卸载非官方版本或者:移除同名文件,但不删除软件包;二选一即可
    #way 1:删除非官方发行包
    #ssh $1 'pip uninstall speedtest-cli'
    #way 2:移除speedtest重名文件,使用 speedtest-cli 仍可访问非官方版本
    ssh $1 'rm -vf /usr/local/bin/speedtest'
    }
    scp /v/debian/ookla-speedtest-1.0.0-x86_64-linux.deb $1:/root/
    ssh $1 'cd /root/;dpkg -i ookla-speedtest-1.0.0-x86_64-linux.deb'
    #如有必要,修复安装依赖
    #ssh $1 'apt -f install'
    echo -e "	All action done..."
    

    本文来自博客园,作者:晴云孤魂,转载请注明原文链接:https://www.cnblogs.com/cnhack/p/15088346.html

  • 相关阅读:
    你必须知道的关于大数据的七个概念
    SAS中的聚类分析方法总结
    SAS中的聚类分析方法总结
    数据分析的关键是制定聪明的决策
    数据分析的关键是制定聪明的决策
    想使用 MongoDB ,你应该了解这8个方面!
    利用crtmpserver搭建rtmp服务器
    【leetcode】Jump Game I, II 跳跃游戏一和二
    iOS中从零開始使用protobuf
    session.use_cookies有什么作用,
  • 原文地址:https://www.cnblogs.com/cnhack/p/15088346.html
Copyright © 2020-2023  润新知