Repair mysql databases on boot

This commit is contained in:
Bob Mottram 2014-08-20 21:31:15 +01:00
parent c18a8bae35
commit f32dda7801
1 changed files with 87 additions and 0 deletions

View File

@ -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 <bob@robotics.uk.to>
#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