More Kernel Updates and Modded Kernel Update

Looks like as soon as I got the repo all up to date with mainline, 3 new kernels were pushed out.

3.6.0 was updated to 3.6.1

3.5.5 was updated to 3.5.6

3.4.12 was updated to 3.4.13

I’m working on compiling these as we speak and they should all be pushed to the repository tomorrow morning or early afternoon.

Now… on to Modded Kernels. I spent all weekend playing around with different IO schedulers in the block layer as well as messing with BFS (Brain F*** Scheduler) and I’ve concluded, through some pretty serious benchmarking, that they are once again, not worth building at this point. In most cases there is a slight (and I mean very slight) gain in CPU performance, but a loss of performance in everything else (RAM Speed and Hard Drive Read / Write). At this point, I will not be pursuing modded kernels. I’m also getting a new solid state for my notebook and primary testing rig – this should make everything a bit faster. Once that happens as well I will also be adding a Debian repository that follows the same kernel line that the Ubuntu repository goes with. All in good time.

Create an SVN (Subversion) Server on Linux (Debian / Ubuntu – Redhat / CentOS)

I use SVN a lot – for my personal knowledgebase that I maintain for myself, for my development projects, server configurations, and for my documents (oddly enough). I think it’s a little more thorough than just using a piece of backup software in that there is revision control – and that is the most important thing to me with some of these documents and development bits. For some reason I prefer SVN over git – I think it’s a little more mature and has had bit more time to develop – no doubt that git is a good platform, I just tend to prefer SVN.

In any event, I’ve found softwares for Windows that will run an SVN server, but I think it requires a lot less work to set up on Linux and it runs far more efficiently. Anyway, I’ll detail about how to get that set up and running here.

Let’s start with prerequisites (as usual): You’ll need a box (either virtual or not) with as much space as you think you’ll need. I would suggest at least 8 gigs if it’s a VM – and depending on the server that you use (if you’re using a full out CentOS 6.3 install with GUI, it might be prudent to double that to 16GB) – just make sure it’s practical. It does not need to be a dedicated server – at least not for this instance – we will be using a relatively obscure port dedicated to SVN (3690).

And as usual, you’ll need some form of root.

Alright – here we go.

First you’ll need to install really only one thing – and that is subversion.

Debian / Ubuntu

$ sudo apt-get install subversion

Redhat / CentOS – as root:

# yum install subversion

Once subversion is installed, now we need to create the actual repositories. I generally tend to make a directory solely for this purpose – usually in /var.

# mkdir /var/svn

Once we’ve create the main directory that will house our repositories, we need to go ahead and create the actual repositories. To do that, we issue this command:

# cd /var/svn
# svnadmin create repo_name

After we’ve created the repository, we need to make it accessible. I’m usually not too concerned about this being ultra private – generally I make these local only – as in available to the LAN only – so normally I just will create a password for the repository.

All the configuration files are held within the repository now – so lets say you did this:

# svnadmin create /var/svn/foo

Within the /var/svn/blah folder, there are now going to be a folder we are concerned with, and that is a folder called “conf”.

In the conf folder (which should be at /var/svn/foo/conf). In that folder are two files we are concerned with – one is called “passwd” and the other is “svnserve.conf”.

Let’s first edit “passwd”. The “passwd” file looks like this:

### This file is an example password file for svnserve.
### Its format is similar to that of svnserve.conf. As shown in the
### example below it contains one section labelled [users].
### The name and password for each user follow, one account per line.
 
[users]
# harry = harryssecret
# sally = sallyssecret

As you can see, a username and a password commented out. If you want to create a username and password for yourself and for other users, add some in here.

[users]
foo = bar
luke = skywalker
frodo = baggins
# harry = harryssecret
# sally = sallyssecret

Now we have some users set up.

Next we need to tell the SVN server that we want it to authenticate users, we need to edit “svnserve.conf”.

There are a few lines in here that are concerned with:

One is “# anon access = read”.
Another is “# auth-access = write”.
Another is “# password-db = passwd”.

