Saturday, December 26, 2009

VPS.net server install

Notes from a recent installation of Ubuntu server on a UK2 cloud server.

signup
login as root@

passwd
sudo apt-get install joe
joe /etc/apt/sources.list
apt-get update
apt-get upgrade
adduser username
usermod -G admin username

joe /etc/ssh/sshd_config (permitrootlogin no)
/etc/init.d/ssh restart

logout

ssh-copy-id -i .ssh/id_rsa.pub username@host.domain.tld

ssh username@host

wget http://download1.parallels.com/Plesk/PPP9/Ubuntu8.04/parallels_installer_v3.4.1_build090204.18_os_Ubuntu_8.04_x86_64

mv parallels_installer.... /tmp/
chmod +x file
sudo ./file

follow the instructions

log into the Plesk frontend
admin:setup

setup master user details

-> updates
- -> prefs -> Check for updates upon administrator's login to control panel [Y]

-> Settings
- -> Spam Filter Settings -> Switch on server-wide greylisting spam protection [Y]

-> Control Panel Interface
- -> Interface Management

apt-get install munin-node
joe /etc/munin/munin-node.conf

#
# Example config-file for munin-node
#

log_level 4
log_file /var/log/munin/munin-node.log
port 4949
pid_file /var/run/munin/munin-node.pid
background 1
setseid 1

# Which port to bind to;
host *
user root
group root
setsid yes

# Regexps for files to ignore

ignore_file ~$
ignore_file \.bak$
ignore_file %$
ignore_file \.dpkg-(tmp|new|old|dist)$
ignore_file \.rpm(save|new)$

# Set this if the client doesn't report the correct hostname when
# telnetting to localhost, port 4949
#
#host_name localhost.localdomain
host_name [luffness.konsulting.ltd.uk]

# A list of addresses that are allowed to connect. This must be a
# regular expression, due to brain damage in Net::Server, which
# doesn't understand CIDR-style network notation. You may repeat
# the allow line as many times as you'd like

allow ^127\.0\.0\.1$
allow ^80\.2\.73\.137$

****************************
[monitoring server]
joe /etc/munin/munin.conf

[craigielaw.konsulting.ltd.uk]
address 83.170.83.182
use_node_name yes

***************************

** install mysqltuner
wget mysqltuner.pl
chmod +x mysqltuner.pl
sudo mv mysqltuner.pl /usr/local/bin/mysqltuner

** alter crontab
** allows a weekly email to test for upgrade and mysql tuning options
sudo crontab -e
add:
MAILTO=server@klever.co.uk
17 3 * * 3 apt-get update; apt-get upgrade -sy
17 4 * * 5 /usr/local/bin/mysqltuner

Monday, September 28, 2009

Ubuntu fonts

Get a raft of fonts for Ubuntu with a simple apt-get
sudo apt-get install ttf-sil-gentium ttf-dustin ttf-georgewilliams ttf-sjfonts sun-java6-fonts ttf-larabie-deco ttf-larabie-straight ttf-larabie-uncommon
Any, if Microsoft fonts are required:
sudo apt-get install msttcorefonts
Works a treat.. and you could do worse than gnome-specimen for a font previewer.

Monday, September 14, 2009

Load alert

I've been having an issue with a server whose load sporadically runs high. While trying to work out what the problem was, I needed a way to know when the load peaked.

I modified a simple script to allow me to do just that and then ran it from cron. Only problem is that if it detects a high load, an email is sent each time the cron is run (maybe every 5 minutes!)
!/bin/bash
avg=`uptime | awk '{print $8" " $9 " "$10 $11 $12 }' | tr -s , " "`
cur=`uptime | awk '{print $10}' | tr -d , | cut -d. -f1`
str="============================="
info="Curent $avg"
if [ $cur -ge 1 ]; then
info1="Server load is high presently"
touch /tmp/tmp.00
echo -e "$str\n$info\n$info1\n$str\n" >> /tmp/tmp.00
ps aux | head -1 >> /tmp/tmp.00
ps aux | sort -rn +2 | head -10 >> /tmp/tmp.00;
mail -s "Alert: Load Average for `hostname` on `date` " jeremy@yourdomainnamehere.com < /tmp/tmp.00;
rm -f /tmp/tmp.00
else
#echo -e "$str\n$info\n$str"
fi
Cron might look something like this:
*/5 * * * * /usr/local/bin/loadaverage

Sunday, August 30, 2009

Cloud server Plesk Ubuntu install

Notes from a recent installation of Ubuntu server on a UK2 cloud server.

signup
login as root@

passwd
sudo apt-get install joe
joe /etc/apt/sources.list
apt-get update
apt-get upgrade
adduser username
usermod -G admin username

