Skip to content

Commit

Permalink
bash
Browse files Browse the repository at this point in the history
  • Loading branch information
linkchw committed Aug 15, 2024
1 parent c888fa9 commit 6643b73
Showing 1 changed file with 33 additions and 10 deletions.
43 changes: 33 additions & 10 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,43 @@

REPO_DIR="name-family"

if [ -d "$REPO_DIR" ]; then
echo "Repository directory '$REPO_DIR' already exists. Pulling latest changes..."
check_if_in_repo() {
if [ "$(basename "$(pwd)")" == "$REPO_DIR" ]; then
return 0
elif [ "$(pwd)" == *"$REPO_DIR"* ]; then
return 0
else
return 1
fi
}

check_repo_exists() {
[ -d "$REPO_DIR" ]
}

navigate_to_repo() {
cd "$REPO_DIR" || { echo "Failed to change directory to '$REPO_DIR'."; exit 1; }
git pull
else
echo "Cloning the repository..."
git clone https://github.com/viraweb123/name-family.git
}

if [ $? -ne 0 ]; then
echo "Failed to clone repository."
exit 1
if check_if_in_repo; then
echo "Already in the repository directory. Pulling latest changes..."
else
if check_repo_exists; then
echo "Repository directory '$REPO_DIR' exists. Changing to the directory..."
navigate_to_repo
else
echo "Cloning the repository..."
git clone https://github.com/viraweb123/name-family.git

if [ $? -ne 0 ]; then
echo "Failed to clone repository."
exit 1
fi

navigate_to_repo
fi

cd "$REPO_DIR" || { echo "Failed to change directory to '$REPO_DIR'."; exit 1; }
git pull
fi

echo "Setting permissions for 'train/' directory..."
Expand Down

0 comments on commit 6643b73

Please sign in to comment.