Trying tom make schedule for turning on off display/HDMI

i am new to balena and trying to add display turn on/off to a application.

the service appers on the application and running but not working .

ther error code i am getting is

10.04.19 12:51:18 (+0200) display /usr/src/start.sh: 7: /usr/src/start.sh: Syntax error: end of file unexpected (expecting “then”)

have tried too google the problem but no distinct explanation what the trouble is.

have added the Device Environment Variables

DISPLAY_OFF 43 12 * * *
DISPLAY_ON 0 7 * * *
ENABLE_DISPLAY_TIMER 1

one error/warning appers when pushing and that is

[display] debconf: delaying package configuration, since apt-utils is not installed

what i found is that i can ignore it.


orgininal i code i am using is the balena-dash-master

and added a service " display"

with script folder with start.sh display_ on.sh and display_off.sh

start.sh

#!/bin/bash`
if [ “$ENABLE_BACKLIGHT_TIMER” -eq “1” ]
then
(crontab -l; echo “${BACKLIGHT_ON:-0 8 * * *} /usr/src/backlight_on.sh”) | crontab -
(crontab -l; echo “${BACKLIGHT_OFF:-0 23 * * *} /usr/src/backlight_off.sh”) | crontab -
fi

crond -f

display_off.sh

#!/bin/bash

echo 'standby 0' | cec-client -s -d 1


display_on.sh

#!/bin/bash

echo 'on 0' | cec-client -s -d 1

Dockerfile

FROM balenalib/raspberrypi3-ubuntu

RUN install_packages cec-utils -y

COPY scripts /usr/src/

RUN chmod +x /usr/src/*.sh

CMD /usr/src/start.sh


docker.compose.yml

version: ‘2’
services:
wpe:
restart: always
build: ./wpe
privileged: true
ports:
- 80:80
display:
restart: always
build: ./display
privileged: true
scheduler:
restart: always
build: ./scheduler
privileged: true
wifi-connect:
build: ./wifi-connect
restart: always
network_mode: host
privileged: true
labels:
io.balena.features.dbus: ‘1’
io.balena.features.firmware: ‘1’

@C.Hellman welcome to the forums.

I can’t tell for sure but you seem to have quite a few issues with your start.sh script. There are missing $ signs and unicode quotes (i.e. ones that look like 66/99) - if you’re editing script files like this I’d recommend a text editor like Atom which won’t give you those problems.

You can also use a tool like Shellcheck to check your script before pushing it to the device.

I’ve corrected your script so you can give that a try:

#!/bin/bash
if [ "$ENABLE_BACKLIGHT_TIMER" -eq "1" ]
then
        (crontab -l; echo "${BACKLIGHT_ON:-0 8 * * *} /usr/src/backlight_on.sh") | crontab -
        (crontab -l; echo "${BACKLIGHT_OFF:-0 23 * * *} /usr/src/backlight_off.sh") | crontab -
fi

I hope this helps!

1 Like