pi-hole / PADD

PADD (formerly Chronometer2) is a more expansive version of the original chronometer.sh that is included with Pi-Hole. PADD provides in-depth information about your Pi-hole.
1.36k stars 122 forks source link

stty: standard input: Inappropriate ioctl for device #288

Closed klutchell closed 1 year ago

klutchell commented 1 year ago

Describe the bug

Switching from tput to stty size results in errors if tty does not exist.

To Reproduce Steps to reproduce the behavior:

  1. Call PADD script from an s6 overlay in a docker container (eg. /usr/src/app/padd.sh > /dev/tty1)
  2. ...

Expected behavior

The old method of calculating terminal size without a tty worked with no issues.

Screenshots

12.12.22 11:12:44 (-0600)  pihole  stty: 'standard input': Inappropriate ioctl for device
12.12.22 11:12:44 (-0600)  pihole  stty: 'standard input': Inappropriate ioctl for device
12.12.22 11:12:44 (-0600)  pihole  /usr/src/app/padd.sh: 939: [: Illegal number: 
12.12.22 11:12:44 (-0600)  pihole  /usr/src/app/padd.sh: 944: [: Illegal number: 
12.12.22 11:12:44 (-0600)  pihole  /usr/src/app/padd.sh: 949: [: Illegal number: 
12.12.22 11:12:44 (-0600)  pihole  /usr/src/app/padd.sh: 954: [: Illegal number: 
12.12.22 11:12:44 (-0600)  pihole  /usr/src/app/padd.sh: 959: [: Illegal number: 
12.12.22 11:12:44 (-0600)  pihole  /usr/src/app/padd.sh: 964: [: Illegal number: 
12.12.22 11:12:44 (-0600)  pihole  /usr/src/app/padd.sh: 969: [: Illegal number: 
12.12.22 11:12:44 (-0600)  pihole  /usr/src/app/padd.sh: 974: [: Illegal number: 
12.12.22 11:12:44 (-0600)  pihole  [â] Error!
12.12.22 11:12:44 (-0600)  pihole      PADD isn't
12.12.22 11:12:44 (-0600)  pihole      for ants!
12.12.22 11:12:44 (-0600)  pihole  
12.12.22 11:12:44 (-0600)  pihole  Stopping PADD

Additional context

rdwebdesign commented 1 year ago

I was able to run PADD inside official Pi-hole containers.

Which image are you using?

klutchell commented 1 year ago

Also the official Pi-hole container, with an external PiTFT display. Are you running the container as privileged?

Here's the compose file: https://github.com/klutchell/balena-pihole/blob/main/docker-compose.yml

rdwebdesign commented 1 year ago

No. I'm running using the basic setup, but I didn't tested on a external display. I only tested on different terminals.

klutchell commented 1 year ago

Replacing

    console_height=$(stty size | awk '{ print $1 }')
    console_width=$(stty size | awk '{ print $2 }')

with

    console_height=$(tput lines)
    console_width=$(tput cols)

Which is what was working before seems to solve it on my devices. Do we know if the switch to stty size was intentional?

rdwebdesign commented 1 year ago

Do we know if the switch to stty size was intentional?

I think it was, but it needs confirmation.

yubiuser commented 1 year ago

Yes, it was intentional.

Because of the (claimed) tput overhead: https://github.com/dylanaraps/writing-a-tui-in-bash#escape-sequences

https://github.com/dylanaraps/writing-a-tui-in-bash#using-stty

rdwebdesign commented 1 year ago

Did you see this? https://github.com/docker/compose/issues/1876

tty:true should fix it.

klutchell commented 1 year ago

tty: true is set by default by the balena supervisor (I confirmed by inspecting the container).

However I have a workaround by using stty size -F /dev/tty1 so we can close this if no one else is experiencing any issues.

yubiuser commented 1 year ago

Let's keep it open until it goes auto-stale in 30 days. Just to make sure users can find it easier if they experience the same issue.

yubiuser commented 1 year ago

Fix released with https://github.com/pi-hole/PADD/releases/tag/v3.10.0