Latest Publications

Updating the FreeBSD ports collection

beastie There has been different ways to update the FreeBSD ports collection over time.

However, this is the recommended, simple, network friendly and firewall friendly procedure for updating the FreeBSD ports collection using the portsnap utility, which updates via internet from a FreeBSD mirror.

This procedure assumes, that the ports collection has been installed prior to updating, such as a part of the system installation.

portsnap fetch && portsnap extract

This ports collection is now up to date.

Print

Preparing internal and external storage for FreeBSD

Internal and external storage has to be prepared and formatted for the operating system FreeBSD to be able to use it. FreeBSD supports different ways to prepare storage. However, this is the recommended procedure for preparing and formatting internal or external storage for use with FreeBSD in a way, that is supported and compatible.

Create a directory, that can be used as a mount point for the storage, and run the system maintenance tool. Use a short name without special characters, such as underscore.

mkdir /mnt/usbs
sysinstall

Use arrow keys to highlight Index. Press Enter. Use arrow keys to highlight Partition. Press Enter. Use arrow keys to highlight the device node for the storage. Press Space. Use arrow keys to hightlight a used slice. Press D. Repeat this until only one unused slice remains. Press A. Press W. A dialog about an existing system appears. Press Y. A dialog about a boot manager appears. Press Enter. A dialog about succesful write appears. Press Enter. Press Q. Press C.

Use arrow keys to hightlight Label. Press Enter. Press C. Press Enter. A dialog about file system appears. Confirm, that FS is highlighted. Press Enter. A dialog about mount point appears. Enter the mount point. Press Enter. Press W. A dialog about existing system appears. Press Y. Press C. Press C.

Press X.

Test, that you can mount and unmount the storage. In our example, the device node is da0s1d, which is to be read as partition d on slice 1 on external storage device da0.

umount /mnt/usbs
ls -ld /dev/da*
mount /dev/da0s1d /mnt/usbs

Print

Open Source Days Community Day 2009

On Saturday, October 24th, Open Source Days will host the Community Day 2009 conference at Symbion in Copenhagen, which will include a number of simultanious talks on open source subjects.

The program has been published on the website.

The price is 145 DKK per guest and includes T-shirt and lunch.

Print

Configuring DHCP on a FreeBSD DNS server

The dynamic host configuration protocol (DHCP) describes the means by which a system can connect to a network and obtain the necessary information for communication upon that network. The manual is available in the FreeBSD manual pages.

When the client is executed, it begins broadcasting requests for configuration information. By default, these requests are on UDP port 68. The server replies on UDP 67, giving the client an IP address and other relevant network information, such as netmask, router and DNS servers. This information comes in the form of a lease and is only valid for a certain amount of time. In this manner, stale IP addresses can be reclaimed.

It is important to know, that some internet service providers (ISPs) only allow traffic to customers, that use DHCP. Fullrate is an example of those. In such cases, the line will suddently appear dead even though, it has been configured with static network information.

Now, in our example, we want to configure the internet network interface on a FreeBSD 7.2 DNS server by using the DHCP client. What we need to take care of is the DNS configuration in resolv.conf and our hostname. The client will by default overwrite this. In stead of this, we want our local DNS to be prepended, the DNS servers of the ISP to be appended, our search domain to be superseded and our hostname to be superseded.

First, we make sure, that rc.conf is configured for DHCP. In our example, the interface is called bge0.

vi /etc/rc.conf
ifconfig_bge0="DHCP"

Then, we configure the client, where X and Y are other DNS servers of our own, that we want to use.

vi /etc/dhclient.conf

interface "bge0"
{
prepend domain-name-servers 127.0.0.1, X, Y;
supersede host-name "star.foobar.com";

supersede domain-name "foobar.com;
send dhcp-lease-time 9000;
}

Make sure, that these declarations end with a semicolon, and, that notation quotes are used where expected. Consult the manual. Forgetting this will result in silent unexpected behavior, such as overwriting our DNS configuration.

That’s it. We do a reboot test and confirm, that things look right.

ifconfig bge0
cat /etc/resolv.conf
hostname

Print

Calculating CIDR notation from IP address netmask

If you need to calculate the classless inter domain routing notation (CIDR) from a given IP address netmask or IP address range, there are many free online calculators available, which will do the job.

CIDR simply replaces the subnet mask, such as 255.255.240.0, which expressed as CIDR notation is replaced with /20.

We recommend the calculator at IP Address Location IP Subnet Calculator.

Print

Combining raw movie clips

There are lots of open source software, that can be used to combine a series of raw movie clips from a digital camera into a single compressed movie clip. A simple solution is to use the command line movie encoder mencoder.

In this example, we want to combine three raw movie clips, 1.avi, 2.avi and 3.avi, into a single compressed movie clip x.avi. Note, that the audio track is copied, which means, that the audio format and sample rates must be the same for all movie clips.

mencoder -forceidx -oac copy -ovc xvid -xvidencopts bitrate=3000 -o x.avi 1.avi 2.avi 3.avi