The first, anon access = read means that anyone can read the repository, regardless of authentication. Meaning anyone can “read” your repository. They can’t edit it, but they can read it. In some cases, this is a big no no. Especially if you have sensitive config files that contain database passwords. You can change it to this:

anon access = none

This will make it so that they have to have a password to even read the repository.

The second is “auth access”. This means authorized access. I tend to keep this on “write”. If you have a username and password, you are probably actively working on the project.

And last, uncomment “password-db = passwd”. This just means that it will use the “passwd” file we previously set up to authenticate users.

Alright – now the repository is set up, the users are up and running. Make sure port 3960 is open.

Last – we need to edit / create a few files to make a service out of this. On CentOS / Redhat – this is already done, but on Ubuntu and Debian, this is not done.

For Debian / Ubuntu, I wrote a little start up script that can be stuck in init.d.

Do this:

# sudo nano /etc/init.d/svnserve

And paste this in (changing your SVN root directory of course):

#!/bin/sh
#
# start/stop subversion daemon.
#
# Let's set some variables first
# If we want more than one root svn path, we can set it here
#
SVN_ROOT_PATH="/var/svn/foo"
SVN_USER="root"
SVNSERVE="/usr/bin/svnserve"
#
# Let's make sure SVN is actually installed
#
test -f $SVNSERVE || 'echo "svnserve not found at $SVNSERVE"; exit 0'
#
# If we want more than one root path, we can set it here
#
OPTIONS="-d -r $SVN_ROOT_PATH"
#OPTIONS="-d -r $SVN_ROOT_PATH2"
#
# Alright - let's start the daemon
#
case "$1" in

start)
        echo "Starting subversion daemon: svnserve."
        start-stop-daemon -S -o -q -u $SVN_USER -c $SVN_USER -v -x $SVNSERVE -- $OPTIONS

;;

stop) 
        echo "Stopping subversion daemon: svnserve."
        start-stop-daemon -K -q -o -x $SVNSERVE

;;

reload) 

;;

force-reload)
        $0 restart
        
;;


restart)
        $0 stop
        $0 start

;;

*)
	echo "Usage: /etc/init.d/svnserve {start|stop|reload|restart}"
	exit 1
	
;;

esac

exit

Save and close. Now the SVN daemon starts on boot.

If we want to connect to your SVN repo, there are some handy utilities – For Windows you can use TortoiseSVN or Eclipse, for Linux you can use subversion on the command line (I’ll write another post here in the near future) or Eclipse as well.

Set service to start on boot in Linux

In Linux, sometimes after updating, services will no longer start on boot – or their init level goes back to 0. This just means the service will no longer start at boot (or on login, or anything else other than if you manually ran service whatever start)

To fix this, we can just check the config level and then add it to runlevels 2, 3, 4, 5 – which means it will start on boot. 5 just gives it access to X, so if it’s an app with a GUI, it will HAVE to be on level 5 too.

If you want to read more about runlevels, read here.

$ chkconfig --list sshd

In CentOS it will usually come back with something like this:

sshd            0:off   1:off   2:on    3:on    4:on    5:on    6:off

So you see ssh is set to start on boot. What if it returns back something like this?

sshd            0:off   1:off   2:off    3:off    4:off    5:off    6:off

Well, then we need to fix it so it starts on boot. That can be done like this (as root):

$ chkconfig --level 2345 sshd on

That will restore it or put it at all those run levels – so if you reboot, it will start on boot.

How to install a .deb from the terminal

I tend to use the terminal more than most people I think. When I was very new at Linux, I hated the terminal – I thought it was really dumb to have such an advanced operating system, like Linux, use something little more than a command line. I’ve since revised my view on that and I think it would absolutely stupid not to have one and I spend far more time in a Linux terminal than I do with the GUI.

What’s nice about the terminal is that it doesn’t change much, unlike the GUIs. Anyway, there are a few ways to install .deb packages from the terminal. One that will resolve dependencies and one that won’t.

