Is it possible to have conditionals in /etc/rc.local?
The [[ ... ]]
syntax isn't valid for /bin/sh
. Try:
if [ -e /usr/src/an-existing-file ]
then
echo "seen" >> /etc/rclocalmadethis
fi
Note that sometimes it works because /bin/sh -> /bin/bash
or some other shell that supports that syntax, but you can't depend on that being the case (as you see here).
You can run ls -l /bin/sh
to get to know this info for instance:
lrwxrwxrwx 1 root root 4 Jul 18 2019 /bin/sh -> dash
[[
is a bash feature not available in sh
:
root@d4b4b6325f2a:/# type [[
[[ is a shell keyword
root@d4b4b6325f2a:/# sh
# type [[
[[: not found