Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Model of Raspberry PI #228

Closed
lastsamurai26 opened this issue Jun 13, 2022 · 15 comments · Fixed by #229
Closed

Add Model of Raspberry PI #228

lastsamurai26 opened this issue Jun 13, 2022 · 15 comments · Fixed by #229

Comments

@lastsamurai26
Copy link

lastsamurai26 commented Jun 13, 2022

in the version of the chronometer which is supplied with the Pihole,
the model was then and is still displayed. Is there a possibility to do this here too ?

`#######################
    if command -v vcgencmd &> /dev/null; then
        local sys_throttle_raw
        local sys_rev_raw

        sys_throttle_raw=$(vgt=$(sudo vcgencmd get_throttled); echo "${vgt##*x}")

        # Active Throttle Notice: https://bit.ly/2gnunOo
        if [[ "$sys_throttle_raw" != "0" ]]; then
            case "$sys_throttle_raw" in
                *0001) thr_type="${COL_YELLOW}Under Voltage";;
                *0002) thr_type="${COL_LIGHT_BLUE}Arm Freq Cap";;
                *0003) thr_type="${COL_YELLOW}UV${COL_DARK_GRAY},${COL_NC} ${COL_LIGHT_BLUE}AFC";;
                *0004) thr_type="${COL_LIGHT_RED}Throttled";;
                *0005) thr_type="${COL_YELLOW}UV${COL_DARK_GRAY},${COL_NC} ${COL_LIGHT_RED}TT";;
                *0006) thr_type="${COL_LIGHT_BLUE}AFC${COL_DARK_GRAY},${COL_NC} ${COL_LIGHT_RED}TT";;
                *0007) thr_type="${COL_YELLOW}UV${COL_DARK_GRAY},${COL_NC} ${COL_LIGHT_BLUE}AFC${COL_DARK_GRAY},${COL_NC} ${COL_LIGHT_RED}TT";;
            esac
        [[ -n "$thr_type" ]] && sys_throttle="$thr_type${COL_DARK_GRAY}"
        fi

sys_rev_raw=$(awk '/Revision/ {print $3}' < /proc/cpuinfo)
        case "$sys_rev_raw" in
            000[2-6]) sys_model=" 1, Model B";; # 256MB
            000[7-9]) sys_model=" 1, Model A";; # 256MB
            000d|000e|000f) sys_model=" 1, Model B";; # 512MB
            0010|0013) sys_model=" 1, Model B+";; # 512MB
            0012|0015) sys_model=" 1, Model A+";; # 256MB
            a0104[0-1]|a21041|a22042) sys_model=" 2, Model B";; # 1GB
            900021) sys_model=" 1, Model A+";; # 512MB
            900032) sys_model=" 1, Model B+";; # 512MB
            90009[2-3]|920093) sys_model=" Zero";; # 512MB
            9000c1) sys_model=" Zero W";; # 512MB
            a02082|a[2-3]2082) sys_model=" 3, Model B";; # 1GB
            a020d3) sys_model=" 3, Model B+";; # 1GB
            *) sys_model="";;
        esac
        sys_type="Raspberry Pi$sys_model"
    else
        source "/etc/os-release"
        CODENAME=$(sed 's/[()]//g' <<< "${VERSION/* /}")
        sys_type="${NAME/ */} ${CODENAME^} $VERSION_ID"
    fi
#################`

This is the code, but it doesn't work with #!/usr/bin/env sh only with #!/usr/bin/env bash

@yubiuser
Copy link
Member

yubiuser commented Jun 13, 2022

This code block was never part of PADD, but only chronometer. This has nothing to do with

#!/usr/bin/env sh only with #!/usr/bin/env bash

I consider this a feature request.

@lastsamurai26
Copy link
Author