Dependencies, in Linux, are other packages required by the package you are trying to install. Similarly, in Windows, if you were trying to install a game, a dependency might be DirectX, or if you have an app written in .net, you’d need the .net framework.

In any event, the first way (and probably the more common way) is dpkg. To do this in the terminal you simply cd to where the directory is that houses your .deb file and run this:

$ sudo dpkg -i yourpackage.deb

The only problem with dpkg is that it doesn’t offer any dependency resolution. So if your package fails to install because of dependency issues, you’ll have to run this:

$ sudo apt-get -f install

Which will resolve any unmet dependencies (if those dependencies are in your repositories) as well as install the package you were trying to install. For kernel packages and other other packages that require no dependencies, this is the way to go.

For packages that require dependencies, I tend to use gdebi. It’s basically the same syntax, except like this:

$ sudo gdebi yourpackage.deb

Fairly straight forward. If your dependencies are not in the repository, you’ll have to manually start finding the packages and installing them as they need to be installed and it’s basically going to be a chain of installs.

Web Server “Essential Services” Monitoring Script

A while back I wrote a script that I set as a cron (every 5 minutes) to monitor my web server (LAMP with mod_proxy / BIND). I was having trouble, specifically with BIND, with few or no logs (I changed this, but they were so non-descript that I had no idea why it was dying). Thankfully an update came out for it via repo that fixed that issue, but not before I’d written a script to do it for me. So I present, the Web Monitoring Script.

This was written for Debian, but a few easy modifications to your variables will have it working on CentOS / RedHat / Fedora.

Prerequisites – You need root to add this as a cron. You also need to create this folder “/var/log/server_monitor/”.

It would also be a good idea to do set up log rotation on those logs.

To do that, follow this (and use whatever text editor you like, my server doesn’t have a GUI, so I tend to use text based tools):

# cd /etc/logrotate.d
nano server_monitor

And add this to that file and save.

/var/log/server_monitor/*.log {
	weekly
	missingok
	rotate 5
	compress
	notifempty
	create 640 root adm
	sharedscripts
	postrotate
	endscript
}

Now your logs will rotate weekly and will be compressed.

Now on to the actual script:

#!/bin/bash
#
# This is a server monitor that will run every 5 minutes to be sure all services are running, and if they are not, to start them.
#
# Let's set some variables quick
############################################################
RESTARTAPACHE="/etc/init.d/apache2 restart"
RESTARTBIND="/etc/init.d/bind9 restart"
RESTARTMYSQL="/etc/init.d/mysql restart"
RESTARTXINETD="/etc/init.d/xinetd restart"
RESTARTQMAIL="/etc/init.d/qmail restart"
############################################################
############################################ Path to pgrep
PGREP="/usr/bin/pgrep"
############################################################
############################################ Program names
APACHE2="apache2"
BIND9="named"
MYSQL="mysql"
XINETD="xinetd"
QMAIL="qmail"
############################################################
########################################## Set the log file
LOG="/var/log/server_monitor/server_monitor.log"
SUCCESS=" was down and has restarted successfully at $(date)"
###########################################################
############################################### Set date
set $(date)
#
# Apache
#
$PGREP $APACHE2
if
	[ $? -ne 0 ] #This shows that apache is not running since there are no pids
then
	$RESTARTAPACHE
	echo "$APACHE2 $SUCCESS" >> $LOG
else
	echo "$APACHE2 is running fine at $(date)" >> $LOG
fi;
#
# Bind
#
$PGREP $BIND9
if
	[ $? -ne 0 ]
then
	$RESTARTBIND
	echo "$BIND9 $SUCCESS" >> $LOG
else
	echo "$BIND9 is running fine at $(date)" >> $LOG
fi;
#
# MySQL
#
$PGREP $MYSQL
if
	[ $? -ne 0 ]
then
	$RESTARTMYSQL
	echo "$MYSQL $SUCCESS" >> $LOG
else
	echo "$MYSQL is running fine at $(date)" >> $LOG
fi;
#
# Xinetd
#
if
	[ $? -ne 0 ]
then
	$RESTARTXINETD
	echo "$XINETD $SUCCESS" >> $LOG
else
	echo "$XINETD is running fine at $(date)" >> $LOG
fi;
#
# Qmail
#
if
	[ $? -ne 0 ]
then
	$RESTARTQMAIL
	echo "$QMAIL $SUCCESS" >> $LOG
else
	echo "$QMAIL is running fine at $(date)" >> $LOG
fi;

Then if you want it to run every 5 or so minutes (I have mine on every 5 minutes), just add it to crontab. It’s an extremely light script and uses basically zero system resources.

That will keep your server running pretty smooth. If you want to get an email notification when this happens, it’s also fairly easy to set up. It would also be a good idea to check the logs once in a while and make sure you’re not having too many service issues.

Installing Eclipse to any Gnome Based Linux Distro

Problem – Eclipse is outdated in your repository, or else it’s not even in your repository.

Solution – install it from their site!

I have done this process in both RPM based and APT based distros and it works just fine. First thing you need to know though is that you need a JDK or JRE to run Eclipse. I personally have done it on CentOS (Stella), Fedora, Debian, Ubuntu (either Unity or Gnome), Mint (Mate, Cinnamon), etc… For some reason, I prefer Oracle’s JDK / JRE over OpenJDK / OpenJRE, but that is just a personal preference. I will write another article here in the future that tells how to install Oracles JDK. It tends to use less memory in my personal opinion, but that is pointless because I usually expand the memory that Eclipse can use.

I have never tried this with KDE, LXDE, or XFCE – so I’m not sure if it will work or not. I know it works on MATE, Unity, Cinnamon, and GNOME 2 and 3.

Here we go.

First you need to download the latest Eclipse (at the present it’s Juno) from http://www.eclipse.org. Choose Linux and choose your architecture (x86 or x64).

Next, open a terminal. This is where the fun starts. First you need to go to wherever your your downloads are. For most people this is in /home/user/Downloads or ~/Downloads

$ cd ~/Downloads

Next we need to untar Eclipse.

$ tar xvf eclipse*.tar.gz

This will create a folder in that folder called “eclipse”. Next we need to do this in this order. Become root first, or the rest will fail.

$ su
# mv eclipse /opt
chown -R root:root /opt/eclipse
chmod -R +r /opt/eclipse
touch /usr/bin/eclipse
chmod 755 /usr/bin/eclipse

Now we need edit /usr/bin/eclipse.

Use your favorite text editor  as super user (nano, vi, gedit, whatever):

# sudo gedit /usr/bin/eclipse

To punch this in to /usr/bin/eclipse

#!/bin/sh
export ECLIPSE_HOME="/opt/eclipse"
$ECLIPSE_HOME/eclipse $*

Next we need to make an application icon and launcher for it in the gnome menu. Use your favorite text editor to create /usr/share/applications/eclipse.desktop

# sudo gedit /usr/share/applications/eclipse.desktop

Add this to that file:

[Desktop Entry]
Encoding=UTF-8
Name=Eclipse
Comment=Eclipse IDE
Exec=/usr/bin/eclipse
Icon=/opt/eclipse/icon.xpm
Terminal=false
Type=Application
Categories=GNOME;Application;Development;
StartupNotify=true

And there you go. You can now launch Eclipse from the “Programming” section of Gnome 2 – if you are running Mate, Cinnamon, or Gnome 3, just search for Eclipse.

Issues:

I have had an issue in the past where no repositories will show up in Eclipse. You’ll have to manually add the latest repository – Name it Juno and add the link http://download.eclipse.org/releases/juno – then it will work for you.

I’ve also sometimes had an issue where the launcher we created at /usr/bin/eclipse doesn’t work. If that is your case, in eclipse.desktop, change the Exec= line to this:

Exec=/opt/eclipse/eclipse

And that should work for you.