From 914e9a969549192f99bc62bc65bc6709cac47517 Mon Sep 17 00:00:00 2001 From: yuncliu Date: Sat, 5 Dec 2020 15:34:58 +0800 Subject: [PATCH] modify download script --- start_download.sh | 46 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/start_download.sh b/start_download.sh index 56665670..af1d4898 100755 --- a/start_download.sh +++ b/start_download.sh @@ -1,14 +1,46 @@ #!/bin/bash -have_python3=`command -v python3 | wc -l` -have_yum=`command -v yum | wc -l` -have_apt=`command -v apt | wc -l` -if [ ${have_python3} -eq 0 ];then + +function get_python_cmd() +{ + # try this first + py36="/usr/bin/python3.6" + if [ -f ${py36} ];then + echo ${py36} + return 0 + fi + + # centos 8.2 + platform_python="/usr/libexec/platfrom-python3.6" + if [ -f ${platform_python} ];then + echo ${platform_python} + return 0 + fi + + # this python3 mybe replace by user and have no lzma or other module + have_python3=`command -v python3 | wc -l` + if [ ${have_python3} -eq 1 ];then + echo python3 + return 0 + fi + + have_yum=`command -v yum | wc -l` if [ ${have_yum} -eq 1 ];then yum install -y python3 fi + + have_apt=`command -v apt | wc -l` if [ ${have_apt} -eq 1 ];then DEBIAN_FRONTEND=noninteractive apt -y install python3 fi -fi -python3 downloader/downloader.py -python3 downloader/other_downloader.py + echo python3 + return 0 +} + +function main() +{ + pycmd=$(get_python_cmd) + ${pycmd} downloader/downloader.py + ${pycmd} downloader/other_downloader.py +} + +main $* -- Gitee