linux-tutorial/codes/linux/download.sh

28 lines
965 B
Bash
Raw Normal View History

2019-05-08 17:13:04 +08:00
#!/usr/bin/env bash
2019-05-16 11:49:19 +08:00
##############################################################################
# console color
C_BLACK="\033[1;30m"
C_RED="\033[1;31m"
C_GREEN="\033[1;32m"
C_YELLOW="\033[1;33m"
C_BLUE="\033[1;34m"
C_PURPLE="\033[1;35m"
C_CYAN="\033[1;36m"
C_RESET="$(tput sgr0)"
##############################################################################
2019-05-08 17:13:04 +08:00
2019-05-16 11:49:19 +08:00
path=/home/scripts/linux-tutorial
printf "\n${C_BLUE}>>>>>>>> Downloading linux-tutorial to ${path}.${C_RESET}\n"
command -v yum >/dev/null 2>&1 || { echo >&2 -e "${C_RED}Require yum but it's not installed. Aborting.${C_RESET}"; exit 1; }
command -v git >/dev/null 2>&1 || { echo >&2 -e "${C_YELLOW}Not detected git. Install git.${C_RESET}"; yum -y install git; }
2019-05-08 17:13:04 +08:00
2019-05-16 11:49:19 +08:00
if [[ -d ${path} ]]; then
cd ${path}
git pull
else
mkdir -p ${path}
git clone --no-checkout https://gitee.com/turnon/linux-tutorial.git ${path}
fi
printf "\n${C_GREEN}<<<<<<<< Download linux-tutorial to ${path} ok.${C_RESET}\n"