Fix database recovery

This commit is contained in:
Bob Mottram 2014-08-10 19:28:39 +01:00
parent e2223cde9b
commit b8627554d3
1 changed files with 141 additions and 116 deletions

View File

@ -3302,171 +3302,196 @@ Now visit your blog and follow the setup instructions, which are quite minimal.
IRC is not an especially secure system. For instance, even with the best encryption it's easily possible to imagine IRC-specific cribs which could be used by cryptanalytic systems. However, we'll try to implement it in a manner which will at least give the surveillance aparatus something to ponder over.
First install some dependencies.
Because hybrid doesn't support OpenSSL by default, you have to do a manual patch to get it working.
#+BEGIN_SRC: bash
cd ~/build
mkdir hybrid
cd hybrid
apt-get update
apt-get install build-essential openssl libssl-dev debhelper dpatch docbook-to-man flex bison libpcre3-dev screen
apt-get source ircd-hybrid
#+END_SRC
Then get the source code for ircd-hybrid.
To enable SSL
#+BEGIN_SRC: bash
mkdir ~/build
cd ~/build
wget http://freedombone.uk.to/ircd-hybrid-8.1.17.tgz
editor ircd-hybrid-*/debian/rules
#+END_SRC
verify it.
At the top add:
#+BEGIN_SRC: bash
sha256sum ircd-hybrid-8.1.17.tgz
440c9d86ba6bc930efef9cdaaec547b425c35cad3f08bed8df69e55788c1268a
USE_OPENSSL = 1
#+END_SRC
Install it.
So the file should looks like:
#+BEGIN_SRC: bash
tar -xzvf ircd-hybrid-8.1.17.tgz
cd ircd-hybrid-8.1.17
./configure --prefix=/usr/local/ircd --enable-openssl
make
make install
1# ...
2# Some useful stuff to edit here.
3# Beware: TOPICLEN may not exceed 390.
4NICKLEN = 15
5TOPICLEN = 350
6MAXCLIENTS = 200
7USE_OPENSSL = 1
8# ...
#+END_SRC
Customise the configuration to your system, giving it a name and description. In this example 192.168.1.60 is the static IP address on the BBB on the local network, so change that if necessary.
Save and exit, then rebuild the deb-file and install it:
#+BEGIN_SRC: bash
chown -R irc:irc /usr/local/ircd
cp /usr/local/ircd/etc/reference.conf /usr/local/ircd/etc/ircd.conf
editor /usr/local/ircd/etc/ircd.conf
cd ircd-hybrid-*
dpkg-buildpackage -rfakeroot -uc -b
cd ..
dpkg -i ircd-hybrid_*.deb
#+END_SRC
Set *name* to the domain name of your server, and set a description.
Edit connect, listen and operator settings:
Set a *network_name* and *network_desc*. The network name should not contain any spaces.
#+BEGIN_SRC: bash
editor /etc/ircd-hybrid/ircd.conf
#+END_SRC
Set max_clients to 20, or however many you expect that you'll typically need.
Edit the connect section. Set *name* to the name of your server, and set a description.
#+BEGIN_SRC: c
connect {
/* name: the name of the server */
name = "myircdomainname.com";
Set a *network_name* and *network_desc*.
/* host: the host or IP to connect to. If a hostname is used it
* must match the reverse dns of the server.
*/
host = "127.0.0.1";
#+END_SRC
Set max_clients to 20.
#+BEGIN_SRC: c
/* passwords: the passwords we send (OLD C:) and accept (OLD N:).
* The remote server will have these passwords reversed.
*/
send_password = "password";
accept_password = "password";
#+END_SRC
Within the admin section set your *name* and *email*.
Within the *listen* section set host to your fixed IP address (in the earlier
sections it was 192.168.1.60).
Enable compression.
Within the *auth* section set user = "*@192.168.1.60" - or whatever the fixed IP address of the BBB is on your network - and password to the desired password for the IRC server. If you don't wish to use a password then remove need_password from the flags.
Within the *connect* section set *host* and *vhost* to your fixed IP address (in the earlier
sections it was 192.168.1.60) and *name* to your domain name. Also set the *send/accept passwords* to your IRC login password.
Within the *operator* section change *name* to the username/nick which you will user to irc@192.168.1.60
Change *ssl_connection_required* to *yes*.
Save and exit, then restart the IRC server. Open port 6697 on your internet router and forward it to the BBB. Note that although ports 6665 to 6669 are active within the configuration file in practice we will only use the encrypted port.
Ensure that the configuration is only readable by the root user.
#+BEGIN_SRC: bash
chmod 600 /usr/local/ircd/etc/ircd.conf
#+BEGIN_SRC: c
/* compressed: controls whether traffic is compressed via ziplinks.
* By default this is disabled
*/
compressed = yes;
};
#+END_SRC
Now create an init script.
Within the *listen* section set host to your fixed IP address (in the earlier sections it was 192.168.1.60).
#+BEGIN_SRC: bash
adduser irc
#+BEGIN_SRC: c
/* listen {}: contain information about the ports ircd listens on (OLD P:) */
listen {
/* port: the specific port to listen on. if no host is specified
* before, it will listen on all available IPs.
*
* ports are seperated via a comma, a range may be specified using ".."
*/
/* port: listen on all available IPs, ports 6665 to 6669 */
host = "127.0.0.1";
port = 6665 .. 6669;
/* sslport: ports to accept ONLY ssl connections on */
flags = ssl;
port = 6697
};
#+END_SRC
Make the password some long random string.
Generate a password for the IRC operator using mkpasswd tool.
#+BEGIN_SRC: bash
editor /usr/bin/runircd
mkpasswd -Hmd5
#+END_SRC
Add the following:
Search for operator block and change it to look like this, including the password which you just generated:
#+BEGIN_SRC: bash
#!/bin/sh
USERNAME=irc
COMMAND="cd /usr/local/ircd/bin; ircd > /usr/local/ircd/ircd.log"
su -l $USERNAME -c '$COMMAND'
#+BEGIN_SRC: c
# ...
operator {
/* name: the name of the oper */
name = "root";
/* user: the user@host required for this operator. CIDR is not
* supported. multiple user="" lines are supported.
*/
user = "*@*";
/* password: the password required to oper. By default this will
* need to be encrypted using '/usr/bin/mkpasswd'.
* WARNING: Please do not mix up the 'mkpasswd' program from
* /usr/sbin with this one. If you are root, typing 'mkpasswd'
* will run that one instead and you will receive a strange error.
*
* MD5 is supported. If you want to use it, use mkpasswd -Hmd5.
*/
password = "#MD5 PASSWORD HERE#";
# ...
#+END_SRC
Within the *auth* section set user = "*@192.168.1.60" - or whatever the fixed IP address of the BBB is on your network.
Save and exit.
#+BEGIN_SRC: bash
chmod +x /usr/bin/runircd
editor /etc/init.d/ircd-hybrid
#+BEGIN_SRC: c
service ircd-hybrid restart
#+END_SRC
Add the following:
Now open ports 6665 to 6669 on your internet router/firewall.
After connecting to IRC server you should see something like this:
#+BEGIN_SRC: bash
#!/bin/bash
# /etc/init.d/ircd-hybrid
### BEGIN INIT INFO
# Provides: ircd-hybrid
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts irc server
# Description: starts irc server
### END INIT INFO
# Author: Bob Mottram <bob@robotics.uk.to>
#Settings
SERVICE='ircd-hybrid'
COMMAND="runircd"
USER='irc'
NICELEVEL=19 # from 0-19 the bigger the number, the less the impact on system resources
HISTORY=1024
INVOCATION="nice -n ${NICELEVEL} ${COMMAND}"
PATH='/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/core_perl:/sbin:/usr/sbin:/bin'
irc_start() {
echo "Starting $SERVICE..."
su --command "screen -h ${HISTORY} -dmS ${SERVICE} ${INVOCATION}" $USER
}
irc_stop() {
echo "Stopping $SERVICE"
pkill ${COMMAND}
}
#Start-Stop here
case "$1" in
start)
irc_start
;;
stop)
irc_stop
;;
restart)
irc_stop
sleep 10s
irc_start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac
exit 0
23:50 -!- - hybrid7.debian.local Message of the Day -
23:50 -!- - _,met$$$$$gg. ircd-hybrid 7.2.2
23:50 -!- - ,g$$$$$$$$$$$$$$$P. -----------------
23:50 -!- - ,g$$P"" """Y$$.".
23:50 -!- - ,$$P' `$$$. If you are seeing this, you have
23:50 -!- - ',$$P ,ggs. `$$b: installed the ircd-hybrid package and
23:50 -!- - `d$$' ,$P"' . $$$ you are now connected to your new IRC
23:50 -!- - $$P d$' , $$P server -- congratulations.
23:50 -!- - $$: $$. - ,d$$'
23:50 -!- - $$; Y$b._ _,d$P' Since you have just installed the
23:50 -!- - Y$$. `.`"Y$$$$P"' package, there are some things you
23:50 -!- - `$$b "-.__ should do before going any further:
23:50 -!- - `Y$$b
23:50 -!- - `Y$$. 1. Edit /etc/ircd-hybrid/ircd.conf to
23:50 -!- - `$$b. suit your needs. Beware some options have
23:50 -!- - `Y$$b. been removed or moved into other blocks in
23:50 -!- - `"Y$b._ the configuration file since
23:50 -!- - `"""" ircd-hybrid 7.0.3.
23:50 -!- -
23:50 -!- - 2. Edit /etc/ircd-hybrid/ircd.motd (this
23:50 -!- - MOTD) to suit your needs. You are free
23:50 -!- - to use this Debian swirl under the
23:50 -!- - Debian Open Use Logo License. :)
23:50 -!- -
23:50 -!- - 3. Restart the server using invoke-rc.d
23:50 -!- - ircd-hybrid restart.
23:50 -!- -
23:50 -!- End of /MOTD command.
#+END_SRC
Save and exit, then start the daemon.
If necessary you can change the message of the day with:
#+BEGIN_SRC: bash
editor /etc/ircd-hybrid/ircd.motd
#+END_SRC
The restart the irc server.
#+BEGIN_SRC: bash
chmod +x /etc/init.d/ircd-hybrid
update-rc.d ircd-hybrid defaults
service ircd-hybrid start
#+END_SRC
@ -7169,7 +7194,7 @@ mysqlcheck -c -u root --password=$MYSQL_ROOT_PASSWORD $DATABASE > $TEMPFILE
# If it still contains errors then restore from backup
if grep -q "Error" "$TEMPFILE"; then
mysql -u root --password=$MYSQL_ROOT_PASSWORD $DATABASE -o < /var/backups/$DATABASE_daily.sql
mysql -u root --password=$MYSQL_ROOT_PASSWORD $DATABASE -o < /var/backups/${DATABASE}_daily.sql
# Send a warning email
echo "$DATABASE database corruption could not be repaired. Restored from backup." | mail -s "Freedombone database maintenance" $EMAIL