You want to start hacking on your device running LibreELEC but creating Kodi packages sounds overkilled to you? Then this might be for you.
You want to distribute your cool new tool to many users? Then use Kodi packages, please.
What this does? Well, it creates a folder structure
and integrates this into LibreELEC. You can start all binaries from ~/modroot/bin without specifying the directory, libraries in ~/modroot/lib will be picked up automatically (in fact you're even able to overwrite LibreELECs libraries by placing them there) and ~/modroot/etc is for config files (here you're able to overwrite LibreELECs buildins, too).
So how does it work? Simple: It's all a single shell script that you use as autostart file (~/.config/autostart.sh). Here it is:
#!/bin/sh
#####################################################################################################
# Use this as autostart.sh for OpenELEC or LibreELEC to get a mini root for modifications to the #
# underlying Linux system. #
# #
# (c) 2016 Thomas "V10lator" Rohloff <[email protected]> #
# License: Use this for whatever you want but consider buying me a beer if you like it. #
# #
# USE IT ON YOUR OWN RISK! #
#####################################################################################################
# In case we aren't booting don't do anything
case "$1" in
halt)
exit 0
;;
poweroff)
exit 0
;;
reboot)
exit 0
;;
esac
MODROOT="/storage/modroot"
MODCONF="/etc/profile.d/9999-modroot.conf"
# Create mini mod root if needed
for DIR in "${MODROOT}" "${MODROOT}/bin" "${MODROOT}/lib" "${MODROOT}/etc" "${MODROOT}/.work" ; do
if [ ! -d "${DIR}" ]; then
if [ -e "{$DIR}" ]; then
logger -t "Modroot" "${DIR} exists but is not a directory! Aborting"
exit 1
fi
mkdir "${DIR}"
fi
done
# rw overlay above /etc
mount -t overlay overlay -o lowerdir=/etc,upperdir=/storage/modroot/etc,workdir=/storage/modroot/.work /etc
# Set PATH and LD_LIBRARY_PATH temporary (needed for chainloading later)
PATH="${MODROOT}/bin:${PATH}"
LD_LIBRARY_PATH="${MODROOT}/lib:${LD_LIBRARY_PATH}"
# Add PATH and LD_LIBRARY_PATH permamently into hacked profile
if [ ! -e "${MODCONF}" ]; then
echo "export PATH=\"${MODROOT}/bin:\${PATH}\"" > "${MODCONF}"
echo "export LD_LIBRARY_PATH=\"${MODROOT}/lib:\${LD_LIBRARY_PATH}\"" >> "${MODCONF}"
fi
# Create example autostart in modroot
if [ ! -e "${MODROOT}/bin/autostart" ]; then
echo "#!/bin/sh" > ${MODROOT}/bin/autostart
echo "logger \"Modroot\" \"Chainloading successfull!\"" >> ${MODROOT}/bin/autostart
chmod +x ${MODROOT}/bin/autostart
fi
# Chainload into mini mod root
${MODROOT}/bin/autostart
Display More
Wait, how to use autostart now? Just use ~/modroot/bin/autostart - It can be a binary, a shell script or anything other executable by LibreELEC.