#!/bin/sh mk_custom_path() { if [ $(id -u) -eq 0 ]; then return 0 fi local _custom_path_file="$1" while read line || [ -n "$line" ] do local _custom_path="$(echo "$line" | cut --only-delimited -d= -f2)" if [ -z "$_custom_path" ]; then continue fi eval "_custom_path=$_custom_path" if [ ! -d "$_custom_path" ]; then mkdir -p "$_custom_path" if [ $? -ne 0 ]; then cur_date="$(date +"%Y-%m-%d %H:%M:%S")" echo "[Common] [$cur_date] [ERROR]: create $_custom_path failed." return 1 fi fi done < $_custom_path_file return 0 } _version_le() { test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" = "$1" } _version_ge() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" = "$1" } py_version_check(){ local pyver_37_min="3.7.5" local pyver_37_max="3.7.11" local pyver_38_min="3.8.0" local pyver_38_max="3.8.11" local pyver_39_min="3.9.0" local pyver_39_max="3.9.2" local cur_date="$(date +"%Y-%m-%d %H:%M:%S")" which python3 > /dev/null 2>&1 if [ $? -eq 0 ]; then local python_version="$(python3 --version | head -n 1)" local python_version=$(expr "$python_version" : '.*\([0-9]\+\.[0-9]\+\.[0-9]\+\)') if _version_ge $python_version $pyver_37_min && _version_le $python_version $pyver_37_max; then return 0 elif _version_ge $python_version $pyver_38_min && _version_le $python_version $pyver_38_max; then return 0 elif _version_ge $python_version $pyver_39_min && _version_le $python_version $pyver_39_max; then return 0 else echo "[Common] [$cur_date] [WARNING]: Python ${python_version} is not in Python3.7.x($pyver_37_min~$pyver_37_max), Python3.8.x($pyver_38_min~$pyver_38_max), Python3.9.x($pyver_39_min~$pyver_39_max)." return 1 fi else echo "[Common] [$cur_date] [WARNING]: python3 is not found." return 1 fi }