shell脚本安装python、pip

#!/bin/bash#. /etc/init.d/functionscat END +----------------------------------+| || This is install python || || 1...

#!/bin/bash
#. /etc/init.d/functions
cat <<END
+----------------------------------+
| |
| This is install python |
| |
| 1.安装依赖环境 |
| 2.安装pip |
| 3.安装python3.5 |
| |
+----------------------------------+
END

#node 0.
read -p "请你输入一个数字:" NUM
# expr $NUM + 1 &> /dev/null
if [ "$?" -ne 0 ];then
echo "对不起,请你输入整数!!!" /bin/false
exit 1
elif [ "$NUM" -eq 0 ];then
echo "对不起,请你输入比0大的数字!!!" /bin/false
exit 1
fi

#node 1.
[ "$NUM" = "1" ] && {
echo "首先安装依赖包"
yum -y groupinstall "Development tools" && yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
}

#node 2.
[ "$NUM" = "2" ] && {
echo "开始安装pip-18,请稍后.........."
yum remove pip -y && cd /usr/local/ && tar -xf pip-18.0.tar.gz && cd pip-18.0/ && python setup.py install

}

#node 3.
[ "$NUM" = "3" ] && {
echo "开始安装python3.6.5,请稍后.........."
cd /usr/local/ && tar -zxvf Python-3.6.5.tgz && mv Python-3.6.5 python3 && cd python3 && ./configure && make && make install
mv /usr/bin/python /usr/bin/python.bak
ln -s /usr/local/bin/python3 /usr/bin/python && ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
whereis pip && /usr/local/bin/pip3.6 install --upgrade pip && /usr/local/bin/pip install paramiko
echo "配置yum"
sed -i 's/usr\/bin\/python/usr\/bin\/python2.7/g' /usr/bin/yum && sed -i 's/usr\/bin\/python/usr\/bin\/python2.7/g' /usr/libexec/urlgrabber-ext-down

}

本文标题为:shell脚本安装python、pip

基础教程推荐