Skip to content

Commit

Permalink
fixed: init.sh & obdiag_backup.sh (oceanbase#649)
Browse files Browse the repository at this point in the history
* Rename Dockerfile to DockerFile

* fixed: init.sh & obdiag_backup.sh
  • Loading branch information
Teingi authored Dec 23, 2024
1 parent c138ef3 commit 5f8cc82
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion rpm/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ mkdir -p ${OBDIAG_HOME}/log
mkdir -p ${OBDIAG_HOME}/display

# Clean rca old *scene.py files
find ${OBDIAG_HOME}/rca -maxdepth 1 -name "*_scene.py" -type f -exec rm -f {} \;
find ${OBDIAG_HOME}/rca -maxdepth 1 -name "*_scene.py" -type f -exec rm -f {} + 2>/dev/null

cp -rf ${WORK_DIR}/plugins/* ${OBDIAG_HOME}/

Expand Down
17 changes: 15 additions & 2 deletions rpm/obdiag_backup.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
#!/bin/bash

CURRENT_USER_ID=$(id -u)
CURRENT_USER_NAME=$(logname 2>/dev/null || echo "$SUDO_USER" | awk -F'[^a-zA-Z0-9_]' '{print $1}')

if [ "$CURRENT_USER_ID" -eq 0 ]; then
if [ -n "$SUDO_USER" ]; then
USER_HOME=$(getent passwd "$SUDO_USER" | cut -d: -f6)
else
USER_HOME=/root
fi
else
USER_HOME="$HOME"
fi

# Define source directory and target backup directory
SOURCE_DIR=~/.obdiag/
BACKUP_DIR=~/.obdiag/backup/
SOURCE_DIR="$USER_HOME/.obdiag/"
BACKUP_DIR="$USER_HOME/.obdiag/backup/"

# Ensure the backup directory exists, create it if it does not
mkdir -p "$BACKUP_DIR"
Expand Down

0 comments on commit 5f8cc82

Please sign in to comment.