Setup your own deb repository

It is difficult to setup a Debian repository that is signed and can handle multiple versions of any single package. I went through many different packages and tutorials in how to setup my own Debian repository and it was a pain to find a method that works. My two requirements might be specific to my needs but they give the user the ability to do these two things.

The signed part allows automated scripts to upgrade a package as it allows the following.

sudo apt-get -y install <package>

The ability to handle multiple versions of the same package would allow the user to install which ever version of the package with the following command example

sudo apt-get -y install <package>=<version>

Generate a gpg key

We need a gpg key to sign our packages and repository. So let’s generate one before setting up freight.

gpg –gen-key

Select option 4 RSA (sign only)

Fill out all the information that it asks.

Note: Be sure to add an email. It will be needed to configure freight.

One thing that will happen most likely is that there is not enough entropy to generate the key and it waits for entropy. I found a good way to generate some entropy is to run stress. Open another terminal to install and run stress while leaving the gen key running.

sudo apt-get install stress

stress –hdd 8 –io 8

If you want to watch the available entropy get generated, open another terminal and watch with this command

watch cat /proc/sys/kernel/random/entropy_avail

Installing Freight

The package that I found to handle both my requirements was freight. The instructions are there, but I will document what I did just to be complete.

I installed via apt-get and so I needed to add the third party source list before installing

echo “deb http://packages.rcrowley.org $(lsb_release -sc) main” | sudo tee /etc/apt/sources.list.d/rcrowley.list

sudo wget -O /etc/apt/trusted.gpg.d/rcrowley.gpg http://packages.rcrowley.org/keyring.gpg

sudo apt-get update

sudo apt-get -y install freight

Configuring Freight

Copy the example conf

sudo cp /etc/freight.conf.example /etc/freight.conf

Edit the freight.conf and add

GPG=”emailfromgpgkey@mydomain.com”

Add deb packages

Take a deb file you already created and added to the repository. The apt/squeeze, etc arguments are the different distros where the deb should be published.

freight add foobar_1.2.3-1_all.deb apt/squeeze apt/lucid apt/natty

Build the cache

freight cache

Setting up Nginx

Now we need to serve out the repository over http. You can use any web server to do this. I chose Nginx and here is the setup procedure.

sudo apt-get install nginx

Setup hosting file

cd /etc/nginx/sites-available

sudo vi mydomain.com

Put something like this into the site configuration file

server {
listen 80;
server_name mydomain.com;
access_log /var/log/nginx/mydoamin.com.access.log;
error_log /var/log/nginx/mydomain.com.error.log;

location / {
alias /var/cache/freight/;
}
}

Enable the new site

cd /etc/nginx/sites-enabled

sudo ln -s /etc/nginx/sites-available/mydomain.com mydomain.com

Restart Nginx

sudo service nginx restart

Consume packages

Now to install the packages from your new repository on a Debian machine, add the source list and the key

echo “deb http://mydomain.com $(lsb_release -sc) main” | sudo tee /etc/apt/sources.list.d/mydomain.list

sudo wget -O /etc/apt/trusted.gpg.d/mydomain.gpg http://mydomain.com/keyring.gpg

Now you can do the normal apt-get procedure to install a package

sudo apt-get update
sudo apt-get -y install foobar

Getting Ionic framework running on Ubuntu

Very frustrating when it appears that Ionic setup is as simple as http://ionicframework.com/getting-started/ to get a helloworld running. But I received all kinds of errors when following those simple instructions. Primarily, there were Cordova dependencies that were missing and are not installed if you only follow Ionic instructions.

So here they are. After installing cordova and ionic

sudo npm install -g cordova

sudo npm install -g ionic

Install ADT

http://developer.android.com/sdk/index.html#download

Unzip to somewhere that makes sense for you on your home dir

Add paths

edit your .bashrc and add this to the bottom

export PATH=$PATH:/[path to adt]/adt-bundle/sdk/platform-tools:/[path to adt]/adt-bundle/sdk/tools

Save your .bashrc then run

source ~/.bashrc

Then install ant

sudo apt-get install ant

Then create a AVD

android create avd -n <name> -t <targetID>

you can list targets to see what you have available

android list targets

Now that everything else is installed and an AVD is created, you can continue with the Ionic instructions.

$ cd myApp
$ ionic platform android
$ ionic emulate android
$ ionic run android <-- still getting an error on this one

 


	