I know, I had packed this myself in the Padd version but with version 3.7.0 this code does not work anymore :(

@yubiuser
Copy link
Member

Try

    if command -v vcgencmd >/dev/null 2>&1; then

        sys_throttle_raw=$(vgt=$(sudo vcgencmd get_throttled); echo "${vgt##*x}")

        # Active Throttle Notice: https://bit.ly/2gnunOo
        if [ "$sys_throttle_raw" != "0" ]; then
            case "$sys_throttle_raw" in
                *0001) thr_type="${COL_YELLOW}Under Voltage";;
                *0002) thr_type="${COL_LIGHT_BLUE}Arm Freq Cap";;
                *0003) thr_type="${COL_YELLOW}UV${COL_DARK_GRAY},${COL_NC} ${COL_LIGHT_BLUE}AFC";;
                *0004) thr_type="${COL_LIGHT_RED}Throttled";;
                *0005) thr_type="${COL_YELLOW}UV${COL_DARK_GRAY},${COL_NC} ${COL_LIGHT_RED}TT";;
                *0006) thr_type="${COL_LIGHT_BLUE}AFC${COL_DARK_GRAY},${COL_NC} ${COL_LIGHT_RED}TT";;
                *0007) thr_type="${COL_YELLOW}UV${COL_DARK_GRAY},${COL_NC} ${COL_LIGHT_BLUE}AFC${COL_DARK_GRAY},${COL_NC} ${COL_LIGHT_RED}TT";;
            esac
        [ -n "$thr_type" ] && sys_throttle="$thr_type${COL_DARK_GRAY}"
        fi

sys_rev_raw=$(awk '/Revision/ {print $3}' < /proc/cpuinfo)
        case "$sys_rev_raw" in
            000[2-6]) sys_model=" 1, Model B";; # 256MB
            000[7-9]) sys_model=" 1, Model A";; # 256MB
            000d|000e|000f) sys_model=" 1, Model B";; # 512MB
            0010|0013) sys_model=" 1, Model B+";; # 512MB
            0012|0015) sys_model=" 1, Model A+";; # 256MB
            a0104[0-1]|a21041|a22042) sys_model=" 2, Model B";; # 1GB
            900021) sys_model=" 1, Model A+";; # 512MB
            900032) sys_model=" 1, Model B+";; # 512MB
            90009[2-3]|920093) sys_model=" Zero";; # 512MB
            9000c1) sys_model=" Zero W";; # 512MB
            a02082|a[2-3]2082) sys_model=" 3, Model B";; # 1GB
            a020d3) sys_model=" 3, Model B+";; # 1GB
            *) sys_model="";;
        esac
        sys_type="Raspberry Pi$sys_model"
    else
        . "/etc/os-release"
        # remove parenthesis and only print second substring
        CODENAME=$(echo "${VERSION}"| sed 's/[()]//g' | awk '{print $2}')

        # only print first substring of NAME and make first character of CODENAME uppercase
        sys_type=$(echo "${NAME}" | awk '{print $1}')
        CODENAME=$(echo "$CODENAME" | sed 's/./\U&/')
        sys_type="${sys_type} ${CODENAME} $VERSION_ID"
    fi

@dschaper
Copy link
Member

I think this is a good idea to have. Thanks Yubi for the POSIX conversion.

@lastsamurai26
Copy link
Author

Thank you, this works :)

@yubiuser yubiuser self-assigned this Jun 15, 2022
@yubiuser
Copy link
Member

@yubiuser
Copy link
Member

@lastsamurai26

We're thinking about integrating the code in PADD- Could you please share at which place you added the code and maybe a screenshot how this would look like.

@lastsamurai26
Copy link
Author

lastsamurai26 commented Jun 15, 2022

Bildschirmfoto 2022-06-15 um 22 12 45

I forked the padd repo with my changes

https://github.com/lastsamurai26/PADD/blob/master/padd.sh

between line 321 and 369 is your code
on line 782 you can find the model in the Network area. Because I think the model fits the hostname
but i guess we can find a better place for this

@yubiuser
Copy link
Member

Thanks.

i guess we can find a better place for this

Maybe System?

@lastsamurai26
Copy link
Author

I just thought since the hostname is in the network, the model may belong to it. I have inserted the code only for the regular screen but maybe you can do this also for the others.

System also sounds good

@yubiuser yubiuser linked a pull request Jun 22, 2022 that will close this issue
1 task
@yubiuser
Copy link
Member

I filed a PR which implements this but different than chronometer did.

@lastsamurai26 could you please test https://github.com/pi-hole/PADD/blob/model/padd.sh

@lastsamurai26
Copy link
Author

Old Version
Bildschirmfoto 2022-06-23 um 15 39 26

New Version
3b +
Bildschirmfoto 2022-06-23 um 15 39 41

3B
Bildschirmfoto 2022-06-23 um 15 47 36

I unfortunately do not know why the error comes on the 3B

@yubiuser
Copy link
Member

yubiuser commented Jun 23, 2022

Thanks for testing. The warning should be fixed now. Please try again.

@lastsamurai26
Copy link
Author

thx :-)
Bildschirmfoto 2022-06-23 um 18 52 36
Bildschirmfoto 2022-06-23 um 18 52 47

error message has disappeared 👍 👍

@yubiuser
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants