From 6858db5a302fa80ae5169ce383d34bfa34774fcd Mon Sep 17 00:00:00 2001 From: NotBad Date: Sat, 27 Jun 2020 21:19:43 +0800 Subject: [PATCH] fix for root user and non-root user --- .github/workflows/pre-commit-job.sh | 16 ++++++++++++++-- models/download.sh | 11 +++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pre-commit-job.sh b/.github/workflows/pre-commit-job.sh index 4a84866..66b699c 100755 --- a/.github/workflows/pre-commit-job.sh +++ b/.github/workflows/pre-commit-job.sh @@ -32,8 +32,20 @@ function abort() { } function install_miniconda() { - #apt update - #apt install -y wget git + platform=$(get_platform) + echo $platform + if [[ $platform =~ "Linux" ]]; then + if [`id -u` -eq 0 ]; then + echo "root user" + apt update + apt install -y wget unzip zip git + else + echo "not root user" + sudo apt update + sudo apt install -y wget unzip zip git + fi + fi + #cmd="conda" #is_conda_existed=`is_cmd_existed ${cmd}` #echo $is_conda_existed diff --git a/models/download.sh b/models/download.sh index 6dec17a..e2cd3b5 100755 --- a/models/download.sh +++ b/models/download.sh @@ -17,8 +17,15 @@ function prepare_env() { platform=$(get_platform) echo $platform if [[ $platform =~ "Linux" ]]; then - sudo apt update - sudo apt install -y wget unzip zip + if [`id -u` -eq 0 ]; then + echo "root user" + apt update + apt install -y wget unzip zip + else + echo "not root user" + sudo apt update + sudo apt install -y wget unzip zip + fi fi }