File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ get_user_home() {
2121
2222# Set paths relative to the correct user's home directory
2323USER_HOME=$( get_user_home)
24+ USER_NAME=$( echo $USER_HOME | awk -F' /' ' {print $3}' )
2425DOWNLOAD_DIR=" /tmp"
2526EXTRACT_DIR=" $USER_HOME /.systemguard/"
2627LOG_DIR=" $HOME /logs"
@@ -274,3 +275,8 @@ case $ACTION in
274275 load_test) load_test ;;
275276 * ) echo " No action specified. Use --help for usage information." ;;
276277esac
278+
279+
280+ # this script ran with sudo command so all the files have root permission
281+ # remove the root permission from the files to the user
282+ chown -R $USER_NAME :$USER_NAME $EXTRACT_DIR
Original file line number Diff line number Diff line change 1+ get_user_home () {
2+ if [ -n " $SUDO_USER " ]; then
3+ # When using sudo, SUDO_USER gives the original user who invoked sudo
4+ TARGET_USER=" $SUDO_USER "
5+ else
6+ # If not using sudo, use LOGNAME to find the current user
7+ TARGET_USER=" $LOGNAME "
8+ fi
9+
10+ # Get the home directory of the target user
11+ USER_HOME=$( eval echo ~ $TARGET_USER )
12+ echo " $USER_HOME "
13+ }
14+
15+ USER_HOME=$( get_user_home)
16+ echo " USER_HOME: $USER_HOME "
17+ # get only user name
18+ USER_NAME=$( echo $USER_HOME | awk -F' /' ' {print $3}' )
19+ echo " USER_NAME: $USER_NAME "
You can’t perform that action at this time.
0 commit comments