LibreELEC.wiki
  • Introduction
  • Support
    • Log Files
    • Updating
  • Installation
    • Create Media
    • Add-Ons
    • Containers
    • Security
  • Hardware
    • Allwinner
    • Amlogic
      • BananaPi M5 / M2S
      • LaFrite
      • WeTek Hub/Play2
    • NXP - iMX6/iMX8
    • Intel x86-64 (Generic)
      • Laptops
    • Qualcomm
    • Raspberry Pi
    • Rockchip
    • Samsung (Exynos)
    • Virtual Image
  • Configuration
    • 4K / HDR
    • Blu-Ray Playback
    • Config.txt
    • Cron
    • Dual Boot
    • EDID
    • Fonts
    • Hidden WiFi
    • Hypercon
    • Hyperion
    • Infra-Red Remotes
    • LCDProc
    • Network Boot
    • Pulseaudio
    • Safe Mode
    • Samba
    • SSL/TLS Certificates
    • Startup & Shutdown
    • Useful Scripts
    • WireGuard
  • How To
    • Add Firmware
    • Blacklist Kernel Module
    • Change Bootsplash
    • Force Add-on Update
    • Add content via Samba Shares
    • Mount Network Share
  • Development
    • Building (Basics)
    • Building (Docker)
    • Building (Advanced)
    • Building (Windows WSL)
    • Beginners Guide to Git
    • Build Commands
      • Build Commands (Add-ons)
      • Build Commands LE 12.0.x
      • Build Commands LE 11.0.x
      • Build Commands LE 10.0.x
      • Build Commands LE 9.2.x
      • Build Commands LE 9.0.x
      • Build Commands LE 8.2.x
      • Build Commands LE 8.0.x
      • Build Commands LE 7.0.x
    • Nightly Images
    • Release Management
    • Website
  • Project
    • Releases
    • Forks
    • Licenses
      • Source Code
      • Documentation
    • Mirrors
Powered by GitBook
On this page
  • autostart.sh
  • autostop.sh
  • shutdown.sh

Was this helpful?

Edit on GitHub
Export as PDF
  1. Configuration

Startup & Shutdown

autostart.sh

The autostart.sh script runs at the start of userspace boot. It can be used to run commands before Kodi starts. It does not exist by default, but you can create it using nano.

nano /storage/.config/autostart.sh

You can place any commands in the script, but note they will block the boot process until they complete, so most uses of autostart.sh require you to "background" and delay the commands, e.g. the following script sleeps for 20 seconds and then runs a kodi-send command to update the video library.

(
 sleep 20
 kodi-send --host=127.0.0.1 -a "UpdateLibrary(video)"
)&

The network stack will be up when the script runs.

autostop.sh

The autostop.sh script runs during the shutdown process, but before the network is shutdown. It does not exist by default, but you can create it using nano.

nano /storage/.config/autostop.sh

Like the autostart.sh script you can place any commands in the script, and they will block the shutdown process for up to 5 minutes and then will be terminated automatically.

autostop.sh is available as of LibreELEC 10.0.2 or LibreELEC 11 nightlies 2022-02-04.

shutdown.sh

The shutdown.sh script run during the shutdown process. It does not exist by default, but you can create it using nano.

nano /storage/.config/shutdown.sh

Unlike the autostart.sh script the network stack will not be up when the script runs and the shutdown.sh script should follow the following template to ensure commands are executed during the correct event, i.e. you can run different commands for a reboot event to halt event, or put commands outside the case ... esac as a catch-all.

case "$1" in
  halt)
    # your commands here
    ;;
  poweroff)
    # your commands here
    ;;
  reboot)
    # your commands here
    ;;
esac
# your commands here
PreviousSSL/TLS CertificatesNextUseful Scripts

Last updated 2 years ago

Was this helpful?