Commit 
							
							·
						
						73e494f
	
1
								Parent(s):
							
							ecfd212
								
Add automation scripts to support displaying environment information such as RAGFlow repository version, operating system, Python version, etc. in a Linux environment for users to report issues. (#396)
Browse files### What problem does this PR solve?
Add automation scripts to support displaying environment information
such as RAGFlow repository version, operating system, Python version,
etc. in a Linux environment for users to report issues.
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
- printEnvironment.sh +67 -0
 
    	
        printEnvironment.sh
    ADDED
    
    | 
         @@ -0,0 +1,67 @@ 
     | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
| 
         | 
|
| 1 | 
         
            +
            #!/bin/bash
         
     | 
| 2 | 
         
            +
             
     | 
| 3 | 
         
            +
            # The function is used to obtain distribution information
         
     | 
| 4 | 
         
            +
            get_distro_info() {
         
     | 
| 5 | 
         
            +
                local distro_id=$(lsb_release -i -s 2>/dev/null)
         
     | 
| 6 | 
         
            +
                local distro_version=$(lsb_release -r -s 2>/dev/null)
         
     | 
| 7 | 
         
            +
                local kernel_version=$(uname -r)
         
     | 
| 8 | 
         
            +
             
     | 
| 9 | 
         
            +
                # If lsd_release is not available, try parsing the/etc/* - release file
         
     | 
| 10 | 
         
            +
                if [ -z "$distro_id" ] || [ -z "$distro_version" ]; then
         
     | 
| 11 | 
         
            +
                    distro_id=$(grep '^ID=' /etc/*-release | cut -d= -f2 | tr -d '"')
         
     | 
| 12 | 
         
            +
                    distro_version=$(grep '^VERSION_ID=' /etc/*-release | cut -d= -f2 | tr -d '"')
         
     | 
| 13 | 
         
            +
                fi
         
     | 
| 14 | 
         
            +
             
     | 
| 15 | 
         
            +
                echo "$distro_id $distro_version (Kernel version: $kernel_version)"
         
     | 
| 16 | 
         
            +
            }
         
     | 
| 17 | 
         
            +
             
     | 
| 18 | 
         
            +
            # get Git repo name
         
     | 
| 19 | 
         
            +
            git_repo_name=''
         
     | 
| 20 | 
         
            +
            if git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
         
     | 
| 21 | 
         
            +
                git_repo_name=$(basename "$(git rev-parse --show-toplevel)")
         
     | 
| 22 | 
         
            +
                if [ $? -ne 0 ]; then
         
     | 
| 23 | 
         
            +
                    git_repo_name="(Can't get repo name)"
         
     | 
| 24 | 
         
            +
                fi
         
     | 
| 25 | 
         
            +
            else
         
     | 
| 26 | 
         
            +
                git_repo_name="It NOT a Git repo"
         
     | 
| 27 | 
         
            +
            fi
         
     | 
| 28 | 
         
            +
             
     | 
| 29 | 
         
            +
            # get CPU type
         
     | 
| 30 | 
         
            +
            cpu_model=$(uname -m)
         
     | 
| 31 | 
         
            +
             
     | 
| 32 | 
         
            +
            # get memory size
         
     | 
| 33 | 
         
            +
            memory_size=$(free -h | grep Mem | awk '{print $2}')
         
     | 
| 34 | 
         
            +
             
     | 
| 35 | 
         
            +
            # get docker version
         
     | 
| 36 | 
         
            +
            docker_version=''
         
     | 
| 37 | 
         
            +
            if command -v docker &> /dev/null; then
         
     | 
| 38 | 
         
            +
                docker_version=$(docker --version | cut -d ' ' -f3)
         
     | 
| 39 | 
         
            +
            else
         
     | 
| 40 | 
         
            +
                docker_version="Docker not installed"
         
     | 
| 41 | 
         
            +
            fi
         
     | 
| 42 | 
         
            +
             
     | 
| 43 | 
         
            +
            # get python version
         
     | 
| 44 | 
         
            +
            python_version=''
         
     | 
| 45 | 
         
            +
            if command -v python &> /dev/null; then
         
     | 
| 46 | 
         
            +
                python_version=$(python --version | cut -d ' ' -f2)
         
     | 
| 47 | 
         
            +
            else
         
     | 
| 48 | 
         
            +
                python_version="Python not installed"
         
     | 
| 49 | 
         
            +
            fi
         
     | 
| 50 | 
         
            +
             
     | 
| 51 | 
         
            +
            # Print all infomation
         
     | 
| 52 | 
         
            +
            echo "Current Repo: $git_repo_name"
         
     | 
| 53 | 
         
            +
             
     | 
| 54 | 
         
            +
            # get Commit ID
         
     | 
| 55 | 
         
            +
            git_version=$(git log -1 --pretty=format:'%h')
         
     | 
| 56 | 
         
            +
             
     | 
| 57 | 
         
            +
            if [ -z "$git_version" ]; then
         
     | 
| 58 | 
         
            +
                echo "Commit Id: The current directory is not a Git repository, or the Git command is not installed."
         
     | 
| 59 | 
         
            +
            else
         
     | 
| 60 | 
         
            +
                echo "Commit Id: $git_version"
         
     | 
| 61 | 
         
            +
            fi
         
     | 
| 62 | 
         
            +
             
     | 
| 63 | 
         
            +
            echo "Operating system: $(get_distro_info)"
         
     | 
| 64 | 
         
            +
            echo "CPU Type: $cpu_model"
         
     | 
| 65 | 
         
            +
            echo "Memory: $memory_size"
         
     | 
| 66 | 
         
            +
            echo "Docker Version: $docker_version"
         
     | 
| 67 | 
         
            +
            echo "Python Version: $python_version"
         
     |