Google Chrome Voice Search Extension Memory Leak

Screenshot from 2013-12-11 16:57:26This was observed on Ubuntu 12.04 where just opening Chrome without going to any pages would see memory start to get eaten up. The cpu usage would go way up as well. The culprit was the Google Voice Search Hotword Extension. If you go to upper right three horizontal bars -> Tools -> Extensions and disable that extension, everything is solved.

Auto start Sphinx searchd after reboot on Linux

By default, after you install and configure Sphinx, you will find that once your OS restarts, search will not be working. That is because searchd is not setup to auto start. The following will solve that problem.

Create file /etc/init.d/searchd.
sudo vi /etc/init.d/searchd

Copy the following into searchd.
#!/bin/bash

case “${1:-”}” in
‘start’)
/usr/local/bin/searchd
;;
‘stop’)
/usr/local/bin/searchd –stop
;;
‘restart’)
/usr/local/bin/searchd –stop && /usr/local/bin/searchd
;;
*)
echo “Usage: $SELF start|stop|restart”
exit 1
;;
esac

Add execute to the file
sudo chmod -x /etc/init.d/searchd

Register with auto start
sudo update-rc.d searchd defaults

Replacing OpenGeo Suites on Windows with GeoServer on Linux

After our initial installation of OpenGeo Suites for WMS service on Windows, we encountered some stability issues that could not be resolved. We could have hired some high priced consultants to debug the issue but we opted for a lighter weight infrastructure.

Our initial system specs:

  • Windows Server 2008
  • 4GB ram
  • Quad core
  • Open Geo Suites running as Windows application

Our slim and fast system specs:

  • Ubuntu 10.04
  • 512MB ram
  • Quad core
  • GeoServer running as java process

So far so good. All layers are loading super fast. We will see how the stability issue is resolved. At least we are using a lot few resources now which makes scaling out to a cluster of GeoServers much more affordable.

Running stored procedures on MSSQL via any language on Linux

If you need to run store procedures on Microsoft SQL Server on perl, php, ruby, etc., you need to configure /etc/freetds/freetds.conf with the server connection information. Specifically, specify the tds version to be 8.0. Something like the following.

/etc/freetds/freetds.conf

[Server80]
host = domain.com
port = 1433
tds version = 8.0

Connection to the server via php would look like this.

$link = mssql_connect("Server80", "user", "pass");

Scaling down from MS to open source

We just moved a service that was running on the Microsoft stack (Windows Server 2008, .NET, MSSql Server, IIS) to an open source stack (Ubuntu Server, php, Codeigniter framework, apache2, postgres).

We now run the service on a cloud server with dual cpu and 256MB ram (Yes, that’s megabytes).

The old server ran on dual core with 2GB of ram.

A four letter word can ruin your day

halt + Amazon EC2 + Instance Store = A bad day

I did a stupid thing while on vacation. Decided to clone an EC2 server and executed halt from commandline without checking to see if the server was using Instance Store. Whoops, Amazon showed the server as terminating…terminated… ahhhhh.

After having to rebuild the server while on vacation, I have learned a valuable lesson.

sendmail[2525]: My unqualified host name (servername) unknown

If you see these messages in your syslog, your sendmail is not configured correctly with the domain name. If you are sending from a fully qualified domain, add it to the local-host-names file. In Ubuntu, it would be /etc/mail/local-host-names. Make sure it reads something like this.

localhost
[domain.com]
[server name]

Now in the /etc/hosts, make sure it reads the following.

127.0.0.1 [domain.com] [server name] localhost

Then

sudo /etc/init.d/sendmail restart

and the error should not continue filling the syslog.

Changing Mysql data directory require change to AppArmor

After a bit of googling and hair-pulling, I realized that if I just changed the datadir directive in my.cnf will cause mysql start to fail on Ubuntu. The other thing is to add permissions to apparmor for mysql to access the new data directories.

Steps
1. sudo vi /etc/apparmor.d/usr.sbin.mysqld
2. Add
/newdir/ r,
/newdir/** rwk,
3. sudo /etc/init.d/apparmor restart
4. sudo /etc/init.d/mysql restart

If that still does not work, check the nix permissions to be sure mysql is owner and group for the new directory recursively.
chown -R mysql:mysql “new datadir path”