# Prerequisites:
# A Linux kernel with a watchdog driver
# You need to build a kernel or use a distribution pre-built kernel with a
# watchdog driver in it (or a module). If you have a vanilla kernel
# you will find some info about it here:
# /usr/src/linux/Documentation/watchdog/
# or here:
# https://www.kernel.org/doc/Documentation/watchdog/
# and in some of the source files here:
# /usr/src/linux/drivers/watchdog/
# Get it
cd
test -f installed/watchdog-5.13.tar.gz &&
mv installed/watchdog-5.13.tar.gz .
test ! -f watchdog-5.13.tar.gz &&
wget http://downloads.sourceforge.net/watchdog/watchdog-5.13.tar.gz
# Extract the source
mkdir -p -m 0700 src
cd src
find -maxdepth 1 -type d -name "watchdog-*" -exec rm -r {} \;
tar xzvf ~/watchdog-5.13.tar.gz
cd watchdog-5.13
test $UID = 0 && chown -R root:root .
# Configure the build
# Read ./INSTALL and 'configure --help' for info about configure options
./configure --mandir=/usr/man
# Build it
make
# Become root to install it
su
# Install it
make install
# For info about running and configuring it:
man watchdog
man watchdog.conf
man wd_identify
man wd_keepalive
# I would recommend NOT adding it to start on boot-up automatically until
# you've run it manually to make sure there are no issues and it does not
# start rebooting your system over and over again. If you are not familiar
# with booting in single-user mode or booting from a CD/DVD or USB flash
# drive, might want to read up on that first too just in case.
## Once you are ready to make it start automatically, either run it from
## /etc/rc.d/rc.local with something like this (-v = syslog):
# if [ -x /usr/sbin/watchdog ]; then
# echo "Starting watchdog daemon..."
# /usr/sbin/watchdog -v
# fi
## or modify the the included ./debian/init script or redhat/watchdog.init
## as /etc/rc.d/init.d/watchdog, or use the one I already created.
## If you only need it to run in runlevel 3, like I do, that's the only Sxx
## symlink you need to create. Run 'runlevel' to see your current one.
## Look in /etc/inittab to see more about the runlevels in Slackware.
## Some other distributions no longer use that, so don't be surprised when
## it does not exist in Ubuntu, etc.
if [ -d /etc/rc.d/init.d ]; then
wget -nc http://englanders.us/pub/linux/misc/rc.watchdog \
-O /etc/rc.d/init.d/watchdog
chown root:root /etc/rc.d/init.d/watchdog
chmod 700 /etc/rc.d/init.d/watchdog
ln -sf /etc/rc.d/init.d/watchdog /etc/rc.d/rc3.d/S99watchdog
fi
## ...and either do this to override a few things in that script, or
## edit the script directly
if [ -d /etc/default ]; then
test ! -f /etc/default/watchdog &&
echo -e "run_watchdog=1\nwatchdog_options=\"-v\"" > /etc/default/watchdog
chown root:root /etc/default/watchdog
chmod 600 /etc/default/watchdog
fi
# If you want to run it in test mode first, run it with -q by updating
# /etc/default/watchdog or adding it in /etc/rc.d/rc.local or however you
# set it to start
# If you went with the init.d way above, start the daemon like so:
test -x /etc/rc.d/init.d/watchdog && /etc/rc.d/init.d/watchdog start
# Become your non-root user again
exit
# Save the source for later
cd
mkdir -p -m 0700 installed
rm -f installed/watchdog-*.tar.gz
mv -f watchdog-5.13.tar.gz installed/
# If you ever want to uninstall watchdog, this should do it:
cd
su
test -x /etc/rc.d/init.d/watchdog stop
sleep 2
killall watchdog
sleep 2
killall -9 watchdog
sleep 2
test -d src/watchdog-* && ( cd src/watchdog-* ; make uninstall )
test -d /etc/watchdog.d && rm -r /etc/watchdog.d
( cd /usr/man/man8 ; rm -f watchdog.8 wd_identify.8 wd_keepalive.8 )
( cd /usr/sbin ; rm -f watchdog wd_identify wd_keepalive )
rm -f /etc/watchdog.conf /etc/rc.d/init.d/watchdog \
/etc/rc.d/rc?.d/S27watchdog /etc/rc.d/rc?.d/K40watchdog \
/usr/man/man5/watchdog.conf.5 /var/run/watchdog.pid \
/var/run/wd_keepalive.pid
ldconfig
exit
find ~/src -maxdepth 1 -type d -name "watchdog-*" -exec rm -r {} \;
rm -f ~/installed/watchdog-*.tar.*