joe /etc/ssh/sshd_config (permitrootlogin no)
/etc/init.d/ssh restart

logout

ssh-copy-id -i .ssh/id_rsa.pub username@host.domain.tld

ssh username@host

wget http://download1.parallels.com/Plesk/PPP9/Ubuntu8.04/parallels_installer_v3.4.1_build090204.18_os_Ubuntu_8.04_x86_64

chmod +x file
sudo ./file

follow instructions

make sure that postfix is installed as the MTA

sudo apt-get install postgrey
netstat -lpn | grep 60000
joe /etc/postfix/main.cf (add check_policy_service inet:127.0.0.1:60000,) before reject_unauth_destination
/etc/init.d/postfix restart
tail -f /var/log/mail.info

apt-get install munin-node
joe /etc/munin/munin-node.conf

#
# Example config-file for munin-node
#

log_level 4
log_file /var/log/munin/munin-node.log
port 4949
pid_file /var/run/munin/munin-node.pid
background 1
setseid 1

# Which port to bind to;
host *
user root
group root
setsid yes

# Regexps for files to ignore

ignore_file ~$
ignore_file \.bak$
ignore_file %$
ignore_file \.dpkg-(tmp|new|old|dist)$
ignore_file \.rpm(save|new)$

# Set this if the client doesn't report the correct hostname when
# telnetting to localhost, port 4949
#
#host_name localhost.localdomain
host_name [luffness.konsulting.ltd.uk]

# A list of addresses that are allowed to connect. This must be a
# regular expression, due to brain damage in Net::Server, which
# doesn't understand CIDR-style network notation. You may repeat
# the allow line as many times as you'd like

allow ^127\.0\.0\.1$
allow ^80\.2\.73\.137$

[monitoring server]
joe /etc/munin/munin.conf

[craigielaw.konsulting.ltd.uk]
address 83.170.83.182
use_node_name yes

http://www.debuntu.org/postfix-and-postgrey-a-proactive-approach-to-spam-filtering
https://help.ubuntu.com/community/PostfixAmavisNew

** spamassassin
sudo apt-get install spamassassin spamc

** install backports
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install -t hardy-backports spamassassin

** install mysqltuner
wget http://mysqltuner.com/mysqltuner.pl.gz
gzip -d mysqltuner.pl.gz
chmod +x mysqltuner.pl
sudo mv mysqltuner.pl /usr/local/bin/mysqltuner

** alter crontab
sudo crontab -e
add:
MAILTO=server@klever.co.uk
17 3 * * 3 apt-get update; apt-get upgrade -sy
17 4 * * 5 /usr/local/bin/mysqltuner


other helpful software
sudo apt-get install ifstat rcconf

tbackup
ssh-keygen -rsa
ssh-copy-id -i......

Monday, August 17, 2009

Fonts in Ubuntu

I had been reading some blog posts about free fonts in Ubuntu:
  • http://embraceubuntu.com/2007/05/21/300-easily-installed-free-fonts-for-ubuntu/
  • http://crunchbang.org/archives/2008/06/14/aenigma-fonts-for-ubuntu/
In the latter, it talks about installing a PPA to get the package. However, it turns out that the package is already in the Karmic Universe repository and this is all you need:
sudo apt-get install ttf-aenigma

Friday, August 14, 2009

Upgrading iPhone firmware in a VirtualBox

As I blogged previously, I've setup a Virtualbox inside Ubuntu Karmic and installed an old copy of WindowsXP and then iTunes.

I needed to upgrade to the latest version of the firmware and after some scouting around, it appeared possible back in v2 of Virtualbox, so I was hoping that v3 would be fine.

At first, it didn't work.

I couldn't work out why, but not long after the upgrade had started, the "preparing" message just kept cycling until a "can't do it" error message popped up. Restart the VM and tried again... nothing.

Then, as a matter of last resort, I noticed that just before the "preparing" message came up, the USB icon in the bottom left didn't flash. I right clicked and noticed that the iPhone had restarted and therefore wasn't checked in the list of USB.

So, if you recheck it each time the iPhone switches mode or restarts, everything works like a charm

Thursday, August 13, 2009

Running WindowsXP on VirtualBox on Ubuntu Karmic

Recently installed the latest alpha of Karmic and thought I'd give it a shot with VirtualBox and Windows XP.

The most important thing to do right now is realise the there are two version of VirtualBox:
  • virtualbox-ose (open source edition) - no USB support
  • virtualbox-puel - the one with USB support
The OSE edition is in the repositaries:
sudo-s
apt-get install virtualbox-ose
  • Then run it: Applications -> Accessories -> VirtualBox OSE
