I am new to bash-programming, sorry if this might be a kind of stupid question. I found a script on my server and i am trying to understand every line:
#!/bin/sh
#
# man-db cron weekly
set -e
if ! [ -d /var/cache/man ]; then
# Recover from deletion, per FHS.
mkdir -p /var/cache/man
chown man:root /var/cache/man || true
chmod 2755 /var/cache/man
fi
# regenerate man database
if [ -x /usr/bin/mandb ]; then
# --pidfile /dev/null so it always starts; mandb isn't really a daemon,
# but we want to start it like one.
start-stop-daemon --start --pidfile /dev/null \
--startas /usr/bin/mandb --oknodo --chuid man \
-- --quiet
fi
exit 0
Some things i don't understand like
set -e
I read about it, that it "checks" your commands. So it gives warnings or an exception if something goes wrong? Or a more detailed error-report?
if ! [ -d /var/cache/man ]; then OR
if [ -x /usr/bin/mandb ]; then
What i don't understand are the "-d" or "-x" commands at the if clause, imho there is something missing there.
chown man:root /var/cache/man || true
I don't understand the last part, what's the reason for this "OR TRUE".
Maybe somebody can help me?
tia && regards noircc