Repository navigation
Expand file tree
/
Copy pathpython.sh
More file actions
executable file
·87 lines (81 loc) · 3.12 KB
/
Copy pathpython.sh
File metadata and controls
executable file
·87 lines (81 loc) · 3.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash
# Author: yeho <lj2007331 AT gmail.com>
# BLOG: https://blog.linuxeye.com
#
# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+
#
# Project home page:
# https://oneinstack.com
# https://github.com/lj2007331/oneinstack
Install_Python() {
pushd ${oneinstack_dir}/src
if [ "${CentOS_RHEL_version}" == '7' ]; then
[ ! -e /etc/yum.repos.d/epel.repo ] && cat > /etc/yum.repos.d/epel.repo << EOF
[epel]
name=Extra Packages for Enterprise Linux 7 - \$basearch
#baseurl=http://download.fedoraproject.org/pub/epel/7/\$basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=\$basearch
failovermethod=priority
enabled=1
gpgcheck=0
EOF
elif [ "${CentOS_RHEL_version}" == '6' ]; then
[ ! -e /etc/yum.repos.d/epel.repo ] && cat > /etc/yum.repos.d/epel.repo << EOF
[epel]
name=Extra Packages for Enterprise Linux 6 - \$basearch
#baseurl=http://download.fedoraproject.org/pub/epel/6/\$basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=\$basearch
failovermethod=priority
enabled=1
gpgcheck=0
EOF
fi
if [ "${OS}" == "CentOS" ]; then
pkgList="gcc dialog augeas-libs openssl openssl-devel libffi-devel redhat-rpm-config ca-certificates"
for Package in ${pkgList}; do
yum -y install ${Package}
done
elif [[ "${OS}" =~ ^Ubuntu$|^Debian$ ]]; then
pkgList="gcc dialog libaugeas0 augeas-lenses libssl-dev libffi-dev ca-certificates"
for Package in ${pkgList}; do
apt-get -y install $Package
done
fi
# Install Python
if [ ! -e "${python_install_dir}/bin/python" -a ! -e "${python_install_dir}/bin/python3" ] ;then
src_url=http://mirrors.linuxeye.com/oneinstack/src/Python-${python_version}.tgz && Download_src
tar xzf Python-${python_version}.tgz
pushd Python-${python_version}
./configure --prefix=${python_install_dir}
make && make install
[ ! -e "${python_install_dir}/bin/python" -a -e "${python_install_dir}/bin/python3" ] && ln -s ${python_install_dir}/bin/python{3,}
popd
rm -rf Python-${python_version}
fi
if [ ! -e "${python_install_dir}/bin/easy_install" ] ;then
src_url=http://mirrors.linuxeye.com/oneinstack/src/setuptools-${setuptools_version}.zip && Download_src
unzip -q setuptools-${setuptools_version}.zip
pushd setuptools-${setuptools_version}
${python_install_dir}/bin/python setup.py install
popd
rm -rf setuptools-${setuptools_version}
fi
if [ ! -e "${python_install_dir}/bin/pip" ] ;then
src_url=http://mirrors.linuxeye.com/oneinstack/src/pip-${pip_version}.tar.gz && Download_src
tar xzf pip-${pip_version}.tar.gz
pushd pip-${pip_version}
${python_install_dir}/bin/python setup.py install
popd
rm -rf pip-${pip_version}
fi
if [ ! -e "/root/.pip/pip.conf" ] ;then
# get the IP information
PUBLIC_IPADDR=$(../include/get_public_ipaddr.py)
IPADDR_COUNTRY=$(../include/get_ipaddr_state.py $PUBLIC_IPADDR | awk '{print $1}')
if [ "$IPADDR_COUNTRY"x != "CN"x ]; then
[ ! -d "/root/.pip" ] && mkdir /root/.pip
echo -e "[global]\nindex-url = https://pypi.tuna.tsinghua.edu.cn/simple" > /root/.pip/pip.conf
fi
fi
popd
}