The PUEL version needs downloading and installing using the .deb package maintainer or:
  • add the following repro:
    deb http://download.virtualbox.org/virtualbox/debian jaunty non-free
  • then add the key and install it
wget -q http://download.virtualbox.org/virtualbox/debian/sun_vbox.asc -O- | sudo apt-key add -
sudo apt-get install virtualbox-3
  • You should find it under Applications -> System Tools
THE REST

Create a new virtual machine and follow the wizard. I chose to use the following settings:
  • windows
  • XP
  • 512 MB RAM
  • Dynamic HDD (max 50GB)
BEWARE: the dynamic HDD maximum cannot be increaed after this point. If you use dynamic, the file in /home/username/.VirtualBox/HardDrives will start out small and grow to the maximum file size stated here.

Once this is done, double click on the newly created VM and follow the "First Run Wizard". Pop the XP installation CD in the drive and choose that as the media to use for installation.

The Windows installation proceeds: the only problem that I had was when trying to Eject the disc (the XP disc is an upgrade disc and I needed to put an old NT disc in). At first, the Eject just wouldn't happen - I joked that Windows clearly didn't want to leave the machine. After using the right click -> Eject option from the desktop a couple of times, it relented.

In fact, the whole process was far less stressful than it used to be installing it on a fresh box - the network worked first time and I didn't have to wait for the "34 minutes" while watching a blue screen. Instead, I could fire up firefox and do some surfin'.

When the VM needs keyboard or mouse action, life is very simple:
  • keyboard: simply bring the VM window to focus
  • mouse: click on the VM window or use the "capture key" which, by default is the Right Ctrl key
And, that was it.


Just needed to install all the updates... trivial really, keep re-visiting the Updates page via the control panel, and install SP1, SP2, SP3 and a couple of other pieces of software and restarting the VM about 7 times!

NETWORK FOLDERS

Getting networked folders sorted is pretty simple too.

  • ensure that the VM is fired up
  • install the "guest additions": from the VirtualBox menu: Devices -> Install Guest Additions
  • follow the prompts from within the VM
Now, share the Host's folders:
  • from the live VM window, choose Devices -> Shared Folders
  • within the popup window, use the add button (top right) and choose the folder you want to share
  • I chose to make the sharing permanent too
That's one side done... now for the Windows glue:
  • within Windows, choose "Start -> Run"
  • type "net use x: \\vboxsvr\NameOfYourFolderHere"
Have a look in MyComputer, and you should see a shiny networked drive. And, changes either side of the glue persist in realtime.

USB and iPHONE

Of course, this is only going to work if you've downloaded the PUEL version (see above).

  • add yourself to the vboxusers group
  • add this line to /etc/fstab, replacing XXX for the groupid of vboxusers: NB. most posts talk about /proc/bus/usb, but this didn't exist on my Karmic install, so I changed it to /dev/bus/usb
    none /dev/bus/usb usbfs devgid=XXX,devmode=664 0 0
  • restart your machine: some people say restart some services, some say logout...
Once the machine has restarted, double check that the USB controller is working on the VM: for some reason mine wasn't.
  • goto Control Panel -> System -> Hardware -> Device Manager
  • check that the USB controller is installed correctly and there aren't any other drivers missing
  • if there are problems, double click and choose to search for driver from the web
Now, USB should be working:
  • check the iPhone is recognised by plugging it in and seeing if it is listed under the USB menu at the bottom or within the Devices menu
  • click the checkbox next to them to ensure that Windows connects to them
  • install iTunes
  • done!

Monday, June 01, 2009

Zotero style

I’ve just been writing a zotero style for radiopaedia.org where I’m an editor. I didn’t have a seamless start to the process and found it pretty difficult to work out exactly what I should be writing, but after taking one of the other styles as a starting point and mashing it about, I finally got to our working copy.

The styles are writtin in CSL and have to validate against the RELAX_NG XML schema. Long story short, use this online tool:

  • validator.nu
  • encoding and parser can be left of auto
  • schemas: http://xbiblio.svn.sourceforge.net/viewvc/xbiblio/csl/schema/trunk/csl.rnc
  • check “Be lax about HTTP Content-Type”

And, after uploading and hitting validate you should be on your way.

As for getting the new style into firefox, just File->Open File from within Firefox.

And then, once happy, the task of getting it up to zotero rears it’s head. All the csl files are held in an SVN repository. So, we need to checkout the csl repro, We also need to have a zotero trac account to be able to submit our style.

Once the repro is checked out, we can add our style with an “svn add file.csl” and “svn commit”.

A couple of helpful pages: