Snippets: Python: Initscript-like scripts for Gunicorn with Conda: install.sh

20th August 2020 at 2:19pm
Snippets: Python: Initscript-like scripts for Gunicorn with Conda
echo "Installing miniconda..."

# 包发布并不会检查自定义安装脚本的返回码。这里返回非 0 返回码都不会被理会,依然是安装成功。。

# Python 3 版本的 Miniconda 一样可以建 Python 2 的 env
sh #INSTALL_PATH/scripts/installer/Miniconda3-4.3.31-Linux-x86_64.sh -b -f -p #INSTALL_PATH
if [ $? -ne 0 ]
then
  echo "Install miniconda3 failed."
  exit 1
fi

# 织云包发布不可以有 dot files,我也是醉了
echo "Copying .condarc to conda dir..."
cp #INSTALL_PATH/scripts/condarc #INSTALL_PATH/.condarc
if [ $? -ne 0 ]
then
  echo "Copy .condarc to conda dir failed."
  exit 1
fi

# 把私有 PyPi Server 写进 pip.conf 中,因为 Conda 残废的 environment.yaml 机制并不好去加 PyPi Server
mkdir -p /home/user_00/.config/pip
cat > /home/user_00/.config/pip/pip.conf <<EOF
[global]
index-url = http://10.123.16.167:8080/simple
trusted-host = 10.123.16.167
format = columns
proxy = fm-proxy.oa.com:8080
EOF

# 检查下 DNS OK 不
dig +time=1 +tries=1 fm-proxy.oa.com
if [ $? -ne 0 ]
then
  echo "Conda installed successfully. But DNS not working."
  echo "It's probably DNS servers are not set in local machine."
  echo "Lookup README to find the solution."
  exit 1
fi

echo "Installation succeed."