I'm running Armbian Linux and trying to execute a shell file at boot. The file runs perfectly when I execute it through the command line after boot. However, it skips my Python commands (which are supposed to send animations to an OLED screen) when it runs during boot. It does still, however, turn on and off an LED.
The shell file is placed in /etc/init.d and I ran the following commands.
sudo update-rc.d startup.sh defaults
sudo update-rc.d startup.sh enable
chmod +x /etc/init.d/startup.sh
Here is the shell file.
#!/bin/sh
### BEGIN INIT INFO
# Provides: startup
# Required-Start: $all
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: display to screen
### END INIT INFO
main() {
#GPIO numbers for the RGB-Led Pins
RGB_GPIO_RED=157
RGB_GPIO_GREEN=156
RGB_GPIO_BLUE=154
#OLED settings
OLED_I2C_PORT=2
OLED_ORIENTATION=2
OLED_DISPLAY_TYPE='sh1106'
# turn on the blue led while configuring and updating
cd /sys/class/gpio
sudo sh -c 'echo '$RGB_GPIO_BLUE' > export'
cd gpio$RGB_GPIO_BLUE
sudo sh -c 'echo out > direction'
sudo sh -c 'echo 1 > value'
cd ~
# display cardano animation
python ~/display/cardano-luma/examples/cardano-animation.py --display $OLED_DISPLAY_TYPE --i2c-port $OLED_I2C_PORT --rotate $OLED_ORIENTATION
# turn off blue led and on the green led
cd /sys/class/gpio
sudo sh -c 'echo '$RGB_GPIO_BLUE' > export'
cd gpio$RGB_GPIO_BLUE
sudo sh -c 'echo out > direction'
sudo sh -c 'echo 0 > value'
cd ..
cd /sys/class/gpio
sudo sh -c 'echo '$RGB_GPIO_GREEN' > export'
cd gpio$RGB_GPIO_GREEN
sudo sh -c 'echo out > direction'
sudo sh -c 'echo 1 > value'
cd ~
# display rock pi information
sudo python ~/display/cardano-luma/examples/cardano.py --display $OLED_DISPLAY_TYPE --i2c-port $OLED_I2C_PORT --rotate $OLED_ORIENTATION
}
main "$@" || exit 1