Monday, April 19, 2010

converting flv's to mpeg's

The following takes an flv in folder /music and outputs it as an mpg in the home folder

markp@server:~$ ffmpeg -i /music/faithworks.flv -sameq -s 480x270 faithworks.mpg

Monday, March 29, 2010

Merging pdf's

Ghostscript does this simply:

gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=crossing_grant_application_v1.pdf cover.pdf doc1.pdf appa.pdf appb.pdf appc.pdf appe.pdf

Monday, February 22, 2010

webgen

Webgen creates websites with linked menus, common stylesheets and template and page files which work as site wide models. It does this automatically using perl scripting.

create a new site:
cd into directory that will hold new site.
webgen create -t default -s andreas08 mysite
on a default installation you choose between three templates -t and several styles applied to those templates -s
when created cd into your new website top level folder (eg mysite) and run command 'webgen' to create the static html content. The html created resides in a subfolder called 'output'. Run same command each time any changes are made. Content of the output folder is what needs ftp'ing to your webserver. Seeemples.

Thursday, February 04, 2010

mdadm on existing setup

These notes relate to my ubuntu 9.10 setup. When I first setup up I had two sata drives (sda1 and sdb1) and an IDE drive (sdc1). sdb1 was one of an intended pair of 750gb drives that I wanted to set up as RAID1 using mdadm for /home, however the 2nd of that pair went back to samsung and was replaced under warranty at the time of setting up the 9.10 machine. The challenge here was could I add the 2nd 750gb drive, create the RAID and transfer what was on original /home as a regular ext3, without having to totally start over. Short answer - yes!

First let's see what's happening with the drives:
root@server:~# fdisk -l

The new drive is placed as /dev/sdb. The previous sdb1 (/home) gets renamed to /dev/dsc1 and the IDE goes to sdd1. As my fstab is using UUID's this presents no problem. To prepare the new drive
root@server:~# fdisk /dev/sdb
This brings up the fdisk command prompt: use n for new partition; partition type is 'fd' for linux raid.

To manage what I want to do I need to setup an mdadm raid1 array without the 2nd drive in place:
root@server:~# mdadm --create --force --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sdb1 missing
Result:
mdadm: size set to 732571904K
mdadm: array /dev/md0 started.


OK, lets check what's happening with mdadm:
root@server:~# cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md0 : active raid1 sdb1[0]
732571904 blocks [2/1] [U_]

unused devices: none


OK, format the new array drive with:
root@server:~# mkfs.ext3 /dev/md0

create info for the mdadm config file with:
root@server:~# mdadm --detail --scan --verbose > /etc/mdadm/mdadm.conf

Mount the new array (/dev/md0) as /whatever
root@server:~# mkdir /whatever
root@server:~# mount /dev/md0 /whatever


Copy contents of /home to /whatever.
-a is archive, preserves all attributes; -v verbose, let's you know what's happening:
root@server:~# cp -a -v /home/* /whatever

unmount the old /home:
root@server:~# umount /home

OK so now use fdisk again change the partition type of sdc1 to fd as above,
then add sdc1 to the array with
root@server:~# mdadm --add /dev/md0 /dev/sdc1

Next check that the new array can mount manually:
root@server:~# mount /dev/md0 as /whatever
OK!

Problem: after a reboot there doesn't appear to be a /dev/md0 Where's it gone?! Don't worry it's become /dev/md_d0 instead. This is the new naming convention which mdadm uses on newer linux kernels that can make md devices partitionable (see mdadm MAN on this).

Next issue is that /dev/md_d0 will need mounting as /home using fstab. Using the UUID that the mdadm --scan command uses appears not to be the right one. Using the command blkid (Block ID) gives another UUID for the RAID partition itself. Use that in fstab.

STUCK AT PRESENT
Can't get the raid drive to mount using fstab:
First of all simply tried hashing out the old /home and using the new raid drive, the UUID for the raid device is the one that blkid is giving me. like this:
# orig /home was on /dev/sdb1 during installation
#UUID=e2c6ff62-a576-4182-b5e0-82c9fea9601c /home ext2 relatime $

# raid /home on /dev/md_d0 created during raid setup
UUID=9c1a494c-0e38-4f3b-b1f1-cdf66f4e7c0a /home ext3 relatime $


No go, so I also try this:
# orig /home was on /dev/sdb1 during installation
#UUID=e2c6ff62-a576-4182-b5e0-82c9fea9601c /home ext2 relatime $

# raid /home on /dev/md_d0 created during raid setup
/dev/md_d0 /home ext3 relatime 0 $


Still no go; boot halts saying that /home cannot be mounted.
OK that could because I can't simply switch the /home directory without doing some other things perhaps. So let's just try and get the raid to mount as /whatever:
# raid /home on /dev/md_d0 created during raid setup
UUID=9c1a494c-0e38-4f3b-b1f1-cdf66f4e7c0a /whatever ext3 relatime $

This results in /whatever being empty?
Huh?

this works:
markp@server:~$ sudo mount /dev/md_d0 /whatever

So does this:
markp@server:~$ sudo mount UUID="9c1a494c-0e38-4f3b-b1f1-cdf66f4e7c0a" /whatever

OK So John thinks there's something squiffy with my fstab. knocking the options off of it and doing a mount -a indicates that might be right.

