Skip to content

Commit

Permalink
Optimize the dev_helper.sh (#640)
Browse files Browse the repository at this point in the history
* Rename Dockerfile to DockerFile

* Optimize the dev_helper.sh script
  • Loading branch information
Teingi authored Dec 18, 2024
1 parent 8f6d280 commit 9df94b7
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions dev_helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,39 @@ initialize_environment() {
fi
}

copy_file
echo "File initialization completed"
backup_obdiag_folders() {
local backup_dir="${OBDIAG_HOME}/dev_backup"
mkdir -p "$backup_dir"
local datestamp=$(date +%Y%m%d_%H%M%S)
local tar_file="$backup_dir/obdiag_backup_$datestamp.tar.gz"
tar -czf "$tar_file" -C "${OBDIAG_HOME}" check display gather rca 2>/dev/null
if [ $? -eq 0 ]; then
echo "Backup completed: $tar_file"
else
echo "No folders found to back up or backup failed."
fi
}

remove_existing_folders() {
for folder in check display gather rca; do
if [ -d "${OBDIAG_HOME}/$folder" ]; then
echo "Removing existing ${OBDIAG_HOME}/$folder"
rm -rf "${OBDIAG_HOME}/$folder"
fi
done
}

if [ -z "${OBDIAG_HOME}" ]; then
OBDIAG_HOME="${HOME}/.obdiag"
fi

mkdir -p "${OBDIAG_HOME}"

backup_obdiag_folders

remove_existing_folders

copy_file
check_python_version
install_requirements

Expand Down

0 comments on commit 9df94b7

Please sign in to comment.