update README, atuo auth git

This commit is contained in:
Joseph Le 2023-10-13 17:44:05 +11:00
parent 7ad0b8b385
commit f4e4057a74
2 changed files with 27 additions and 31 deletions

View File

@ -56,19 +56,6 @@ if [ -d "/etc/systemd/system" ]; then
echo -e "\e[32mOK: $path exists\e[0m"
sleep 1
fi
else
if [[ $line == *"REPOSITORY"* ]]; then
path="${line#*=}"
if git ls-remote -q --exit-code "$path" > /dev/null; then
echo -e "\e[32mOK: Repository $path exists\e[0m"
sleep 1
else
echo ""
echo -e "\e[41mError: Repository $path not exists.\e[0m"
echo ""
exit 1
fi
fi
fi
done <"$input_file" &&

View File

@ -2,41 +2,50 @@
# Đường dẫn tới tệp index.js
indexjs_path=$HOOK_PATH/index.js
project_path=$HOOK_PATH
project_path=$HOOK_PATH
REPOSITORY_AUTH="https://$GIT_USERNAME:$GIT_PASSWORD@$(echo $GIT_REPOSITORY | sed 's#https://##')"
cd "$PROJECT_PATH" &&
SET_ORIGIN=$(git remote set-url origin $REPOSITORY_AUTH)
echo "$SET_ORIGIN"
if git ls-remote -q --exit-code "$REPOSITORY_AUTH" > /dev/null; then
echo -e "\e[32mOK: Repository $GIT_REPOSITORY exists\e[0m"
sleep 1
else
echo ""
echo -e "\e[41mError: Repository $GIT_REPOSITORY not exists.\e[0m"
echo ""
exit 1
fi
# Kiểm tra xem Node.js đã cài đặt chưa
if ! command -v node &> /dev/null; then
echo -e "\e[31mNode.js is not installed.\e[0m"
echo -e "\e[32mInstall Node.js...\e[0m"
curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash - &&
sudo apt-get install nodejs -y &&
node -v
echo -e "\e[31mNode.js is not installed.\e[0m"
echo -e "\e[32mInstall Node.js...\e[0m"
curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash - &&
sudo apt-get install nodejs -y &&
node -v
else
echo -e "\e[32mNodejs is installed!\e[0m" &&
node -v
echo -e "\e[32mNodejs is installed!\e[0m" &&
node -v
fi
# Kiểm tra xem npm đã cài đặt chưa
if ! command -v npm &> /dev/null; then
echo -e "\e[31mnpm is not installed. Install npm...\e[0m"
sudo apt-get install npm -y
echo -e "\e[31mnpm is not installed. Install npm...\e[0m"
sudo apt-get install npm -y
else
echo -e "\e[32mnpm is installed!\e[0m" &&
npm -v
echo -e "\e[32mnpm is installed!\e[0m" &&
npm -v
fi
# Kiểm tra xem tệp index.js có tồn tại không
if [ -f "$indexjs_path" ]; then
echo "Run file $indexjs_path..."
cd "$project_path" &&
npm install &&
node "$indexjs_path"
echo "Run file $indexjs_path..."
cd "$project_path" &&
npm install &&
node "$indexjs_path"
else
echo -e "\e[31mFile $indexjs_path not exists\e[0m"
echo -e "\e[31mFile $indexjs_path not exists\e[0m"
fi