Category: Linux

Compiling R1Soft Backup Agent on Ubuntu 16.x or 14.x

** UPDATE FOR UBUNTU 16.X **

it’s a little different with these versions of ubuntu, you can follow the instructions below, but when it comes time to updating your grub config, do this instead.

# grep menuentry /boot/grub/grub.cfg

Which, will output all the kernels, which now you just have to ‘count’ the entries, so for example

if [ x"${feature_menuentry_id}" = xy ]; then
 menuentry_id_option="--id"
 menuentry_id_option=""
export menuentry_id_option
menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-8e6c4ba1-8970-4c10-8245-ff967b14dad5' {
submenu 'Advanced options for Ubuntu' $menuentry_id_option 'gnulinux-advanced-8e6c4ba1-8970-4c10-8245-ff967b14dad5' {
 menuentry 'Ubuntu, with Linux 4.4.0-62-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.0-62-generic-advanced-8e6c4ba1-8970-4c10-8245-ff967b14dad5' {
 menuentry 'Ubuntu, with Linux 4.4.0-62-generic (upstart)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.0-62-generic-init-upstart-8e6c4ba1-8970-4c10-8245-ff967b14dad5' {
 menuentry 'Ubuntu, with Linux 4.4.0-62-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.0-62-generic-recovery-8e6c4ba1-8970-4c10-8245-ff967b14dad5' {
 menuentry 'Ubuntu, with Linux 4.4.0-59-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.0-59-generic-advanced-8e6c4ba1-8970-4c10-8245-ff967b14dad5' {
 menuentry 'Ubuntu, with Linux 4.4.0-59-generic (upstart)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.0-59-generic-init-upstart-8e6c4ba1-8970-4c10-8245-ff967b14dad5' {
 menuentry 'Ubuntu, with Linux 4.4.0-59-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.0-59-generic-recovery-8e6c4ba1-8970-4c10-8245-ff967b14dad5' {
 menuentry 'Ubuntu, with Linux 3.16.0-69-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.16.0-69-generic-advanced-8e6c4ba1-8970-4c10-8245-ff967b14dad5' {
 menuentry 'Ubuntu, with Linux 3.16.0-69-generic (upstart)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.16.0-69-generic-init-upstart-8e6c4ba1-8970-4c10-8245-ff967b14dad5' {
 menuentry 'Ubuntu, with Linux 3.16.0-69-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.16.0-69-generic-recovery-8e6c4ba1-8970-4c10-8245-ff967b14dad5' {
menuentry 'Memory test (memtest86+)' {
menuentry 'Memory test (memtest86+, serial console 115200)' {

Now, you just need to ‘count’ the entries, so for us we want to ‘downgrade’ to kernel 3.16.0.69-generic, which, starting at 0, makes it be 7, on the advanced menu.

Because we have a sub menu to deal with, we’ll have to execute this command;

# sudo grub-set-default "1>7"

Which is telling it to use the 7th option, on the 1st option (the submenu for advanced). Now you just run update-grub, and reboot.

# sudo update-grub

Old article below:

If, like us, you use R1Soft backups, you may have recently encountered an error trying to get it to compile on your Ubuntu 14.x or 16.x machines.

This is because they are nearly a year out of date on compiling for the latest kernels, the newest one currently supported is actually 3.16, so, the agent will fail on anything newer than that. You can view all the available module versions from the R1soft repository, by clicking here.

Their support is basically useless [unless you pay], so, we had to find our own solution.

This isn’t the most elegant way to fix things, but, it works, so there’s that. [I guess]. Basically, 16.x comes with kernel 4.4, which won’t work, so what did we end up having to do? Downgrade the kernel!  

Well, not literally downgrade, we just used the older, supported kernel that was already installed.

To make this work for you, you’ll have to edit the grub configuration, by doing this.

# cp /etc/default/grub /etc/default/grub.bak

# nano /etc/default/grub

and make these changes

GRUB_DEFAULT=saved 
GRUB_TIMEOUT=2

then exit and save the file.

Now, we’re going to have to find out which kernels you have installed, for us, we simply did the following;

# grep menuentry /boot/grub/grub.cfg

Which, will give you output similar to the following;

menuentry 'Ubuntu, with Linux 4.4.0-31-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.0-31-generic-advanced-64f733aa-c9fe-4aed-b662-8fd6b99d6825' {
menuentry 'Ubuntu, with Linux 4.4.0-31-generic (upstart)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.0-31-generic-init-upstart-64f733aa-c9fe-4aed-b662-8fd6b99d6825' {
menuentry 'Ubuntu, with Linux 4.4.0-31-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.0-31-generic-recovery-64f733aa-c9fe-4aed-b662-8fd6b99d6825' {
menuentry 'Ubuntu, with Linux 3.16.0-77-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.16.0-77-generic-advanced-64f733aa-c9fe-4aed-b662-8fd6b99d6825' {
menuentry 'Ubuntu, with Linux 3.16.0-77-generic (upstart)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.16.0-77-generic-init-upstart-64f733aa-c9fe-4aed-b662-8fd6b99d6825' {
menuentry 'Ubuntu, with Linux 3.16.0-77-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.16.0-77-generic-recovery-64f733aa-c9fe-4aed-b662-8fd6b99d6825' {

In our case, we want to use the 3.16.0.77 version of the kernel, so, we simply issue these commands;

# grub-set-default "gnulinux-advanced-64f733aa-c9fe-4aed-b662-8fd6b99d6825>gnulinux-3.16.0-77-generic-advanced-64f733aa-c9fe-4aed-b662-8fd6b99d6825"
# grub-reboot "gnulinux-advanced-64f733aa-c9fe-4aed-b662-8fd6b99d6825>gnulinux-3.16.0-77-generic-advanced-64f733aa-c9fe-4aed-b662-8fd6b99d6825"
# update-grub

then, you’re ready to reboot into your shiny old kernel

# reboot

now, you can verify that the R1Soft agent is working again, using this;

# hcp -v

Idera Hot Copy 5.14.4 build 433 (http://www.r1soft.com)
Documentation http://wiki.r1soft.com
Forums http://forum.r1soft.com

Thank you for using Hot Copy!
Idera makes the only Continuous Data Protection software for Linux.

hcp driver module: 4.6.1 build: 41

and

# /usr/sbin/r1soft/bin/cdp -v
(R1Soft CDP Agent) version 5.14.4 build 433 2016/07/18 16:41:16

That’s it! you’ve got working backups again!

 

Compiling Mod_Geoip2 for use with EasyApache 4 (EA4) and cPanel via command line (CLI)

We’ve recently switched to using Easy Apache 4 (EA4) on our cPanel installs as it’s ‘basically not beta’ now. And we ran into a problem where a site needed to have GeoIP installed but it wasn’t available to us through the WHM control panel.

After some extensive searching and trial and error, we were able to come up with instructions that worked for our particular install which I’ll document below incase someone else needs these.

Note, these assume you already have EasyApache 4 and php installed and configured — a working environment. 

Instructions for getting mod_geoip2 working on easyapache 4 (ea4)

  1. Step one login to your server. I personally just ‘su root’ instead of ‘sudo’ all the time, but I’m lady, and confident I won’t ‘rm -rf /lib’ or something equally as asinine.
  2. Now you’re going to want to issue this command;
    # yum install GeoIP GeoIP-devel GeoIP-data zlib-devel
  3. Then, we’re going to want to issue the following to create the GeoIP directory, and enter it
    # mkdir /usr/share/GeoIP && cd /usr/share/GeoIP
    
  4. Now we’ll want to grab the data files from MaxMind. These commands with download the city and country info.
    # wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
    # wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
    # gunzip GeoIP.dat.gz
    # gunzip GeoLiteCity.dat.gz
  5. Now we’re going to want to install some requirements for everything to build. If you already have something installed from this list it will just ignore it and install the rest.
    # yum install httpd-devel apr-devel ea-apache24-devel.x86_64 ea-apache24-tools.x86_64 wget nano
  6. You should still be in the same GeoIP directory but if you’re not just enter these commands to enter the directory you need to be in.
    cd /usr/share/GeoIP
  7. Now you’re going to want to grab the GeoIP source for apache module. Then, uncompress it, and, enter the directory.
    wget ftp://ftp.netbsd.org/pub/pkgsrc/distfiles/mod_geoip2_1.2.5.tar.gz
    # tar xvzf mod_geoip2_1.2.5.tar.gz && cd mod_geoip2_1.2.5 
  8. Now we have to make a change due to apache 2.4 and some name changes, so, run this command now.
    # sed s/remote_ip/client_ip/g -i mod_geoip.c
  9. And finally we can go ahead and compile the module.
    # apxs -i -a -L/usr/lib64 -I/usr/include -lGeoIP -c mod_geoip.c
  10. Now we just have to modify the httpd.conf file for Apache to load the module
    # nano /etc/apache2/conf.modules.d/mod_geoip.conf
  11. Change the content of this file so instead of looking like this;
    LoadModule geoip_module       /usr/lib64/apache2/modules/mod_geoip.so

    instead, make sure it looks like this;

    LoadModule geoip_module /usr/lib64/apache2/modules/mod_geoip.so
    
    <IfModule mod_geoip.c>
    GeoIPEnable On
    GeoIPDBFile /usr/share/GeoIP/GeoIP.dat Standard
    GeoIPDBFile /usr/share/GeoIP/GeoLiteCity.dat Standard
    </IfModule>

    Then, exit and save the file.

  12. Now you’ll want to restart apache.
    # service httpd restart && apachectl restart
  13. Then you can go ahead and create an info file and check via the web if geoip is supported.
    # nano /var/www/info.php
  14. Put these contents in it
    <?php phpinfo(); ?>
  15. Close and exit the file, then visit your site at http://YOUR_DOMAIN.COM/info.php and you should see something similar to the following.geoip-easyapache4

  16. Congrats, you’re done!

Let me know if there’s any changes that need to be made to this or if this helped you in your quest to get mod_geoip2 working with cpanel/whm and easyapache 4 in the comments below!

 

Setup Auto Updating Apt-get Update/Upgrade with Logging

Here’s some quick steps on how to setup automatic apt-get upgrade and apt-get update on your ubuntu server, with the capability of logging and sending someone of your choosing a notification of the updates and what the output was.

I pieced this together from various sources around the web into a step by step quick tutorial both for myself, and others to use to make it easier when wanting to set this up across servers.

It’s a pretty handy addition to any administration tool kit as it cuts down on time ssh’ing in and manually running this, and is especially useful because it’s got logging so you only have to login if there was an issue!

** nb assumes a proper postfix / default setup.

INSTRUCTIONS

** nb assumes a proper postfix / default setup.

1) SSH to server

2) login / su to root

3) issue these commands:

# nano /root/autoupd

4) paste these items in

#!/bin/bash
tmpfile=$(mktemp)
hostname=$(hostname)
ourtime=`date +"%m-%d-%y"`
echo "APT UPDATE RESULTS:" >> ${tmpfile}
echo "*---*" >> ${tmpfile}
aptitude update >> ${tmpfile} 2>&1
echo "" >> ${tmpfile}
echo "APT UPGRADE RESULTS:" >> ${tmpfile}
echo "*---*" >> ${tmpfile}
aptitude -y full-upgrade >> ${tmpfile} 2>&1
echo "" >> ${tmpfile}
echo "APT CLEAN RESULTS:" >> ${tmpfile}
echo "*---*" >> ${tmpfile}
aptitude clean >> ${tmpfile} 2>&1
mail -s "[${ourtime}] - [${hostname} patches]" root < ${tmpfile}
rm -f ${tmpfile}

5) issue this for your aliases file

# nano /etc/aliases

6) make sure this exists:

root: mail@yourdomain.com

replacing with your proper email address, obviously.

7) run newaliases to ensure functionality

# newaliases

8) restart postfix

# service postfix restart

9) test the script

# chmod +x /root/autoupd
# /root/autoupd

10) you should now have an email in your inbox with the results, if not grab a coffee and start troubleshooting.

11) now you want to make this run daily by copying it to your daily cron directory and make it executable again, just incase something changed.

# cp /root/autoupd /etc/cron.daily/autoupd
# chmod +x /etc/cron.daily/autoupd

12) that’s it, wait for the email notifications!