From f32dda78015e306b14a605291bbfb97f885eb700 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 20 Aug 2014 21:31:15 +0100 Subject: [PATCH] Repair mysql databases on boot --- beaglebone.txt | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/beaglebone.txt b/beaglebone.txt index 757e8362..78562036 100644 --- a/beaglebone.txt +++ b/beaglebone.txt @@ -7298,6 +7298,93 @@ Save and exit. chmod +x /etc/cron.hourly/repair #+END_SRC +Also to keep maintenance to the minimum we need to automatically repair the databases when the system initially boots after a power cycle. So if there's an electrical power outage and the session table gets corrupted then you don't need to be concerned with repairing it manually. + +#+BEGIN_SRC: bash +editor /usr/bin/runinitialrepair +#+END_SRC + +Add the following: + +#+BEGIN_SRC: bash +#!/bin/bash +sleep 180 +/etc/cron.hourly/repair > /var/log/initialrepair.log +exit 0 +#+END_SRC + +Save and exit. + +#+BEGIN_SRC: bash +chmod +x /usr/bin/runinitialrepair +editor /etc/init.d/initialrepair +#+END_SRC + +Add the following: + +#+BEGIN_SRC: bash +#!/bin/bash + +# /etc/init.d/initialrepair + +### BEGIN INIT INFO +# Provides: initialrepair +# Required-Start: $remote_fs $syslog +# Required-Stop: $remote_fs $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: mysql database repair on boot +# Description: Repairs mysql databases at startup +### END INIT INFO + +# Author: Bob Mottram + +#Settings +SERVICE='initialrepair' +INVOCATION='/usr/bin/runinitialrepair' +PATH='/usr/local/sbin:/usr/local/bin:/usr/bin:/sbin:/usr/sbin:/bin' + +initialrepair_start() { +echo "Starting $SERVICE..." +su --command "screen -h 1024 -dmS ${SERVICE} ${INVOCATION}" root +} + + +initialrepair_stop() { +echo "Stopping $SERVICE" +su --command "screen -p 0 -S ${SERVICE} -X stuff "'^C'"" root +} + + +#Start-Stop here +case "$1" in + start) + initialrepair_start + ;; + stop) + initialrepair_stop + ;; + restart) + initialrepair_stop + initialrepair_start + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 + ;; +esac + +exit 0 +#+END_SRC + +Save and exit. + +#+BEGIN_SRC: bash +chmod +x /etc/init.d/initialrepair +update-rc.d initialrepair defaults +service initialrepair start +#+END_SRC + ** Install Tripwire #+BEGIN_VERSE