In this example, clip 1 will be half speed (slow), clip 2 will be double speed (fast) and clip 3 will be normal speed. Because of the different speeds, audio must be encoded as well. Because of the half speed for part 1, the sample rate for the audio is reduced. In this case, the original sample rate of 44,1 kHz per channel is reduced by a half to 22,05 kHz per channel.

mencoder -forceidx -oac mp3lame -srate 22050 -ovc xvid -xvidencopts bitrate=3000 -o x.avi 1.avi -speed .5 2.avi -speed 2 3.avi

In this example, watermarking is prepared by using the subtitle format SubRip and then hardcoded into the encoded movie.

vi w.srt
1
00:00:01,000 --> 00:00:05,000
Visit the website of Foobar
www.foobar.com

mencoder -forceidx -oac copy -ovc xvid -xvidencopts bitrate=3000 -sub w.srt -o x.avi 1.avi

Print

Upgrading WordPress

This is the procedure for upgrading a WordPress installation. It is based on the procedure from WordPress. However, this procedure is optimized for those, who has direct shell access to their web server.

Backup the database.

Backup the WordPress directory, download and install the new version.

cp -r www.foobar.com www.foobar.com-backup
cd www.foobar.com
rm -rf *
ftp http://wordpress.org/latest.zip
unzip latest.zip
rm latest.zip
mv wordpress/* .
rmdir wordpress

Restore the configuration. Confirm, that the wp-content.php file has the same structure as the old version. If not, edit the new file manually.

cd www.foobar.com-backup
cp wp-config.php ../www.foobar.com
cp -r wp-content ../www.foobar.com

cd ../www.foobar.com
chmod -R 0777 wp-content

Open the WordPress administration page, which is reached by adding /wp-admin to the website URL and follow the instructions, if any.

Confirm, that the version has been updated. Remove the backup directory.

rm -rf www.foobar.com-backup

Print

Setting up a new dynamic website, that uses a content management system

In our example, we want to set up a website, that has a log, a static page and a content management system behind it. We want to be able to change between different theme designs.

There are many of such open source systems around. We will choose WordPress for this example.

It is assumed, that system account and web server is configured.

Prior to the installation, we will need to create a database. We will be using the open source database project MySQL in this example.

Create a new user and a new database, that is not used for anything else, than this website. Create a password, that is not used elsewhere. Grant privileges, that only allows this user to operate on this database. These are recommended security measures.

On the website of WordPress, we copy the direct download link.

Open a terminal client, connect to the web server, change to the public website directory, download the latest source code, extract the source code archive and clean up.

cd www.foobar.com
ftp http://wordpress.org/latest.zip
unzip latest.zip
rm latest.zip
mv wordpress/* .
rmdir wordpress

Test the website in your browser. The content management system should respond at this point. Follow the instructions and use the terminal where possible.

Make sure, that the content management system can store uploaded pictures.

chmod 0777 wp-content

Log in and go through configurations from top to buttom. Use the theme feature filter search section, which is more neat than the one on the theme homepage, but, if you experience problems with the automatic FTP install feature, then install themes using manual download and installation instead. It seems, the automatic feature needs more work, such as accepting localhost, source code extract tools and path specification.

ftp http://wordpress.org/extend/themes/download/sliding-door.1.7.1.zip
unzip *.zip
unzip sliding-door.1.7.1.zip
rm sliding-door.1.7.1.zip

Consider writing a posting procedure, that helps you do the actual posting correct every time, and, that takes into account, what you wish and do not wish to publish on your website.

Print

Synchronizing an external copy of folders and files

A simple way to maintain an updated backup of your folders and files on an external storage media, such as an external harddisk or another computer, can be to synchronize them automatically at regular intervals using rsync.

rsync is a fast tool for copying files.

It can copy locally and to other hosts.

It reduces the amount of data, sent over networks, by sending only the differences between the source and destination files.

It copies files, that has changed in size or time stamp.

It can delete files on the destination, that has been deleted from the source.

If not installed, it can be installed from the ports collection.

cd /usr/ports/net/rsync
make
make install

In our example, we want to attach and mount an external harddisk and synchronize it, that is, copy files, that has changed since last backup, and, delete files, that has been deleted from the source since last backup.

mkdir -p -m 0700 /mnt/backup/`hostname`/home
rsync -a --delete /home/source /mnt/backup/`hostname`/home

We recommend, that you store external backups at another physical location, so you will survive theft, fire and the likes.

Print

Turning off automatic Windows Update

windows_updateWindows Update is the software in the Windows operating system, that keeps the system up to date. By default, it is run automatically. However, this is not recommended. It can be very disturbing, that you have to wait for it to finish before you can turn off your computer. It can also be very disturbing, that it keeps telling you, that you have to reboot while you are doing important work. More important, it can cause your computer to stop working while you needed it at the most.

We recommend, that such updating is performed manually on a regular basis at times, that is safe, such as once a week or once a month.

Open Control Panel. Open Security Center. Turn automatic update off.

From now on, you can manually update your system by clicking the Start menu and then clicking Windows Update.

Print