However rebooting fstab doesn't mount /whatever, but after boot 'mount -a' does add it in. This makes me think the raid is not ready to be mounted at initial boot time perhaps?

Unstuck - ie got it working!

When I finally freed up the second 750gb drive from it's /home duties I tried to add it to the /dev/md_d0 raid drive. No joy. Lot's of attempts, including changing the format of the drives to ext4.

Got it fixed by simply running the create again, with force. Done away with all the faffy partition stuff by adding --auto=md This creates an (old fashioned?) regular /dev/md0
Complains that sdb1 and sdc1 are part of a raid and had a ext2 and ext3 partition (I'd definately tried to change them from that??). Anyway this time the new ext4 /dev/md0 is working OK.

root@server:~# mdadm --create --force --verbose --auto=md /dev/md0 --level=1 --raid-devices=2 /dev/sdb1 /dev/sdc1

Now to copy /home to it then mount it as new /home. Then see if the new install (10.04) will see the raid from install (using server version)

Tuesday, December 29, 2009

myth in small window

with thanks to spodesabode for this

MythTV is wonderful, and it's backend/frontend separation is ideal for my uses - as it means I can watch TV in my bedroom, where I don't have an aerial. However, it is quite obviously designed for people who use it as a complete Media Center, and not people who run it on their machine. I found the best thing to do is have a secondary launch icon, which loads MythTV with a different resolution.
The following instructions are for Ubuntu, but I did something very similar in Fedora.
First, copy the mythtv.desktop file.
sudo cp /usr/share/applications/mythtv.desktop /usr/share/applications/mythtvsmall.desktop
Then we'll edit this file with sudo nano /usr/share/applications/mythtvsmall.desktop
Edit the file:
"Name=" portion to read "MythTV Frontend (Small)"
"Exec=" portion to read "mythfrontend -geometry 640x400".
640x400 is a nice size for my twin 1680x1050 screens, and keeps the widescreen aspect ratio. Moving the window around is as simple as holding down ALT and click-dragging on the window.
http://www.spodesabode.com/discussion/54/mythtv-in-a-window/
to make the backend setup small windowed:
sudo cp /usr/share/applications/mythtv-setup.desktop /usr/share/applications/mythtv-setupsmall.desktop
edit the file:
sudo nano /usr/share/applications/mythtv-setupsmall.desktop
"Name=" portion to read "MythTV Backend Setup (Small)",
"Exec=" portion to read "mythtv-setup -geometry 640x400"

Saturday, November 21, 2009

Mail merge labels in OpenOffice

Christmas card time again and my usual annual reminder of how tricky this seems to be.

1. There are different ways of creating a data source for OoWriter:
From Egroupware you can use a CSV export of a particular category search. Best to turn this into a MS xls first. Important that you choose 'semi-colon' as delimiter type, NOT comma (commas are used within the fields in egw), when opening up the csv and saving as your xls (strngely couldn't get Base to work with an Oo spreasheet?). In ubuntu it seems tricky to simply to register the xls as a data source using the wizard, but using the spreadsheet as the data for an Oo Base db. still registers it as a viewable datasource in Writer when hitting F4
Egw can also be hooked into as a data source live. to do that...
Everything needed in here: /home/markp/printjobs/Label Runs/christmas The xls feeds the odb, odb is the registered datasource for Oo, the odt template is setup for the 8x3s.

3. to insert such a data source into a sheet full of labels: chose file:new: labels

4. insert the fields when the data source has been selected. Don't be tempted to drag and drop the fields using the F4 view once the thing is opened! (screws the db somehow and field mismatch)

5. To suppress blank fields (per line), view printing characters and change the carriage returns at end of lines for P (paragraphs). Then, with the cursor at the end of the relevant line: (insert:fields:other:functions:hidden paragraph in the condition field the field is referred to, including it's path, a ! means 'NOT'. eg ![addresses1.Sheet1.City (Private)]

5b. To suppress spaces (eg when no < title > field) follow instructions here

6. To see the finished result got to print (huh?) and to create the output as a file choose such. This allows you to save, but not edit that doc. Don't choose 'update all links' that simply inserts that contents of the first (master) label to all the others.

7. To over come the problem of the salutation on the address label being correct for (eg) a family. whilst using an address record that belongs to s ingle person (eg a Church member), I have used the following fields which cover all situations: on first line of address only use prefix, middlename, surname and suffix fields, not firstname, this allows a name to be created thus: prefix MR middlename G & MRS C surname CARRINGTON suffix & FAMILY. conditional text entries required for prefix, middlename fields in case they are blank (suppreses unnecesary spaces). I have also decided to apply a country to all addresses, use conditional text so that only overseas COUNTRIES print, as here. Only use personal (home) addresses, if business address is the only one, copy it to the personal as well.

8. If you need to adjust the layout slightly when you've finished with your sheet here

egroupware add/delete categories error

default 1.6 installation has a bug in file:

usr/share/egroupware/addressbook/inc/class.addressbook_ui.inc.php

not categories are presented when choosing the option to add/delete cats. to multiple contacts

latest version of that file can be found here:

http://www.egroupware.org/viewvc/egroupware/branches/1.6/addressbook/inc/class.addressbook_ui.inc.php?view=log&r1=28226&pathrev=28226

revision 28226 from branches was OK for me Nov 09