• linux 环境基础设置


    linux 环境基础设置

    #!/usr/bin/env bash
    
    curpath=$(pwd)
    framework=$(uname -m)   # 服务器架构
    yum_or_apt="apt"
    tmp=$(yum)
    if [[ $tmp ]]; then yum_or_apt="yum"; fi
    
    # 安装常用的 linux 命令
    cmds="vim dos2unix wget curl openssl"
    for cmd in $cmds; do echo -e "
    === get $cmd ==="; echo y | yum install $cmd; done
    
    # shell 脚本格式转换
    echo -e "
    === dos2unix shell ==="
    find / -name *.sh | xargs dos2unix
    
    # conda shell 脚本下载
    echo -e "
    === get anaconda3 install shell ==="
    mkdir -p -v $curpath/conda_install_sh
    if [ $framework == 'x86_64' ]; then
        conda_link="https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2021.05-Linux-x86_64.sh"
    else
        conda_link="https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2021.05-Linux-aarch64.sh"
    fi
    
    if [[ $(ls $curpath/conda_install_sh | grep .*.sh | wc -l) -eq 0 ]]; then
        cd $curpath/conda_install_sh; wget $conda_link
    else
        echo "anaconda shell existing"
    fi
    
    # Docker:无,安装。有,更新
    echo -e "
    === get docker version ==="
    docker_version=$(docker --version)
    echo $docker_version
    if [[ $docker_version ]]; then
        echo "docker existing"
    else
        echo "server has no docker, start install docker now"
        if [ $yum_or_apt == 'yum' ]; then
            echo -e "
    === remove docker ==="; echo y | yum remove docker  docker-client  docker-client-latest  docker-common  docker-latest  docker-latest-logrotate  docker-logrotate  docker-engine
            echo -e "
    === install yum-utils ==="; echo y | yum install -y yum-utils
            echo -e "
    === add-repo ==="; echo y | yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
            echo -e "
    === yum makecache ==="; echo y | yum makecache fast
            echo -e "
    === yum update ==="; echo y | yum update
            echo -e "
    === install docker ==="; echo y | yum install docker-ce docker-ce-cli containerd.io
            echo -e "
    === start docker ==="; echo y | systemctl start docker 
            docker version
        else
            echo "installed by yourself"
        fi
    fi
    
    #docker 安装镜像
    echo -e "
    === get redis ==="
    docker pull redis
    
    echo -e "
    === get mysql ==="
    docker pull mysql
    
    
  • 相关阅读:
    c# 暴力破解中文编码方式
    vs调试 不能进入断点
    shell-的bash内部命令变量介绍与shift等
    shell-的特殊变量-难点理论
    shell-的特殊变量-进程状态变量$$ $! $? $_详解
    shell-的特殊变量-位置变量$0 $n $* $# $@详解
    shell-的变量-局部变量
    shell-的变量-全局变量
    shell-脚本开发基本规范及习惯
    shell-脚本的执行
  • 原文地址:https://www.cnblogs.com/hui-code/p/15473613.html
Copyright © 2020-2023  润新知