Showing posts with label how-tos. Show all posts
Showing posts with label how-tos. Show all posts

Tuesday, April 10, 2012

Titanium Backup + Dropbox HOWTO

I set this up today at long last (and assume most of it will apply to Box as well). Couldn't find much use on how to actually make it sync, so here is a picture!





Go into your Preferences -> Cloud sync settings; and enable dropbox. You can go into Dropbox Settings to control stuff like what to sync and where to sync, etc. Then go to the "Schedules" tab and voila!

I don't see what is so schedule about that, and I seem to remember reading that you have to do sync's manually rather than on a schedule but whatever. Couldn't find crap on Google, so I took a screenie ^_^.

Monday, January 16, 2012

How to make your own buttonhook cheap

When working a while back on my private tactics compendium, I summised that we probably call the Button-hook technique after the use of a real buttonhook. Well, my new work shirts are a pain in the ass to button at the collar, so on the way to the office this morning, I thought about how to make one. Yes I'm cheap and I like solving problems here and there lol.

Unfold a paper clip like so:


And you have yourself a buttonhook for like a penny versus $5-$15 out of a store!

Plus if you push the little end closed, you have an ear clip just like my father would make. Those are the most awesome way to clean ear wax out of your ears—qtips are no good.

Friday, June 17, 2011

VNC over SSH, the idiots guide.

Since I rather like to have options, I've decided to augment my usual SSH /w option of X forwarding to the option of VNC as well.

Objective: connect to my netbooks X session using VNC, tunnelled over SSH.


Implementation:

Since my netbook runs a GNOME centric distribution, I'm using the "Remote Desktop" preferences program on "System -> Preferences". If you're like me and to damn lazy to hunt and peck, this just runs the program 'vino-preferences'. On here it's possible to setup VNC access to your desktop. In essence, it just runs vino when you login. There are loads of good and bad write ups on VNC server setup and 3 or 4 click setup is good enough for me.


My iptables rules pretty much block such things as incoming VNC requests, which is good because I don't want the session exposed across the network interface. Pretty much all there is for accessing my netbook is the SSH port.

Now on another system, it's possible to connect using SSH forwarding. This gains us both encryption for the VNC session and less port exposure; that is good for security.

PuTTY client setup:

  1. Load/create your session in PuTTY
  2. Go to SSH -> Tunnels
  3. Add a port forwards
    1. source port: 5900
    2. destination: localhost:5900
  4. Login to the system using PuTTY.
OpenSSH client setup:
  1. ssh -L 5900:localhost:5900 username@host
There are options for both if disabling the shell session and only running the forwarding is preferred (PuTTY: SSH->Don't start a command at all; OpenSSH -> RTFM for -n, -N, and -f). 5900 is the default VNC port running off the server end (my netbook).


Now on the client machine, connecting any VNC client (e.g. TightVNC) to localhost should give the desktop session over at user@host; in this case, my X session on alice!



This is the shortest, sweetest, non-non-sense, you're assumed to know how to RTFM if you want to know the facts, kind of write up that I've seen on doing this. Hmm, maybe it helps that I already know how to use SSH port forwarding with OpenSSH, hehehe.

Thursday, July 23, 2009

Building vim with support for Python and Perl on Windows

Previously:

install a suitable version of Visual Studio / Visual C++
install a suitable version of Python
install a suitable version of Perl
open a Visual Studio Command Prompt

I have VC Express 9.0, ActivePerl 5.10.0, and Python 2.6.2 installed from Python.org's installer.


Check out the VIM source code, you can find directions here. I suggest using CVS or SVN to make the patching life easier. Precompiled binaries of CVS and SVN are available for Windows, and it is possible to build them yourself of course ;).


I use CVS and wish to keep the tree along side my regular vim:

> cd /d P:\editors\vim
> cvs -z3 -d:pserver:anonymous@vim.cvs.sf.net:/cvsroot/vim checkout -Nd vim7-cvs-src vim7
> cd vim7-cvs-src\src

You should know read the Make_mvc.mak makefile to find the options you are interested in using. I'll leave the viewing the file from the command line to a Windows users intelligence (hints: more, edit, notepad, wordpad, or gvim would be useful). We have to tell nmake.exe to use this file and our options, for asses who use Visual Studio all day but don't remember nmake: we pass it VAR=value pairs.

> nmake /F Make_mvc.mak CPUNR=i686 FEATURES=HUGE GUI=yes OLE=yes CSCOPE=yes CTAGS=ctags POSTSCRIPT=yes PYTHON=P:\Devel\Languages\Python\2.6\ PYTHON_VER=26 PERL=P:\Devel\Languages\Perl\ PERL_VER=510

Obviously if you want same options, adjust the paths like a good little geek.

At least on my system, MSVCs compiler refuses to build the vimrun.exe, install.exe, uninstal.exe, and xxd/xxd.exe targets (and programs). As such, I build gvim and the gvimext.dll - the targets are in the makefile. if one wants to build a vim execuitable under a diffirent name, I suggest 'nmake /e VIM=foo /f ... OPTS=... foo.exe' to create foo.exe (default is gvim).


As such we need a place to put vim so we can actually use it.

> MKDIR ..\..\vim-personal
> FOR %F IN (*.dll *.exe) DO XCOPY /Y %F ..\..\vim-personal
> XCOPY /Y P:\Devel\Languages\Perl\bin\perl510.dll ..\..\vim-personal
> XCOPY /I /E /Y ..\runtime\* ..\..\vim-personal

and one can borrow the lost vimrun and diff files from a working install. If one also juggled the names so that vim-personal became vim72, one could also borrow the install.exe file most likely...



In doing all of this, I've written a batch script to use in automating the thing, which is not as good as my vimbuild shell script but still works lol. When I get some time I'll make my script also update the spell files and what nots (hint: see spell\readme.txt)

Wednesday, October 29, 2008

Installing SWAT 4 TSS on GNU/Linux

Disclaimer

The game is not supported by code weavers, and I don't support users of this posting ether. However, comments and corrections are always welcome - spam will be killed. Also note well, I prefer the command line interface, so I do not use file mangers such as Explorer, Nautilus, or Filer often.



Prerequsists:


  • Basic understanding of GNU/Linux user accounts and permissions
  • Having a working GNU/Linux distribution installed (Ubuntu or Debian recommended)
  • The ability to understand file paths and simple file operations (e.g. copy) without a photograph or explanation of how to copy/move/delete files.
  • Legal copies of both SWAT 4 and SWAT 4: TSS, total of 3 CD-ROM


Step one: Purchase a copy of "CrossOver Games for Linux" from CodeWeavers, or download the free 7 day trial.

Step two: install Cross Over Games for Linux, hence forth called simply cxgames -- for brevities sake!


The installation process is simple, the format I suggest is to install it as root for all users. This basically amounts to executing the install shell script as root, either with su or sudo

$ su - root
# ./install-crossover-games-demo-7.1.0.sh

$ sudo -H ././install-crossover-games-demo-7.1.0.sh

Either way, root will need access to you're display. Via the su method, on a secure system to will have to grant root this access. The proscribed method is you'll need to run
xhost +local:root
, and set your $DISPLAY value accordingly once you've su'd to root. N.B. a lot of documents say
xhost +localhost
, which will grant everyone on your machine access to the display; instead of adding root.


Once you've launched the install script, it will walk you through it -- mostly by a graphical installation wizard.



Step Three: Install SWAT 4

Insert your SWAT 4 disk #1 into the drive, and make sure it is mounted. Some Linux distributions are set to automount it like Windows (Ubuntu), others require you to manually mount it. N.B. that secure systems will only allow root to mount file systems by default.

Launch the cxgames windows program installer; this may be in your applications menu (gnome/kde users) or have to be run manually from a prompt. If you have to run it manually, the program you want to execute is /where/you/installed/cxgames/bin/cxinstall, for example: /opt/cxgames/bin/cxinstall.


Since SWAT 4 is not one of the supported games, you'll want to go with the "install other games" option, and pass by the disclaimer. You'll thne need to tell it where to find the disk, usually this is just clicking a checkbox but it is quite flexible. You should install SWAT 4 into it's own "bottle", because Linux doesn't care much for spaces (and command lines are fun), a good bottle name is "SWAT4".


A bottle is just a simulated windows installation, so if desired - every game can be installed into it's own separate place. This really makes back ups a snap, limits one program screwing with another, and improves situations if you need to make 'tweaks' to the bottle. The installer will then create the bottle in your personal space, e.g. /home/terry/.cxgames/SWAT4. N.B. that .files-and-dirs in Linux are considered 'hidden' files, in a GUI file manager, you'll need to b/p to deal with that.


When the installer starts, run it, there is no need to change the default install paths, unless you are installing into a very customized bottle. Since SWAT 4 uses two CD-ROMs, you will have to umount your first disk, and mount your second before pressing "retry" on the change disks dialog. Same thing happens again at the end of the install, to put the play disk back into circulation. When you're done, you can close the install program and tell the cxgames installer that it has completed, it will warn you for paranoias sake -- close it.


Step Four: Launch SWAT 4

SWAT 4 uses a SecuROM based copy protection system, when I set this up - it thought cxgames version of wine was a cd-rom emulator! And refused to run, a quick fix is to google for the 'swat 4 no cd'. You will need to backup the old Swat4.exe, and then replace it with the no cd fix in order to launch the game.

Since I prefer the command line, I use cp and mv to copy and move files around; rather then copy/pasting icons in a file manager.

$ cd ~/.cxgames/SWAT4/drive-c/Program\ Files/Sierra\SWAT\ 4/Content/System
$ mv Swat4.exe Swat4.exe.orig-1.0
$ cp /path/to/fixed/1.0/Swat4.exe ./Swat4.exe.nocd-1.0
$ cp Swat4.exe.nocd-1.0 Swat4.exe

Now launch the game, either via your applications menu (gnome/kde users), or manually with the wine subsystem of cxgames, e.g.

$ /opt/cxgames/bin/wine --bottle ~/.cxgames/SWAT4 ~/.cxgames/SWAT4/drive-c/Program\ Files/Sierra\SWAT\ 4/Content/System/Swat4.exe

Then go ahead and test the training level or something like that. SWAT 4 must take care of first run chores before you install the path. When you're done, just exit the game like normal. In the vent of catrostrophic disaster, you should be able to ctl+alt+function key to vtty, login to a command prompt, and us the ps and kill commands to terminate the process, cxgames also has it's own way of nuking bad windows processes hehe.



Step Five: Patch SWAT 4

Because the patch checks for a legit copy of SWAT4, we have to replace Swat4.exe with Swat4.exe.orig-1.0, otherwise the patch will fail and scramble a few game files.

$ rm Swat4.exe
$ cp Swat4.exe.orig-1.0 Swat4.exe

Now insert you SWAT 4: TSS disk and run the installer, just like when you installed SWAT 4. Except use the same bottle, by selecting it from a list of existing bottles when prompted for a bottle to use. Once the TSS installer pops up, click the button to install the SWAT 4 1.1 patch.



Step Six: Test run SWAT 4 1.1

Now you need to use a no cd fix for SWAT 4 1.1 in order to continue, download it and do like in Step Four.

$ mv Swat4.exe Swat4.exe.orig-1.1
$ cp /path/to/fixed/1.1/Swat4.exe ./Swat4.exe.nocd-1.1
$ cp Swat4.exe.nocd-1.1 Swat4.exe


and launch the game as in Step Five.


Step Seven: Installing TSS

If you left the TSS installer open from Step Six, fine, if not, open it again -- same exact way.

You will have to replace the no cd fixed Swat4.exe with the original one from the path, else the TSS installer will bomb out on you.

$ rm Swat4.exe
$ cp Swat4.exe.orig-1.1 Swat4.exe

Now get the TSS installer up and click the install swat 4 tss expansion pack button. Then proceed through the installation process; you shouldn't have any major problem, as long as you remembered switch executables first.

Step Eight: Run SWAT 4: TSS

Now you should be able to launch SWAT 4: TSS, when I did it... there was no problem with the Swat4x.exe file in the expansion pack, but the game soon refused to run, having verification problems, despite being a legally paid for copy, with the legally paid for copy in the drive. So one will need to employ another no cd fix to be able to use this legally paid for copy of the game.

$ cd ~/.cxgames/SWAT4/drive-c/Program\ Files/Sierra\SWAT\ 4/ContentExpansion/System
$ mv Swat4X.exe Swat4X.exe.orig
$ cp /path/to/fixed/Swat4X.exe ./Swat4X.exe.nocd
$ cp Swat4X.exe.nocd Swat4X.exe

You can launch it the same way as SWAT 4, but in the case of the command line, the path changes. Just like on Windows, from Content\System\Swat4.exe to ContentExpansion\System\Swat4.exe.



Known Issues


If the game and your display are not running at the same resolution, moving your mouse pointer to the 'edge' will make it scroll outside the window, effectively creating a pan and scan across your display. I have a 1600x1200px primary screen and a 1280x1024 secondary screen. Having SWAT in 1024x768px mode, was horrible... edit: this happens even when the game and X screen are at the same resolution.


I have yet to determine under what conditions dual heads will work, but luckyally most X Window Managers handle dual heads better then Microsoft Windows (in my indignant opinion), at least that has been my experience under FreeBSD 7 and Ubuntu GNU/Linux 8.04 with X.Org 7.2,a nd Windows XP Media Center Edition. So the main problem is a question of mouse handling.


Because of the way things work, people who use mods (e.g. SSF) may have problems launching them, without a corresponding no cd exe. Other wise the game seems to be useable, I've only to acertain whether or not graphical performance can be maintained.


Free Image Hosting at www.ImageShack.us


My word, wouldn't it be heaven to only need windows to play Raven Shield once in a blue moon?

Sunday, September 28, 2008

HOWTO boot FreeBSD, Linux, and Windows XP with GAG, GRUB, LILO, and BootEasy






Abstract


This posting endeavours to allow users to successfully boot the following Operating systems: Windows XP, most GNU/Linux distro, and FreeBSD/PC-BSD; using the following boot loaders: GAG, GRUB, LILO, PC-BSD (aka BootEasy). The target audience are PC-BSD users coming from Linux.

There will be several references provided at the end of the posting.



Using the Graphical Boot Manager, GAG


Simply boot off the install media and follow the on screen instructions.

Note well that must install a boot loader such as LILO or GRUB in a Linux / partition in order to boot Linux from GAG, like most other abstract boot loaders.

Using GNU GRUB


In order to boot PC-BSD from GRUB, you must tell GRUB which drive, slice, and
partition to load from; usign GRUBs own notation
syntax
.

The systems kernel is stored on disk as /boot/kernel/kernel and it's Loadable Kernel Module (LKM) drivers are stored in the same directory; with a .ko suffix. Although it is possible to load the kernel directly, it is better to load stage three instead, which gives you an easier interface to loading the desired kernel.

You will have to edit the GRUBs configuration file. The name and location of GRUBs configuration varies based on your Operating System. Under Debian (and thus Ubuntu), OpenSUSE, and FreeBSD based systems, you will find it as /boot/grub/menu.lst. On Fedora/Red Hat Linux and Gentoo based systems you will find it in /boot/grub/grub.conf. Many distros may provide a symbolic link to /etc/grub.conf, please refer to your operating systems documentation if you can not find the file.


Open it as root and edit it accordingly with the settings for your system. This example is is meant for triple booting Windows XP, GNU/Linux, and PC-BSD, where they are installed in that order, into primary partitions.

title WindowsXP
root (hd0,0)
makeactive
chainloader --force +1
boot

title Foo Linux
root (hd0,1)
kernel /boot/vmlinuz

title PC-BSD
root (hd0,2,a)
kernel /boot/loader

By default, if the slice number is omitted, GRUB searches the first slice which has a partition. I have however specified the slice number in this example.

If your distro has already configured Windows and Linux in menu.lst/grub.conf,
you should probably leave it as is; appending the PC-BSD entry to the
configuration. The location and file name of the linux kernel can vary a bit,
/boot/vmlinuz, /vmlinuz, and /boot/vmlinuz-x.y.z should be common, but my grasp
of Linux kernels dates to Linux 2.2, not modern 2.6 --- as always check your
operating systems documentation when necessary! initrd users please see the grub
manuls notes on
linux
.



Using LILO


For those whom still prefer the LInux LOader, you can still use it for booting PC-BSD: edit /etc/lilo.conf accordingly:

# cp /etc/lilo.conf /root/lilo.conf.old
# vi /etc/lilo.conf
# /sbin/lilo

I will leave the top matter in lilo.conf as an exercise to the reader (if you use LILO, you should know this); so working off the GRUB example, the /etc/lilo.conf file should look like:

other=/dev/hda1
 label=WinXP
 table=/dev/hda

image=/boot/vmlinuz
 label=FooLinux
 root=/dev/hda2
 table=/dev/hda

other=/dev/hda2
 label=PCBSD
 root=/dev/hda3
 table=/dev/hda

NB that initrd users will want to add a initrd=/path/to/your/initrd/img rule to
the FooLinux image specs.

Users with multiple hard drives, please refer to the FreeBSD
FAQ
for details.


Using the PC-BSD Boot Loader


The header is actually miss leading, as this is really just the boot loader used by FreeBSD, a.k.a. Boot Easy or /boot/boot0. Hence forth called BootEasy.

To boot your operating systems with BootEasy, once is installed - just reboot the PC. Following the previous examples, you would see a prompt like this:

F1: DOS
F2: Linux
F3: FreeBSD

Press F1 on the keyboard to load Windows XP, F2 to chainload FooLinux, or F3 to load PC-BSD.

Note well that you must have a suitable boot loader installed into the linux / partition in order to boot linux from BootEasy.

The FreeBSD FAQ specifically recommends to install
LILO into the Linux /
, although GRUB should work fine when installed into Linuxes /

References





Post script:


If you have a problem with my spelling, grammar, or punctuation: you can pay my family to go on a shopping spree and leave me free to type slower then I can physically move my fingers across the keys.


Disclaimer


The information provided here is done for your convenience at the authors expanse, it however is without any form of warranty or guarantee of fittness --- use at yur own risk, I'm not responsible.

Saturday, June 14, 2008

Converting FreeBSD into PC-BSD

Abstract


This post describes an example of how one can manually convert a FreeBSD installation into a PC-BSD one using the install disk. There are more elegant ways of doing it, such as pulling things from PC-BSDs SVN and compiling only PC-BSD specific components.



Disclaimers and warnings


This was done purely for 'fun' to see if the programs would work reasonably well. Which is why FreeBSD 7.0-Release was used as a base and PC-BSD 1.5.0 as the overlay (which is based on an old build of FreeBSD 6.3). I do not recommend, endorse, or even suggest actually doing something like this beyond exploratory or playful thoughts at heart !!!


If anyone actually tries this, your on your own.


If someone actually tries this they should probably use a PC-BSD 1.5.1 disk build, the files are newer.


Installing the PC-BSD v1.5.0-v1.5.1 update will install FreeBSD 6.3 files and may break your system -- note that I didn't enable the updater for my user account during this process.



Now that you are warned...


My test partition is reserved fro testing various alpha/beta/rc releases of operating systems I wish to test. So I wiped it clean and set out to install a basic working FreeBSD system.


I Installed FreeBSD 7.0-Release via CD-ROM, using the express option, auto
partitioning to save time, X-Developer dist set, and configured the system
lightly (set root pw, network services etc).


You want the X.org and related drivers from the disk, so they match your release level -- you also want source code for later to build a custom kernel (optional)


Booted the system and logged in as root, one vtty for work and one for logging my notes in vim over ssh.


Then began converting the system to a FreeBSD-PC-BSD hybrid. Since the FreeBSD auto mode for partitioning the slice only gave me a 512mb / and 512mb /tmp, I created a /usr/work directory to use.



NOTE:
actual PC-BSD systems require several gigs of space for / to ensure safe updates and this is noted during previous upgrade notes. My guess after reading some of the 1.4/1.5 scripts is the developers have 'yet' to figure out how to use mount -a for mounting the needed file systems before extracting files and reserved storage places with the default partitioning scheme


pkg_add -r lzma && rehash  # to unpack pc-bsd files
mount -t cd9690 /dev/acd0 /mnt  # mount pc-bsd disk 1
mkdir -m 0700 /usr/work
lzma d /mnt/PCBSD.tar.lzma /usr/work/PCBSD.tar
 ...
     # lzma has fast decompression speeds but
     # this is a ~451mb lzma file being
     # unpacked into a 1.9gb tar file!

tar -C / -kpf /usr/work/PCBSD.tar # extract files without overwrite 

cp /etc/rc.conf /etc/rc.conf.local # fix rc.conf
tar -C /tmp -f /usr/work/PCBSD.tar -px './etc'
cp /tmp/etc/rc.conf /etc/rc.conf
cp /tmp/etc/devfs.conf /etc/devfs.conf # modified in pc-bsd

vi /etc/ttys    # start x on boot up
 ...    # note the ttyvNum is arbitrary
 #ttyv8 "/usr/local/bin/xdm -nodaemon"  xterm   off secure
 ttyv8   "/PCBSD/bin/pdm"                xterm   on secure
 ...
X -configure && mv /root/xorg.conf.new /etc/X11/xorg.conf

#
# create users and groups that come with PC-BSD 1.5.0 but not FreeBSD
# 7.0-Release. Numerical values for -u userid and -g groupid are taken from
# viewing a unified diff of the group files.
#
pw groupadd -n haldaemon -g 560
pw groupadd -n cups -g 193
pw groupadd -n cyrus -g 60
pw useradd -n haldaemon -u 560 -g 560 -L daemon -d /nonexistent \
  -s /usr/sbin/nologin
pw useradd -n cups -u 193 -g 193 -L daemon -d /nonexistent -s /usr/sbin/nologin
pw useradd -n cyrus -u 60 -g 60 -L daemon -d /nonexistent -s /usr/sbin/nologin

#
# add my own user with the bash shell as a test (because it. Note that I typically set
# user/group id numbers by year of birth.
#
pw groupadd -n Terry -g 1988
pw useradd -n Terry -u 1988 -L default -m -s bash -g Terry \
  -G wheel,operator
passwd Terry
 ...

#
# now build a custom kernel merging GENERIC with /PCBSD/conf/PCBSD.i386
# I find Micro GNU Emacs (mg) to be both light and effective for this task.
# -- normally I would use vimdiff
#
pkg_add -r mg && rehash    # if using mg !
cat > ~/.mg
auto-fill-mode
set-fill-column 78
global-set-key "\^x\^f" find-file
global-set-key "\^h" delete-backward-char
set-default-mode blink
^D      # end of ~/.mg

diff -u /usr/src/sys/i386/conf/GENERIC /PCBSD/conf/PCBSD.i386 > /tmp/kern.diff
cd /usr/src/sys/i386/conf
mg KAI
 ...    # kernel config attached at EOF
     # used GENERIC and /tmp/kern.diff to
     # write the file if needed.

cd /usr/src    # compile & install kernel
make -j12 buildkernel KERNCONF=KAI
 ...    # roughly 10 minutes later..
make -j12 installkernel KERNCONF=KAI
 ...    
umount /mnt && cdcontrol -f /dev/acd0 eject
reboot     # let's rock it and roll on to KDE


On reboot, I was greeted with KDM, PC-BSDs login theme, and a clean startup of KDE (no error message popups). I was able to install and use the Firefox PBI from PBIDir without problems. But as one can see in the screen shots, there are sound system related core dumps


Free Image Hosting at www.ImageShack.us

Free Image Hosting at www.ImageShack.us

Free Image Hosting at www.ImageShack.us


I was also interested to see that there is now a 'snd_emu10kx' driver added in FreeBSD 7.0-Release which supports my card. So I guess I won't have to manually compile the 'outdated, unmaintained, etc' audio/emu10kx port to get working sound, the manual page seems to suggest it is the same driver more or less. I only had to add an entry to my loader.conf file to get it loaded before PC-BSD sound detection system, just like audio/emu10kx from ports it won't work (for me) if kldload'ed later on.


I found that although everything I tested was working fine, audio and video related apps were dumping core (mplayer at start, kaffeine during playback). So I did a pkg_delete on kaffeine and kaffeine-mozilla and reinstalled from packages and soon was blasting MP3's from a FAT32 partition ;-)


MPlayer needs to be recompiled as expected, The KDE sound system will likely need that to but otherwise I've observed no real breakages. Not that I've taken the time to test every single program!



Personal Opinions


If like me, your primary reason for using PC-BSD is a quick way of grabbing KDE -- you would be better off installing PC-BSD! As far as setting up a working desktop system, one can do that easy through FreeBSD. If one doesn't want to go into configuration details for 'extra's like PF or X11 using PC-BSD or DesktopBSD is a better idea anyway.



If all you want is PBI, export, compile, and install the necessary files from PC-BSDs SVN repository.




Kernel Configuration: KAI


Note to SATA hard drives out there, the ATA_STATIC_ID option effects device numbering. FreeBSD GENERIC kernel configuration uses it and detects my SATA drive as 'ad4', PC_BSD kernel configuration has it turned off and detects my drive as 'ad0' -- I only have one SATA II hard drive installed.


Changing the ATA_STATIC_ID kernel option means you will havve to make sure /etc/fstab is in working shape unless you want to see a mount root prompt.


#
# Custom FreeBSD 7.0 kernel based on PC-BSD 1.5 Kernel config for FreeBSD 6.3
#

cpu  I686_CPU
ident  KAI



#options  SCHED_$BSD  # 4BSD scheduler
options  SCHED_ULE  # ULE scheduler ;-)
options  PREEMPTION  # ENABLE KERNEL THREAD PREEMPTION
options  INET   # INTERNETWORKING
options  INET6   # IPV6 COMMUNICATIONS PROTOCOLS
options  SCTP   # STREAM CONTROL TRANSMISSION PROTOCOL
options  FFS   # BERKELEY FAST FILESYSTEM
options  SOFTUPDATES  # ENABLE FFS SOFT UPDATES SUPPORT
options  UFS_ACL   # SUPPORT FOR ACCESS CONTROL LISTS
options  UFS_DIRHASH  # IMPROVE PERFORMANCE ON BIG DIRECTORIES
options  UFS_GJOURNAL  # ENABLE GJOURNAL-BASED UFS JOURNALING
options  MD_ROOT   # MD IS A POTENTIAL ROOT device
options  NFSCLIENT  # NETWORK FILESYSTEM CLIENT
options  NFSSERVER  # NETWORK FILESYSTEM SERVER
options  NFS_ROOT  # NFS USABLE AS /, REQUIRES NFSCLIENT
options  MSDOSFS   # MSDOS FILESYSTEM
options  CD9660   # ISO 9660 FILESYSTEM
options  PROCFS   # PROCESS FILESYSTEM (REQUIRES PSEUDOFS)
options  PSEUDOFS  # PSEUDO-FILESYSTEM FRAMEWORK
options  GEOM_PART_GPT  # GUID PARTITION TABLES.
options  GEOM_LABEL  # PROVIDES LABELIZATION
options  COMPAT_43TTY  # BSD 4.3 TTY COMPAT [KEEP THIS!]
options  COMPAT_FREEBSD4  # COMPATIBLE WITH FREEBSD4
options  COMPAT_FREEBSD5  # COMPATIBLE WITH FREEBSD5
options  COMPAT_FREEBSD6  # COMPATIBLE WITH FREEBSD6
options  SCSI_DELAY=5000  # DELAY (IN MS) BEFORE PROBING SCSI
options  KTRACE   # KTRACE(1) SUPPORT
options  SYSVSHM   # SYSV-STYLE SHARED MEMORY
options  SYSVMSG   # SYSV-STYLE MESSAGE QUEUES
options  SYSVSEM   # SYSV-STYLE SEMAPHORES
options  _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B REAL-TIME EXTENSIONS
options  KBD_INSTALL_CDEV # INSTALL A CDEV ENTRY IN /DEV
options  ADAPTIVE_GIANT  # GIANT MUTEX IS ADAPTIVE.
options  STOP_NMI  # STOP CPUS USING NMI INSTEAD OF IPI
options  AUDIT   # SECURITY EVENT AUDITING

# TO MAKE AN SMP KERNEL, THE NEXT TWO LINES ARE NEEDED
options  SMP   # SYMMETRIC MULTIPROCESSOR KERNEL
device  apic   # I/O APIC

# CPU FREQUENCY CONTROL
device  cpufreq

# BUS SUPPORT.
device  eisa
device  pci


# FLOPPY DRIVES
device  fdc

# ATA AND ATAPI deviceS
device  ata
device  atadisk  # ATA DISK DRIVES
device  ataraid  # ATA RAID DRIVES
device  atapicd  # ATAPI CDROM DRIVES
device  atapifd  # ATAPI FLOPPY DRIVES
device  atapist  # ATAPI TAPE DRIVES
options  ATA_STATIC_ID # STATIC device NUMBERING
device   atapicam # Atapi CAM support

# SCSI CONTROLLERS
device  ahb  # EISA AHA1742 FAMILY
device  ahc  # AHA2940 AND ONBOARD AIC7XXX deviceS
options  AHC_REG_PRETTY_PRINT # PRINT REGISTER BITFIELDS IN DEBUG
     # OUTPUT.  ADDS ~128K TO DRIVER.
device  ahd  # AHA39320/29320 AND ONBOARD AIC79XX deviceS
options  AHD_REG_PRETTY_PRINT # PRINT REGISTER BITFIELDS IN DEBUG
     # OUTPUT.  ADDS ~215K TO DRIVER.
device  amd  # AMD 53C974 (TEKRAM DC-390(T))
device  isp  # QLOGIC FAMILY
#device  ispfw  # FIRMWARE FOR QLOGIC HBAS- NORMALLY A MODULE
device  mpt  # LSI-LOGIC MPT-FUSION
#device  ncr  # NCR/SYMBIOS LOGIC
device  sym  # NCR/SYMBIOS LOGIC (NEWER CHIPSETS + THOSE OF `NCR')
device  trm  # TEKRAM DC395U/UW/F DC315U ADAPTERS

device  adv  # ADVANSYS SCSI ADAPTERS
device  adw  # ADVANSYS WIDE SCSI ADAPTERS
device  aha  # ADAPTEC 154X SCSI ADAPTERS
device  aic  # ADAPTEC 15[012]X SCSI ADAPTERS, AIC-6[23]60.
device  bt  # BUSLOGIC/MYLEX MULTIMASTER SCSI ADAPTERS

device  ncv  # NCR 53C500
device  nsp  # WORKBIT NINJA SCSI-3
device  stg  # TMC 18C30/18C50

# SCSI PERIPHERALS
device  scbus  # SCSI BUS (REQUIRED FOR SCSI)
device  ch  # SCSI MEDIA CHANGERS
device  da  # DIRECT ACCESS (DISKS)
device  sa  # SEQUENTIAL ACCESS (TAPE ETC)
device  cd  # CD
device  pass  # PASSTHROUGH device (DIRECT SCSI ACCESS)
device  ses  # SCSI ENVIRONMENTAL SERVICES (AND SAF-TE)

# RAID CONTROLLERS INTERFACED TO THE SCSI SUBSYSTEM
device  amr  # AMI MEGARAID
device  arcmsr  # ARECA SATA II RAID
device  asr  # DPT SMARTRAID V, VI AND ADAPTEC SCSI RAID
device  ciss  # COMPAQ SMART RAID 5*
device  dpt  # DPT SMARTCACHE III, IV - SEE NOTES FOR options
device  hptmv  # HIGHPOINT ROCKETRAID 182X
device  hptrr  # HIGHPOINT ROCKETRAID 17XX, 22XX, 23XX, 25XX
device  iir  # INTEL INTEGRATED RAID
device  ips  # IBM (ADAPTEC) SERVERAID
device  mly  # MYLEX ACCELERAID/EXTREMERAID
device  twa  # 3WARE 9000 SERIES PATA/SATA RAID

# RAID CONTROLLERS
device  aac  # ADAPTEC FSA RAID
device  aacp  # SCSI PASSTHROUGH FOR AAC (REQUIRES CAM)
device  ida  # COMPAQ SMART RAID
device  mfi  # LSI MEGARAID SAS
device  mlx  # MYLEX DAC960 FAMILY
device  pst  # PROMISE SUPERTRAK SX6000
device  twe  # 3WARE ATA RAID

# ATKBDC0 CONTROLS BOTH THE KEYBOARD AND THE PS/2 MOUSE
device  atkbdc  # AT KEYBOARD CONTROLLER
device  atkbd  # AT KEYBOARD
device  psm  # PS/2 MOUSE


device  vga  # VGA VIDEO CARD DRIVER

device  splash  # SPLASH SCREEN AND SCREEN SAVER SUPPORT

# SYSCONS IS THE DEFAULT CONSOLE DRIVER, RESEMBLING AN SCO CONSOLE
device  sc

device  agp  # SUPPORT SEVERAL AGP CHIPSETS

# POWER MANAGEMENT SUPPORT (SEE NOTES FOR MORE options)
#device  apm
# ADD SUSPEND/RESUME SUPPORT FOR THE I8254.
device  pmtimer

# PCCARD (PCMCIA) SUPPORT
# PCMCIA AND CARDBUS BRIDGE SUPPORT
device  cbb  # CARDBUS (YENTA) BRIDGE
device  pccard  # PC CARD (16-BIT) BUS
device  cardbus  # CARDBUS (32-BIT) BUS

# SERIAL (COM) PORTS
device  sio  # 8250, 16[45]50 BASED SERIAL PORTS
device  uart  # GENERIC UART DRIVER

# PARALLEL PORT
device  ppc
device  ppbus  # PARALLEL PORT BUS (REQUIRED)
device  lpt  # PRINTER
device  plip  # TCP/IP OVER PARALLEL
device  ppi  # PARALLEL PORT INTERFACE device
#device  vpo  # REQUIRES SCBUS AND DA

# IF YOU'VE GOT A "DUMB" SERIAL OR PARALLEL PCI CARD THAT IS
# SUPPORTED BY THE PUC(4) GLUE DRIVER, UNCOMMENT THE FOLLOWING
# LINE TO ENABLE IT (CONNECTS TO SIO, UART AND/OR PPC DRIVERS):
#device  puc

# PCI ETHERNET NICS.
device  de  # DEC/INTEL DC21X4X (``TULIP'')
device  em  # INTEL PRO/1000 ADAPTER GIGABIT ETHERNET CARD
device  ixgb  # INTEL PRO/10GBE ETHERNET CARD
device  le  # AMD AM7900 LANCE AND AM79C9XX PCNET
device  txp  # 3COM 3CR990 (``TYPHOON'')
device  vx  # 3COM 3C590, 3C595 (``VORTEX'')

# PCI ETHERNET NICS THAT USE THE COMMON MII BUS CONTROLLER CODE.
# NOTE: BE SURE TO KEEP THE 'device MIIBUS' LINE IN ORDER TO USE THESE NICS!
device  miibus  # MII BUS SUPPORT
device  bce  # BROADCOM BCM5706/BCM5708 GIGABIT ETHERNET
device  bfe  # BROADCOM BCM440X 10/100 ETHERNET
device  bge  # BROADCOM BCM570XX GIGABIT ETHERNET
device  dc  # DEC/INTEL 21143 AND VARIOUS WORKALIKES
device  fxp  # INTEL ETHEREXPRESS PRO/100B (82557, 82558)
device  lge  # LEVEL 1 LXT1001 GIGABIT ETHERNET
device  msk  # MARVELL/SYSKONNECT YUKON II GIGABIT ETHERNET
device  nfe  # NVIDIA NFORCE MCP ON-BOARD ETHERNET
device  nge  # NATSEMI DP83820 GIGABIT ETHERNET
#device  nve  # NVIDIA NFORCE MCP ON-BOARD ETHERNET NETWORKING
device  pcn  # AMD AM79C97X PCI 10/100 (PRECEDENCE OVER 'LE')
device  re  # REALTEK 8139C+/8169/8169S/8110S
device  rl  # REALTEK 8129/8139
device  sf  # ADAPTEC AIC-6915 (``STARFIRE'')
device  sis  # SILICON INTEGRATED SYSTEMS SIS 900/SIS 7016
device  sk  # SYSKONNECT SK-984X & SK-982X GIGABIT ETHERNET
device  ste  # SUNDANCE ST201 (D-LINK DFE-550TX)
device  stge  # SUNDANCE/TAMARACK TC9021 GIGABIT ETHERNET
device  ti  # ALTEON NETWORKS TIGON I/II GIGABIT ETHERNET
device  tl  # TEXAS INSTRUMENTS THUNDERLAN
device  tx  # SMC ETHERPOWER II (83C170 ``EPIC'')
device  vge  # VIA VT612X GIGABIT ETHERNET
device  vr  # VIA RHINE, RHINE II
device  wb  # WINBOND W89C840F
device  xl  # 3COM 3C90X (``BOOMERANG'', ``CYCLONE'')

# ISA ETHERNET NICS.  PCCARD NICS INCLUDED.
device  cs  # CRYSTAL SEMICONDUCTOR CS89X0 NIC
# 'device ED' REQUIRES 'device MIIBUS'
device  ed  # NE[12]000, SMC ULTRA, 3C503, DS8390 CARDS
device  ex  # INTEL ETHEREXPRESS PRO/10 AND PRO/10+
device  ep  # ETHERLINK III BASED CARDS
device  fe  # FUJITSU MB8696X BASED CARDS
device  ie  # ETHEREXPRESS 8/16, 3C507, STARLAN 10 ETC.
device  sn  # SMC'S 9000 SERIES OF ETHERNET CHIPS
device  xe  # XIRCOM PCCARD ETHERNET

# WIRELESS NIC CARDS
device  wlan  # 802.11 SUPPORT
device  wlan_wep # 802.11 WEP SUPPORT
device  wlan_ccmp # 802.11 CCMP SUPPORT
device  wlan_tkip # 802.11 TKIP SUPPORT
device  wlan_amrr # AMRR TRANSMIT RATE CONTROL ALGORITHM
device  wlan_scan_ap # 802.11 AP MODE SCANNING
device  wlan_scan_sta # 802.11 STA MODE SCANNING
device  an  # AIRONET 4500/4800 802.11 WIRELESS NICS.
device  ath  # ATHEROS PCI/CARDBUS NIC'S
device  ath_hal  # ATHEROS HAL (HARDWARE ACCESS LAYER)
device  ath_rate_sample # SAMPLERATE TX RATE CONTROL FOR ATH
device  awi  # BAYSTACK 660 AND OTHERS
device  ral  # RALINK TECHNOLOGY RT2500 WIRELESS NICS.
device  wi  # WAVELAN/INTERSIL/SYMBOL 802.11 WIRELESS NICS.
#device  wl  # OLDER NON 802.11 WAVELAN WIRELESS NIC.

# PSEUDO deviceS.
device  loop  # NETWORK LOOPBACK
device  random  # ENTROPY device
device  ether  # ETHERNET SUPPORT
device  sl  # KERNEL SLIP
device  ppp  # KERNEL PPP
device  tun  # PACKET TUNNEL.
device  pty  # PSEUDO-TTYS (TELNET ETC)
device  md  # MEMORY "DISKS"
device  gif  # IPV6 AND IPV4 TUNNELING
device  faith  # IPV6-TO-IPV4 RELAYING (TRANSLATION)
device  firmware # FIRMWARE ASSIST MODULE

# THE `BPF' device ENABLES THE BERKELEY PACKET FILTER.
# BE AWARE OF THE ADMINISTRATIVE CONSEQUENCES OF ENABLING THIS!
# NOTE THAT 'BPF' IS REQUIRED FOR DHCP.
device  bpf  # BERKELEY PACKET FILTER

# USB SUPPORT
device  uhci  # UHCI PCI->USB INTERFACE
device  ohci  # OHCI PCI->USB INTERFACE
device  ehci  # EHCI PCI->USB INTERFACE (USB 2.0)
device  usb  # USB BUS (REQUIRED)
#device  udbp  # USB DOUBLE BULK PIPE deviceS
device  ugen  # GENERIC
device  uhid  # "HUMAN INTERFACE deviceS"
device  ukbd  # KEYBOARD
device  ulpt  # PRINTER
device  umass  # DISKS/MASS STORAGE - REQUIRES SCBUS AND DA
device  ums  # MOUSE
device  ural  # RALINK TECHNOLOGY RT2500USB WIRELESS NICS
device  rum  # RALINK TECHNOLOGY RT2501USB WIRELESS NICS
device  urio  # DIAMOND RIO 500 MP3 PLAYER
device  uscanner # SCANNERS
# USB ETHERNET, REQUIRES MIIBUS
device  aue  # ADMTEK USB ETHERNET
device  axe  # ASIX ELECTRONICS USB ETHERNET
device  cdce  # GENERIC USB OVER ETHERNET
device  cue  # CATC USB ETHERNET
device  kue  # KAWASAKI LSI USB ETHERNET
device  rue  # REALTEK RTL8150 USB ETHERNET

# FIREWIRE SUPPORT
device  firewire # FIREWIRE BUS CODE
device  sbp  # SCSI OVER FIREWIRE (REQUIRES SCBUS AND DA)
device  fwe  # ETHERNET OVER FIREWIRE (NON-STANDARD!)
device  fwip  # IP OVER FIREWIRE (RFC 2734,3146)
device  dcons  # DUMB CONSOLE DRIVER
device  dcons_crom # CONFIGURATION ROM FOR DCONS


#
# from PC-BSD conf
#
options  LIBICONV
options  LIBMCHAIN
options  CD9660_ICONV
options  MSDOSFS_ICONV
options  NTFS
options  NTFS_ICONV
options  UDF
options  UDF_ICONV
options  GEOM_UZIP  # read only compressed disks
# wifi
device  wlan
device  wlan_wep
device  wlan_ccmp
device  wlan_tkip
device  an
device  ath
device  ath_hal
device  ath_rate_sample
device  awi
device  ral
device  wi
device  iwi
device  ipw
device  firmware
options  DEVICE_POLLING
device  pf
device  pflog
device  pfsync
options  ALTQ
options  ALTQ_CBQ
options  ALTQ_RED
options  ALTQ_RIO
options  ALTQ_HFSC
options  ALTQ_CDNR
options  ALTQ_PRIQ
options  ALTQ_NOPCC

Monday, May 19, 2008

Adding MySQL to my OpenBSD machine

My best friend while doing all of this was the MySQL Reference Manual :-).

The hard part was the fact that this and every thing else I want setup should have been done like 6 or 7 hours ago... But that's my family for ya....



Phase I: Install and Configure the MySQL database service:


My desktop has WAMP installed and a mother load of development tools, my PC-BSD
laptop has the most complete development environment I have access to, and is
where I do all of my real work ^_^.


In order to make some progress in a few bits of playful testing and work that I
do need to tinker with, I've elected to setup things on Vectra to avoid the more
transient nature of the Windows machine here...


This is the notes I've compiled during the process. Managing to sleep off the
headache and get this done before everyone else wakes up... Grr. The machines an
OpenBSD 4.3-Release system working off an old Pentium 3 500Mhz with 384MB of RAM
-- far from ideal for running MySQL but with just me to play with it, it's no
problemo.


ssh2v
 ...
su - root
Password:

pkg_add -iv mysql-server
less /usr/local/share/doc/mysql/README.OpenBSD # refer to the instructions
given

vi /etc/login.conf
 ... # let the login class for _mysql and rebuild the login database
cap_mkdb /etc/login.conf
/usr/local/bin/mysql_install_db
 ... # initialize the database files
vi /etc/rc.mysql
 ...  # quick script to launch mysql properly, listing 2A
vi /etc/rc.local
 ...  # start it during resource configuration, listing 2B
/etc/rc.mysql
/usr/local/bin/mysql_secure_installation
 ...  # secure the installation := -u root -p (pw=V1p3l2)
mysqladmin -u root -p status
 ...
mysql -u root -p -h localhost # set up our databases using the mysql client
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 18
Server version: 5.0.51a-log OpenBSD port: mysql-server-5.0.51a

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> CREATE USER trowa IDENTIFIED BY '*********';                   
Query OK, 0 rows affected (0.03 sec)

mysql> CREATE DATABASE SpidersWeb
    -> ;
Query OK, 1 row affected (0.01 sec)

mysql> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema | 
| SpidersWeb         | 
| mysql              | 
+--------------------+
3 rows in set (0.00 sec)

mysql> GRANT ALTER, ALTER ROUTINE, CREATE, CREATE ROUTINE, DELETE, DROP,
    -> EXECUTE, INDEX, INSERT, LOCK TABLES, SELECT, CREATE VIEW, SHOW VIEW,
    -> UPDATE ON SpidersWeb.* TO 'trowa'@'%';
Query OK, 0 rows affected 
mysql> exit
Bye


That basically allows the database user to do just about everything to the
specified database from anywhere. I considered restricting access further but am
not in the mood to screw with changing it later should it become necessary (and
I hate setting up replacement routers, which happens every now and then).


Since every thing in the mysql client ends up in ~/.mysql_history, including the
password used in the CREATE USER statement. I am also rather glad that OpenBSD
keeps everyones nose out of /root by default, I plan on shredding the file:

rm -P /root/.mysql_history
for safety.



Phase II: Verify it works!

To make sure every thing works out properly enough (considering the current
local time!). I opened another urxvt on my laptop and connected to the server
machine.


Terry@dixie$ mysql -h vectra -u trowa -p SpidersWeb                        5:44
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 22
Server version: 5.0.51a-log OpenBSD port: mysql-server-5.0.51a

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> SHOW TABLES
    -> ;
Empty set (0.01 sec)

mysql> exit
Bye
Terry@dixie$                                                               5:45


Various notes


I found the kern.maxfiles sysctl and standard issue /etc/my.cnf file suitable
for my needs (for now). So no need to screw with them tonight, later on I need
to work on setting up httpd and things... Already 0600Z and work is early
tomorrow so no time to sor that out


Rather then muck about, in case I need to stop and start mysqld I moved the
startup from /etc/rc.local to calling a shell script to run it properly. That
way OpenBSD should allow mysqld sufficant file handles and I can control things
via /etc/my.cnf if I wish to lower it.



Listing 1: /etc/login.conf

#
# This class is used when running MySQL from /etc/rc.local
# XXX: It will *N_O_T* be used when starting/stopping mysqld manually!!
#
_mysql:\
        :ignorenologin:\
        :datasize=infinity:\
        :maxproc=infinity:\
        :openfiles=3580:\       # I've set this to sysctl::kern.maxfiles
        :stacksize-cur=8M:\
        :localcipher=blowfish,8:\
        :tc=daemon:

Listing 2A: /etc/rc.mysql

#!/bin/sh
#
# A simple script to launch mysqld with the proper login privledges
#

su -c _mysql root -c '/usr/local/bin/mysqld_safe >/dev/null 2>&1 &'
echo -n ' mysql

Listing 2B: edits to /etc/rc.local

# launch the MySQL database server
if [ -x /usr/local/bin/mysqld_safe -a -x /etc/rc.mysql ]; then
        /etc/rc.mysql
fi

Monday, March 3, 2008

Manually upgrading PC-BSD v1.4 to using FreeBSD 7 underneath

It can be done although I don't actually recommend it lol, I did this solely for fun. Here is what I recored in the ~/fun-log file on my Samba server. A copy of my kernel configuration and a screen shot of the first GUI enabled boot is at the end of the post:


------------------------------------------------------------------
Enabled SSH login to my test machine, since I don't use the default port 22 for SSH I had to open ssh_config and sshd_config in /etc/ssh/ and uncomment the 'Port' line and change the port number.

A quick restart of the SSH Daemon from a root shell:

/etc/rc.d/sshd restart

I also disabled the firewall (pf) since I was in no mood to sort it out or port my laptops pf.config over.

and from my own shell

ssh Terry@xxx.xxx.xxx.xxx # s/xxx\.xxx\.xxx\.xxx/server ip/g

I accepted the finger print and logged in, then ssh'd to this machine from that ssh connection doing like wise.

I'd recommend taking back ups of the system before proceeding, since this is a test machine I can skip it. I would suggest using either tar or dump in conjunction with a mounted recovery partition (or other storage device) or SSH if you have another system to use for storing the backups. Some people prefer Optical disks (cd/dvd) but I only use these for perm. backups.


rebooted with the FreeBSD 7.0-RELEASE install cd in the drive and chose the upgrade option from sysinstall. I chose to upgrade 'custom' and selected all sets except the profiled libraries and source code: every thing worked perfect except that X.Org failed to upgrade due to already installed packages, unexpected yes but no problem as I was not planning on using X until after KDE was upgraded.

Completed the upgrade and chose the 'Fixit' option in the main menu dropping to a shell on ttyv4 which I used to edit /etc/ttys and disable the start of X.Org on boot up.

Located the ttyv4 line that starts /PCBSD/bin/pdm on an xterm and change the 'on' to an 'off'. Saved the file and gave a 'reboot'.


I forgot that FreeBSD's GENERIC kernels detect my hard drives wrong because the kernel uses the ATA_STATIC_ID option. I have a SATA drive for ad0 and with ATA_STATIC_ID in the kenrel config it detects ad0 as ad4, PC-BSD's kernel builds have the 'right' option commented out to fix that so I had to manually select a root disk at boot:

ufs:ad4s3

While I could easily fix this with changing the lines in /etc/fstab that would defeat the point of merging PC-BSD's SMP Kernel configuration with FreeBSD's GENERIC kernel. Which I could have done before rebooting any way.


I Inserted my install disk and ran /usr/sbin/sysinstall, using the 'Configure' option I chose to install the source code for every thing through the distribution sets. As far as I know you need the full system source to build a kernel.


I set PACKAGEROOT and did a pkg_add of lynx so I could view the installed version of the FreeBSD handbook without reading HTML source code. I like to have access to the handbook when building a kernel so that I can check if any new notes have been made in the section on the kernel configuration file. I also did a pkg_add of the mg editor, much smaller then vim but easier for me to work with then FreeBSDs /usr/bin/vi when I wish to view two files at once.

mkdir ~/kernel-config; cd ~/kernel-config
cp /PCBSD/conf/PCBSD-SMP.i386 ./
cp /usr/src/sys/i386/conf/GENERIC ./
pkg_add -r mg
 ...
vi ~/.mg # set a few options I like for emacs

Then I used MicroGNUEmacs (mg) to merge PCBSD-SMP.i386 into GENERIC saving it as mykernel with the ^x^w command, the basics of using mgh you can find in the man page; if you choose to use mg but don't know emacs. In point of fact, I have not used emacs regularly to edit files in over 2 years!

touch ./mykernel; ln -s /root/kerne-config/mykernel /usr/src/sys/i386/conf/mykernel; mg ./mykernel
cd /usr/src
make buildkernel KERNCONF=mykernel

You know, I wish I remembered to use the -j 8 option to make... Because last time I did that on my Pentium D it only took ~45 minutes to compile a kernel on 6.1-RELEASE or so.

Build started at: Sun Mar 2 21:19:14 UTC 2008
Build finished at: Sun Mar 2 21:40:51 UTC 2008

And to top it off, when I got up to do a few chores when I got back the console 'screen saver' kicked in. Which just happened to be the PC-BSD splash screen that comes up when ever the system boots kicked in during my kernel compile. This appears to have been some thing I broke with the upgrade, unless there is a difference because my laptop uses a Beastie image for the console screen saver.


I'm standing here like WTF? Did I crash or are they joking. Sure enough the system was playing a mean joke on me haha. And I know the system shouldn't go down during a buildkernel even with what I've been 'doing' to the system without some serious problems. Right now it looks like the NIC drivers are compiling so it shouldn't take to much longer.

While I wait, I'll start merging the configuration files in /etc with those in /etc/upgrade.

A quick look to see if there are any config files from PC-BSD with pcbsd mentioned in them:

find /etc/ -type f -exec grep -ni 'pcbsd|pc-bsd' '{}' \;

Of course they are *never* so nice as to denote what files are explicitly changed from the base FreeBSD installs 8=). Used lynx to browse PC-BSD's SVN Repository online, looking at the system overlay in the 1.4 branch. I don't see any any thing here that should effect me seriously -- if any one tries this after me, check PC-BSDs SVN -> pcbsd/branches/1.4/system-overlay/etc (some thing like that) and look at the commit messages, if you see some thing that might effect you. Carefully compare the relevant files in /etc/ and /etc/upgrade unless like me, there is nothing you can seriously break that you will ever want to fix later.

There are two ways of doing this part, manual and mergemaster. If you have never done a buildworld/installworld before read the manual page for mergemaster and run it in a more user friendly mode. I usually do this any way because I use mergemaster only a few times a year at the most.

Some switches to mergemaster you might want to look up are: -a, -i, -v, -U

If you are going manually, I suggest you move the files from /etc/upgrade to /etc/ but pay special attention to files such as group and rc.local -> You don't want to be unable to login as any thing but root on your reboot now do you? Hehe.

mv /etc/upgrade /root/etc-upgrade
mergemaster -viU
 ...

I installed most files but merged several others, among them:

ssh_conf and sshd_conf I merged to keep my port settings

group I merged to keep the various groups PC-BSD has setup for HAL'd and friends as well as having my user in wheel, operator, and its own group ;-)

login.conf because I use 'blf' for the pass word format rather then the default md5. At the end of my mergemaster'ing I was happy to see that mergemaster was already a step ahead of me and promped for the login.conf database to be rebuilt for fool proof safeties sake:

*** You installed a login.conf file, so make sure that you run
    '/usr/bin/cap_mkdb /etc/login.conf'
     to rebuild your login.conf database

    Would you like to run it now? y or n [n] y
    Running /usr/bin/cap_mkdb /etc/login.conf

Some files that I chose to delete, the extra rc scripts which may have broken one of the Intel Wifi drivers. Also I decided not to install the *new* printcap file -> which if I had installed would have overwritten any printer setup I have done on my test machine.

One nice advantage is I have PC-BSD's kernel stored in /boot/kernel.prev from the FreeBSD upgrade proceedure and the GENERIC FreeBSD 7.0-RELEASE kernel in /boot/kernel.old after installing my newly compiled custom kernel.

For extra safety, I'll archive these in roots home directory with more normal names in case I need them later:

tar -cf - /boot/kernel.old | bzip2 -9 > /root/kernel-FreeBSD7.0-RELEASE.g
eneric.tar.bz2
tar -cf - /boot/kernel.prev | bzip2 -9 > /root/kernel-PCBSD1.4.2.smp.tar.
bz

I don't know how to get BSD tar to adjust the compression level for gzip/bzip2 (-z,-j), assuming there is a switch for it. So I redirected tar's output to bzip2 directly to enable maximum compression.


Sadly, on reboot my system would lock up when ever the kernel tried to probe /dev/da3. No matter how many times I try to boot it, it locks up on this. I booted the Windows XP installation on the machine, rebooted into PC-BSD again and it boots perfectly -- This is a *standing* issue with this test machine.


Often FreeBSD will lock up during boot while probing my (internal) USB Card Reader when it gets to the memory stick slot and refuse to boot until I have booted another operating system on the machine. I have had this problem since FreeBSD 6.0-RELEASE, never tried any earlier ones.


Yes I hate this computer.




But otherwise my system however works bloody perfect :-)

pcbsd# uname -ai
FreeBSD pcbsd 7.0-RELEASE FreeBSD 7.0-RELEASE #0: Sun Mar 2 16:27:13 EST 2008
root@pcbsd:/usr/obj/usr/src/sys/mykernel i386 TERRYP


Now to get X.Org and KDE back online, installed the ports tree from the FreeBSD 7.0-RELEASE CD-ROM, new enough for my needs. While that goes, lets back up a few things of interest:

tar -czf /root/old-ports.tgz /usr/local/etc /usr/local/share/{icons,config,config.kcfg,apps,applnk}
tar -cjf /root/linux-fc4.tar.bz2  /compat

These files are essentially our KDE icons and a few directories we might want to keep handy for later. Also I chose to backup the /compat directory that houses the linux files.

Now for the portupgrade business:

After telling the pkgdb what to do with it self, I checked the help and gave this a go after I got tired of the interactive:

pkgdb -fFi

The one thing I hate about dealing with portupgrade and friends on FreeBSD is the packages database -- it's a royal pain in the arse to deal with when you are not in the mood! After sorting out all of the crap that pkgdb had to shout at including the mother ****ing **** load of fonts mentioned in the sale dependencies I know I will __never__ do this again.


In fact, if I ever go back to maintaining a standard FreeBSD system for my workstation I'll do this my way -- use a list of programs needed, and do upgrades with out mucking with pkgdb and it's friends lol -> less trouble I think to do it by hand the way my mind is thinking of it now hehe.


Now to fetch every thing needed before we start and prefer binary packages where possible to save on some compile time. -> Warning!!! Not my reccomendation, done here out of my lack of concern for breaking the test machine.

portupgrade -FDParR

Now to upgrade every thing preferring packages, go to splitsvile and read the log later.

portupgrade --batch -faPrR --results-file /root/portupgrade.log


Whether -a impiles -rR or not I don't know, never really read the source code that much but I'm used to using all three switches at once for this. Portupgrade also crashed about 3 times during the installation, mostly from upgrading ruby and missing stuff in /tmp. It also fragged /var/db/pkg/pkgdb.db once or twice and shouted at /usr/ports/INDEX-7.db's format. So I had to run the command several times taking about a day and a half to complete the entire operation as described here.


Now I remember why I don't use portupgrade or mass software upgrades a lot on my stable machines.

I had to create a new xorg.conf so I did an

X -configure
X -config /root/xorg.conf.new

and it worked, a reboot and I was soon greated by KDE 3.5.8 running on X.Org 7.3 ;-)


I know I broke the PBReg program so I would expect most other custom programs that PC-BSD has needs a recompile from the source code. I also used as many packages as possible during the upgrade procedure to save time, not what I normally do on FreeBSD but it actually worked well enough. Tomorrow after work I'll test out a few of the PC-BSD programs and the Firefox PBI I have installed on the test machine, and installing a PBI to see if any thing survived without a recompile needed. I also want to test the Linux ABI's new abilities and see what happens when installing linux-flock binaries.

------------------------------------------

Screen shot:

Free Image Hosting at www.ImageShack.us


Here is a copy of my kernel configuration:

# My PC-BSD v1.4.2 + FreeBSD 7.0-RELEASE kernel configuration

cpu  I686_CPU
ident  TERRYP

# To statically compile in device wiring instead of /boot/device.hints
#hints  "GENERIC.hints"  # Default places to look for devices.

makeoptions DEBUG=-g  # Build kernel with gdb(1) debug symbols

#options  SCHED_4BSD  # 4BSD scheduler
options  SCHED_ULE  # ULE scheduler instead ;-)

# options from PC-BSD that I'll keep handy
options  LIBICONV
options  LIBMCHAIN
options  CD9660_ICONV
options  MSDOSFS_ICONV
options  NTFS
options  NTFS_ICONV
options  UDF
options  UDF_ICONV
options  GEOM_UZIP
options  DEVICE_POLLING
device  iwi  # intel wireless adapters
device  ipw  # intel wireless adapters

#### I want to use PF.
device  pf
device  pflog
device  pfsync

options  ALTQ
options  ALTQ_CBQ
options  ALTQ_RED
options  ALTQ_RIO
options  ALTQ_HFSC
options  ALTQ_CDNR
options  ALTQ_PRIQ
options  ALTQ_NOPCC

# Memory card drivers I want to test:
device  mmc
device  mmcsd

# options in GENERIC
options  INET   # InterNETworking
options  INET6   # IPv6 communications protocols
options  SCTP   # Stream Control Transmission Protocol
options  FFS   # Berkeley Fast Filesystem
options  SOFTUPDATES  # Enable FFS soft updates support
options  UFS_ACL   # Support for access control lists
options  UFS_DIRHASH  # Improve performance on big directories
options  UFS_GJOURNAL  # Enable gjournal-based UFS journaling
options  MD_ROOT   # MD is a potential root device
options  NFSCLIENT  # Network Filesystem Client
options  NFSSERVER  # Network Filesystem Server
options  NFS_ROOT  # NFS usable as /, requires NFSCLIENT
options  MSDOSFS   # MSDOS Filesystem
options  CD9660   # ISO 9660 Filesystem
options  PROCFS   # Process filesystem (requires PSEUDOFS)
options  PSEUDOFS  # Pseudo-filesystem framework
options  GEOM_PART_GPT  # GUID Partition Tables.
options  GEOM_LABEL  # Provides labelization
options  COMPAT_43TTY  # BSD 4.3 TTY compat [KEEP THIS!]
options  COMPAT_FREEBSD4  # Compatible with FreeBSD4
options  COMPAT_FREEBSD5  # Compatible with FreeBSD5
options  COMPAT_FREEBSD6  # Compatible with FreeBSD6
options  SCSI_DELAY=5000  # Delay (in ms) before probing SCSI
options  KTRACE   # ktrace(1) support
options  SYSVSHM   # SYSV-style shared memory
options  SYSVMSG   # SYSV-style message queues
options  SYSVSEM   # SYSV-style semaphores
options  _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions
options  KBD_INSTALL_CDEV # install a CDEV entry in /dev
options  ADAPTIVE_GIANT  # Giant mutex is adaptive.
options  STOP_NMI  # Stop CPUS using NMI instead of IPI
options  AUDIT   # Security event auditing

# To make an SMP kernel, the next two lines are needed
options  SMP   # Symmetric MultiProcessor Kernel
device  apic   # I/O APIC

# CPU frequency control
device  cpufreq

# Bus support.
device  eisa
device  pci

# Floppy drives
device  fdc

# ATA and ATAPI devices
device  ata
device  atadisk  # ATA disk drives
device  ataraid  # ATA RAID drives
device  atapicd  # ATAPI CDROM drives
device  atapifd  # ATAPI floppy drives
device  atapist  # ATAPI tape drives
#### XXX:
####       This option must be commented out for SATA drives to be
####       detected properly, e.g. ad0 not ad4 on boot up!
#options  ATA_STATIC_ID # Static device numbering

# SCSI Controllers
device  ahb  # EISA AHA1742 family
device  ahc  # AHA2940 and onboard AIC7xxx devices
options  AHC_REG_PRETTY_PRINT # Print register bitfields in debug
     # output.  Adds ~128k to driver.
device  ahd  # AHA39320/29320 and onboard AIC79xx devices
options  AHD_REG_PRETTY_PRINT # Print register bitfields in debug
     # output.  Adds ~215k to driver.
device  amd  # AMD 53C974 (Tekram DC-390(T))
device  hptiop  # Highpoint RocketRaid 3xxx series
device  isp  # Qlogic family
#device  ispfw  # Firmware for QLogic HBAs- normally a module
device  mpt  # LSI-Logic MPT-Fusion
#device  ncr  # NCR/Symbios Logic
device  sym  # NCR/Symbios Logic (newer chipsets + those of `ncr')
device  trm  # Tekram DC395U/UW/F DC315U adapters

device  adv  # Advansys SCSI adapters
device  adw  # Advansys wide SCSI adapters
device  aha  # Adaptec 154x SCSI adapters
device  aic  # Adaptec 15[012]x SCSI adapters, AIC-6[23]60.
device  bt  # Buslogic/Mylex MultiMaster SCSI adapters

device  ncv  # NCR 53C500
device  nsp  # Workbit Ninja SCSI-3
device  stg  # TMC 18C30/18C50

# SCSI peripherals
device  scbus  # SCSI bus (required for SCSI)
device  ch  # SCSI media changers
device  da  # Direct Access (disks)
device  sa  # Sequential Access (tape etc)
device  cd  # CD
device  pass  # Passthrough device (direct SCSI access)
device  ses  # SCSI Environmental Services (and SAF-TE)

# RAID controllers interfaced to the SCSI subsystem
device  amr  # AMI MegaRAID
device  arcmsr  # Areca SATA II RAID
device  asr  # DPT SmartRAID V, VI and Adaptec SCSI RAID
device  ciss  # Compaq Smart RAID 5*
device  dpt  # DPT Smartcache III, IV - See NOTES for options
device  hptmv  # Highpoint RocketRAID 182x
device  hptrr  # Highpoint RocketRAID 17xx, 22xx, 23xx, 25xx
device  iir  # Intel Integrated RAID
device  ips  # IBM (Adaptec) ServeRAID
device  mly  # Mylex AcceleRAID/eXtremeRAID
device  twa  # 3ware 9000 series PATA/SATA RAID

# RAID controllers
device  aac  # Adaptec FSA RAID
device  aacp  # SCSI passthrough for aac (requires CAM)
device  ida  # Compaq Smart RAID
device  mfi  # LSI MegaRAID SAS
device  mlx  # Mylex DAC960 family
device  pst  # Promise Supertrak SX6000
device  twe  # 3ware ATA RAID

# atkbdc0 controls both the keyboard and the PS/2 mouse
device  atkbdc  # AT keyboard controller
device  atkbd  # AT keyboard
device  psm  # PS/2 mouse

device  kbdmux  # keyboard multiplexer

device  vga  # VGA video card driver

device  splash  # Splash screen and screen saver support

# syscons is the default console driver, resembling an SCO console
device  sc

device  agp  # support several AGP chipsets

# Power management support (see NOTES for more options)
#device  apm
# Add suspend/resume support for the i8254.
device  pmtimer

# PCCARD (PCMCIA) support
# PCMCIA and cardbus bridge support
device  cbb  # cardbus (yenta) bridge
device  pccard  # PC Card (16-bit) bus
device  cardbus  # CardBus (32-bit) bus

# Serial (COM) ports
device  sio  # 8250, 16[45]50 based serial ports
device  uart  # Generic UART driver

# Parallel port
device  ppc
device  ppbus  # Parallel port bus (required)
device  lpt  # Printer
device  plip  # TCP/IP over parallel
device  ppi  # Parallel port interface device
#device  vpo  # Requires scbus and da

# If you've got a "dumb" serial or parallel PCI card that is
# supported by the puc(4) glue driver, uncomment the following
# line to enable it (connects to sio, uart and/or ppc drivers):
#device  puc

# PCI Ethernet NICs.
device  de  # DEC/Intel DC21x4x (``Tulip'')
device  em  # Intel PRO/1000 adapter Gigabit Ethernet Card
device  ixgb  # Intel PRO/10GbE Ethernet Card
device  le  # AMD Am7900 LANCE and Am79C9xx PCnet
device  txp  # 3Com 3cR990 (``Typhoon'')
device  vx  # 3Com 3c590, 3c595 (``Vortex'')

# PCI Ethernet NICs that use the common MII bus controller code.
# NOTE: Be sure to keep the 'device miibus' line in order to use these NICs!
device  miibus  # MII bus support
device  bce  # Broadcom BCM5706/BCM5708 Gigabit Ethernet
device  bfe  # Broadcom BCM440x 10/100 Ethernet
device  bge  # Broadcom BCM570xx Gigabit Ethernet
device  dc  # DEC/Intel 21143 and various workalikes
device  fxp  # Intel EtherExpress PRO/100B (82557, 82558)
device  lge  # Level 1 LXT1001 gigabit Ethernet
device  msk  # Marvell/SysKonnect Yukon II Gigabit Ethernet
device  nfe  # nVidia nForce MCP on-board Ethernet
device  nge  # NatSemi DP83820 gigabit Ethernet
#device  nve  # nVidia nForce MCP on-board Ethernet Networking
device  pcn  # AMD Am79C97x PCI 10/100 (precedence over 'le')
device  re  # RealTek 8139C+/8169/8169S/8110S
device  rl  # RealTek 8129/8139
device  sf  # Adaptec AIC-6915 (``Starfire'')
device  sis  # Silicon Integrated Systems SiS 900/SiS 7016
device  sk  # SysKonnect SK-984x & SK-982x gigabit Ethernet
device  ste  # Sundance ST201 (D-Link DFE-550TX)
device  stge  # Sundance/Tamarack TC9021 gigabit Ethernet
device  ti  # Alteon Networks Tigon I/II gigabit Ethernet
device  tl  # Texas Instruments ThunderLAN
device  tx  # SMC EtherPower II (83c170 ``EPIC'')
device  vge  # VIA VT612x gigabit Ethernet
device  vr  # VIA Rhine, Rhine II
device  wb  # Winbond W89C840F
device  xl  # 3Com 3c90x (``Boomerang'', ``Cyclone'')

# ISA Ethernet NICs.  pccard NICs included.
device  cs  # Crystal Semiconductor CS89x0 NIC
# 'device ed' requires 'device miibus'
device  ed  # NE[12]000, SMC Ultra, 3c503, DS8390 cards
device  ex  # Intel EtherExpress Pro/10 and Pro/10+
device  ep  # Etherlink III based cards
device  fe  # Fujitsu MB8696x based cards
device  ie  # EtherExpress 8/16, 3C507, StarLAN 10 etc.
device  sn  # SMC's 9000 series of Ethernet chips
device  xe  # Xircom pccard Ethernet

# Wireless NIC cards
device  wlan  # 802.11 support
device  wlan_wep # 802.11 WEP support
device  wlan_ccmp # 802.11 CCMP support
device  wlan_tkip # 802.11 TKIP support
device  wlan_amrr # AMRR transmit rate control algorithm
device  wlan_scan_ap # 802.11 AP mode scanning
device  wlan_scan_sta # 802.11 STA mode scanning
device  an  # Aironet 4500/4800 802.11 wireless NICs.
device  ath  # Atheros pci/cardbus NIC's
device  ath_hal  # Atheros HAL (Hardware Access Layer)
device  ath_rate_sample # SampleRate tx rate control for ath
device  awi  # BayStack 660 and others
device  ral  # Ralink Technology RT2500 wireless NICs.
device  wi  # WaveLAN/Intersil/Symbol 802.11 wireless NICs.
#device  wl  # Older non 802.11 Wavelan wireless NIC.

# Pseudo devices.
device  loop  # Network loopback
device  random  # Entropy device
device  ether  # Ethernet support
device  sl  # Kernel SLIP
device  ppp  # Kernel PPP
device  tun  # Packet tunnel.
device  pty  # Pseudo-ttys (telnet etc)
device  md  # Memory "disks"
device  gif  # IPv6 and IPv4 tunneling
device  faith  # IPv6-to-IPv4 relaying (translation)
device  firmware # firmware assist module

# The `bpf' device enables the Berkeley Packet Filter.
# Be aware of the administrative consequences of enabling this!
# Note that 'bpf' is required for DHCP.
device  bpf  # Berkeley packet filter

# USB support
device  uhci  # UHCI PCI->USB interface
device  ohci  # OHCI PCI->USB interface
device  ehci  # EHCI PCI->USB interface (USB 2.0)
device  usb  # USB Bus (required)
#device  udbp  # USB Double Bulk Pipe devices
device  ugen  # Generic
device  uhid  # "Human Interface Devices"
device  ukbd  # Keyboard
device  ulpt  # Printer
device  umass  # Disks/Mass storage - Requires scbus and da
device  ums  # Mouse
device  ural  # Ralink Technology RT2500USB wireless NICs
device  rum  # Ralink Technology RT2501USB wireless NICs
device  urio  # Diamond Rio 500 MP3 player
device  uscanner # Scanners

# USB Ethernet, requires miibus
device  aue  # ADMtek USB Ethernet
device  axe  # ASIX Electronics USB Ethernet
device  cdce  # Generic USB over Ethernet
device  cue  # CATC USB Ethernet
device  kue  # Kawasaki LSI USB Ethernet
device  rue  # RealTek RTL8150 USB Ethernet

# FireWire support
device  firewire # FireWire bus code
device  sbp  # SCSI over FireWire (Requires scbus and da)
device  fwe  # Ethernet over FireWire (non-standard!)
device  fwip  # IP over FireWire (RFC 2734,3146)
device  dcons  # Dumb console driver
device  dcons_crom # Configuration ROM for dcons

Friday, February 22, 2008

Creating Firefox searchplugins for any site - including Qt !

You know, Firefox and friends have a nice search system but there are so many websites that just don't have a canned search plugin you can install like the Wikipedia and Google ones. Because I use Qt and Python for most work on Neo Ports Manager I tend to RTFM a lot and one of the things I truly love about using KDE's Konqueror webbrowser is I can go to the address bar and

qt3: someclass

and it will take me there, in fact I have it setup in Flock at the moment to use qt3, qt4 e.t.c as keywords to take me to the index. The thing is, I would like to search, after all there is a bloody search bar !


I tried looking online on how to make one but didn't find any thing helpful, I think the stuff was written for Firefox 1.x so to heck with it. I opened profile and looked for where the search scripts were located. My laptop and desktop use Flock as the default web browser but the only difference this should make here is that my profile is stored in ~/.flock instead of ~/.mozila/*

The searchplugins are in your user profile, for me with flock it is:

/home/Terry/.flock/browser/t247gnll.default/searchplugin

On Windows the profile goes in your %UserProfile%\Application Data\ in a folder such as mozilla\firefox\profile-name or flock\browser\profilename depending on the browser you are using. Don't have a Mac so dunno where it goes on there but thats why there is a FAQ online ;-)


In here are several XML files,

Terry@dixie$ ls                                                            7:25
dictcc.xml         gmail.xml          qt3.xml            youtube.xml
dictionarycom.xml  photobucket.xml    weathercom.xml
Terry@dixie$                                                               7:26

Each one is a search plugin in the search bar in the top right of my browser, qt3.xml is a file of my own creation.


If you are like me, when you are surfing the fine web you occasionally look at the URL's of the web pages you visit, since I spend alot of time looking around at the Qt documentation I know that the documentation for each class is stored as ClassName.html in a specific folder on trolltechs web servers. This means if you can find out how your favorite website stores it's files you can create a search plugin for nearly any website on the world wide web !!!!


I opened the dictcc.xml file to see how it is done, so simple it is easy as pie. And unlike Operas easy way of doing it in the GUI, we can set an ICON to use in the search bar :-)

Qt class docs are in http://doc.trolltech.com/major-version.minor-version/classname.html so we want the text we type in the search bar to be replace the classname part of the URL with out search text, we do that with a little string interpolation.



        Qt Toolkit
        Qt3 - Search all classes
        UTF-8
        data:image/x-icon;base64,
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAABtUlEQVQokY2Rv0sbYRjHv+97d1zu
8gtzwauGGmgjXU+hpaVCMlUMDnZox4IS/AvcCg4Obv4HLZk6dNLFJJ3SQoYkpSTQVUMj8Vf10KaX
O+Jd7u2QkHha0O/4PJ8Pz/PwkE8/XuB+cWwGBv6eNIAri7nuLeG4Yde/WidNGwxqXNBS0uRjod+S
QxQAGa7EXOSz7Uquw9jIJwRP5+V0JkzpoDKakM+2y7sdUSJzS4HEjAiC/Vq3tGNUCyaAxdVwH6PD
TSq5jiiRzKaSfBOIJYSwwkVjfGZT8cn0+xfzcM/2CPVvFmN4uRRQ4wIA49LNruufty7OWr25137G
UC+aHuH0lw0goYlD+qzljKncwyfC9IwI4PTA8QiDE6/Rnuq1DI5W40Lj59VevTs+xetHTmSCo5Sc
HzrZdX161gdAneI9E7SURAhKO0bkAfd2bWxlQ1neUKIxXj/ulXc7hEBLyR5h4pHwbMHftdiH9/p5
yzEu3b8Xvf72AHwBGowMyNHjXBf5j3+qBfPG46QgNdvu87Q/nQl5hH6O9u1a0frdtAGMx3ktKYei
XGnbePUuyPHkP8KdoXcj3vwDRIGtlNEJQYAAAAAASUVORK5CYII=
        


  


I saw that icons were encoded in Base64 much like with E-Mail attachments by looking at the dictcc.xml file so I wanted to include an icon for my qt3.xml search plug.


So I went to trolltechs website, downloaded their logo, opened it in kolourpaint and resize/scale'ed it down to 16x16. I then searched for a base64 encoder/decoder that could handle more then plain text, because opening an image file in a text editor to copy/paste is a pain in the neck. I consider this fair-use of the logo, if Trolltech doesn't they can write me a search plugin ^_^.

I copy and pasted the encoded form of the icon into the file as you can see above and volia we have a search plugin muhauahauha ! Then saved the file, restarted flock, wrote "QLineEdit" in the search bar without qoutes and clicked the 'Qt Toolkit' entry and flock opened a new tab with the QLineEdit class documentation for Qt3.3 ;-).


In a few minutes I will make a Qt4 one and change the ShortNames accordingly. With a little attention to detail this means a search plugin can be created by most any user for most any website. In fact with a little work I could probably set it up so I could search the [SAS] or PC-BSD forums this way, either through the search functions ability to look for topics posted or by thread #'s to go straight to a thread (which would not be fun to have to search by!).

I wonder if with a little poking around at the Open Search and XML specifications if I could have the searchTerms passed on to a perl script to do a a few tricks and pass it back in... I should look at that option some day hehe.


I love it when people make it so you can plug into an application without having to compile crap !

Tuesday, February 13, 2007

SSMTP/Getmail how-to part III

back to part II

The getmail documentation said that was the best way to automate it, and its bloody better then buling up getmail with 'daemon mode' code. But also like the documentation said if we want to 'stop' this daemon like mail checking we need a script for cron to run getmail through and program it to not run getmail if a file is pressent. Now we can do this many ways, heck we could set a enviroment variable if we want.

I've written a little script that can be run with a users cron jobs and skip over all mail or only the given account. You need one rcfile per account and you can tweak it to follow any conventions you want. My RCFiles follow the convention of getmailrc-shortaccountname, hence getmailrc-bell and getmailrc-sas for my bellsouth and sasclan accounts. This script should work on any system that has a bourneshell compatible /bin/sh. Just edit the shebang if you need to run it as another shell (such as /bin/ksh).

#!/bin/sh

# Use getmail to check my E-Mail account using the RC variable
# This script has the advantage that one can save it as another file, change
# one variable and set a cron job to check each account at different times (1
# cron job per script). Then not only use a file in their .getmail folder to
# stop all the scripts from running getmail or use a file to stop one script
# from checking its account. It also keeps a log which will be trimmed by
# another script

# Name of the getmailrc file to use
RC=getmailrc-sas

# log to a file when mail is checked
LOGFILE=${HOME}/.getmail/cronjobs.log

#
# If a nomail or nocheck file is found in ~/.getmail/ exit without checking
# else look for a no file. Where  is equal to every thing that
# comes after the getmailrc- in $RC. If none of these files exsist check mail
# using the $RC file.
#
if [ -e ${HOME}/.getmail/nomail ]
then
        LOG=$(echo "Skipping mail for $RC")
        exit 1
elif [ -e ${HOME}/.getmail/nocheck ]
then
        LOG=$(echo "Skipping mail for $RC")
        exit 1
else
        DIE=$(ls ${HOME}/.getmail| grep $RC | cut -d '-' -f 2)
        if [ -e ${HOME}/.getmail/no${DIE} ]
        then
                LOG=$(echo "You have desided not to check this mailbox - $DIE")
        else
                LOG=$(echo `date` "checked mailbox with $RC")
                getmail -r$RC
        fi
fi

# Update log with the result
echo $LOG >> $LOGFILE 2> /dev/null

if you want to use the script copy and paste it into a text file and mark it executible. I saved them as ~/.getmail/check-.sh and chmod'd them 0700

Ok, let us make a cron job, because this is allready a big long post that took me forever to write with the way my house is. I'm not detailing cron(8) so please read the handbook or read the fine manual.

I created this crontab file to run my scripts to check my accounts every 5 and 4 hours respecfully and to 'trim' my log file every week.

# rstf's crontab
SHELL=/bin/sh
PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin
HOME=/usr/home/rstf/
MAILTO=""
#
#minute hour    mday    month   wday    who     command
#
# check sas every 5hr
5     *       *       *       *       rstf    ${HOME}/.getmail/check-sas.sh
#
# check bell every 4hr
4     *       *       *       *       rstf    ${HOME}/.getmail/check-bell.sh
#
# trim log @weekly
0     0       *       *       0       rstf    ${HOME}/sh/trim-getmail-cronlog
#

The trim-getmail-cronlog script is thus

#!/bin/sh

# Rotate my logfile for running get mail via cron

LOGFILE=${HOME}/.getmail/cronjobs.log
TMPDIR=/tmp/

if [ -e $LOGFILE ]
then
        tail $LOGFILE > $TMPDIR/gmlog.$$
        rm $LOGFILE
        mv $TMPDIR/gmlog.$$ $LOGFILE
else
        exit 1
fi

To load my crontab file into crons system i.e. /var/run/tabs/${USER} all I have to do is run a simple command.

crontab ~/rstf-contrab

SSMTP/Getmail how-to part II

Back to Part I

It should've taken like two minutes to install or so. The getmail program is very nice and it follows the concept of do one ting and do it well + allows for a great level of modularity. We can use it with a number of protocols and other softwares like procmail, spamasassion, clamav e.t.c.

Setting up getmail is very easy and theres great documentation so far I've been very happy with it. Lets go to our home directory, we do *not* want to be the root user for this.

I'm gong to use a console because thats how i like it, so I'll short how to do it via that way. If you want to use a GUI app like Konqueror to do it be my guest, you should be able to easy enough.

Make a directory your home directory called .getmail and set the permissions so that only you have access.

mkdir -m 0700 ~/.getmail That ammounts to the owner having read, write, and execute but no one else but the root user being able to enter the directory. Lets cd over to our ~/.getmail folder and create a rc file. By default getmail reads the ${HOME}/.getmail/getmailrc file but we can create multiple rc files and have getmail use the one we choose.

getmail -rRCFILENAME

if its not in our .getmail/ folder we need to supply the path to the rc file, if its in .getmail we can skip it.

The syntax of the file reminds me alot of .ini files on Win32, to be perfectly honest the getmailrc file syntax is the easist I've seen. Heres a copy of one of the RC files I use complete with anotations of what the ooptions do. After this I'll go into more detail about the options to help you get a owrking rc file.

[retriever]
# This file is getmailrc-sas which is for checking my @sasclan.org account
type = SimplePOP3SSLRetriever
server = mail.host.tld
username = my_emailaddr@sasclan.org
password = My_Password

[destination]

# This destination is just for my e-mail not the systems local mboxes.
type = Maildir 
path = ~/Mail/
user = rstf
filemode = 0600

[options]
# Note that '0' means disable for all integar values.

# (int) 0-warn/err only, 1-retriv/delete only, 2-every thing
verbose = 1
# (bool) true = fetch all, false = only what getmail has not seen before
read_all = true
# (bool) true = delete messages after downloading, will override delete_after
delete = true
# (int) delete messages from server after int days
#delete_after = 1
# (int) max server reported message *total* size to download per session
max_bytes_per_session = 0
# (int) do not retreve messsages larger then this number of bytes
max_message_size = 0
# (int) max number of messages to process
max_messages_per_session = 0
# (bool) adds Delivered-To: header field to the message.
delivered_to = true
# (bool) add received: header field to the message
received = true
# (str) log to file
#message_log
# (bool) use system logger
message_log_syslog = false

as a reminder so I wouldn't have to check the documentation in /usr/local/share/doc/getmail/ or online. I put comment notes in the file briefing discribing what each option does and the type of setting, namely bool (i.e. true/false), int(eger) i.e. 0 1 or 435 e.t.c., or str(ing) likethis. Basically you need to have a [retriever] and a [destination] section. Under retriever we tell getmail what type of protocol to use, taken from the documentation heres the options.


  • SimplePOP3Retriever
    — for single-user POP3 mail accounts.

  • BrokenUIDLPOP3Retriever
    — for broken POP3 servers that do not support the
    UIDL
    command, or which do not uniquely identify messages; this provides basic
    support for single-user POP3 mail accounts on such servers.

  • SimpleIMAPRetriever
    — for single-user IMAP mail accounts.

  • SimplePOP3SSLRetriever
    — same as SimplePOP3Retriever, but uses SSL encryption.

  • BrokenUIDLPOP3SSLRetriever
    — same as BrokenUIDLPOP3Retriever, but uses SSL encryption.

  • SimpleIMAPSSLRetriever
    — same as SimpleIMAPRetriever, but uses SSL encryption.

  • MultidropPOP3Retriever
    — for domain mailbox (multidrop) POP3 mail accounts.

  • MultidropPOP3SSLRetriever
    — same as MultidropPOP3Retriever, but uses SSL encryption.

  • MultidropSDPSRetriever
    — for domain mailbox
    SDPS mail accounts,
    as provided by the UK ISP Demon.

  • MultidropIMAPRetriever
    — for domain mailbox (multidrop) IMAP mail accounts.

  • MultidropIMAPSSLRetriever
    — same as MultidropIMAPRetriever, but uses SSL encryption.

Odds are if you don't know what you need, its probably SimplePOP3Retriever. If you've ever set up a mail client before you should know it, your ISP or webhost should be able to tell you as well. Next we gotta tell getmail what server to fetch mail off of with the server option. If your ISP is some thing like charter, its probably mail.charter.net. I don't have charter but all the mail servers I've seen have been mail.ispname.topleveldomain lol.

We need to set the username and password so the server knows its us and which mailbox we want. Other wise it will tell us to go 'eff off.

Now we need to tell getmail what to do with our mail once it checks the incoming mail server. This is what the destination section is for. You basically have two big options here, Maildir or MBox. I've always used mboxrd since thats what Mozilla Mail&Newsgroups, Mozilla Thunderbird, and Seamonkey Mail&Newsgroups used. Plus the systems local mailboxes are mbox format as well. Theres various 'variations' of mbox and probably maildir but compatible enough for our needs I'd say. Other options for 'type' allow us to use an

External Message Delivery Agent (MDA) like procmail.
Mutilple Destinations, using multiple maildir/mbox/externMDAs e.t.c.
Mutiple message sorting
Sort mitple messages into geussed destinations
And to use qmail-local to deliver messages as instructed in the .qmail file.

The exact specifics and how to set getmail to use these features are in the manual, go read it if you want to know more. I suggest ether mbox or maildir personally.

Maildir is pretty simple there is a folder containing new, cur, and tmp directories full of e-mails. If you plan on checking e-mail often or automating it (as I do) this is probably for you. Each e-mail gets its own file in one of those directories which I personally think makes it better suited sharing messages but bad for FAT32 file systems (i.e. many small files).

We can make a mail directory like this on the command line, assuming we want ~/Mail. Or just make four directories in a GUI file manager.

mkdir -p ~/Mail/{new,cur,tmp}

You'll need to set the path to the mail directory as well to use Maildir. You can also set the user and file permissions to use. You've got to use the unix octal format, i.e. 0755 instead of u=rwx g=rx o=rw or some thing.

[destination]
type = Maildir 
path = ~/Mail/
user = rstf
filemode = 0600
Setting filemode to 0600 means only I and the root user have read-write permission to my mail.

Now if we want to use mboxrd we have to specify the type and path to the mbox file as well. The user option works here too. Also you need to consider the locktype option. It takes a string argument and you have a choice of 'lockf' which uses fcntl locking or 'flock' default as of this writing (getmail v4.7.0) is lockf.

[destination]
type = Mboxrd
path = ~/Mail/inbox
user = rstf
locktype = lockf

We can also set up filter sections to use stuff like clamav & spam assasion on our e-mail. Considering that the odds of a virus or trojan that can invect a windows machine through being ssh'd into a freebsd box that is using mutt to view mail fetched with getmail from a server that filters spam (optional /w my ISP) and scans for viruses (nice ISP). I don't blood ythink I need to filiter things through an Anti-Virus ! But if you like go read the documentation on how to set that up.

I think I'll be looking into spam assasion for my ISP account though so maybe I'll have some thing topost there.

The options section I don't think is required but I'd suggest you set your read_all and ether delete or delete_after options.

My suggestions

[options]
# fetch all mail on the server
read_all = true
# then delete it after its in our Maidir or Mboxrd destination(s)
delete = true

[options]
# fetch mail getmail has not seen before
read_all = false
# then delete old messages after 1 day
delete_after = 1

The bottom option deletes the messages you download today from your mail server (not your destination) the next time getmail checks for mail and sees that the old messages are '1' day old. Any integer number will do but not a floating point number. i.e. 4675 will work but 2.43 will not.

I have two getmail rc files one for each account
$ ls -R ~/.getmail                                             20:21
getmailrc-bell
getmailrc-sas
oldmail-mail.host.tld-110-username
oldmail-mail.host.tld-995-username
So I can run getmail and tell it which file to use so Ican deside which mailbox to check. I've made a pair of shell aliases in my shells rc file to save typing.

alias gm-bell='getmail -rgetmailrc-bell'
alias gm-sas='getmail -rgetmailrc-sas'

Ok, lets run getmail (I'll skip the alias), it will take a few seconds bu t if it takes a really long time you might want to make sure your system is configured correctly to resolve the hostnames.

rstf@Vectra$ getmail -rgetmailrc-sas                                                       20:22
getmail version 4.7.0
Copyright (C) 1998-2006 Charles Cazabon.  Licensed under the GNU GPL version 2.
SimplePOP3SSLRetriever:My_EmailAddr@sasclan.org@OurMailServer:
  0 messages retrieved, 0 skipped

Looks like I have no new mail in the account.

Ok, lets try some automation we can set cron jobs to run getmail -rRCFILE when ever we want on one or all of our files.

SSMTP/Getmail how-to part I

This is a short how to for kicking sendmail in the buttocks and setting up a micro-replacement for send-only usage on a FreeBSD (post 5.x) system. Plus using the getmail utility to check for new messages. I spent long enough screwing with it after I miss-read some documentation (fbsd handbook/ssmtp).

The goal is to be able to use utilties such as mailx, mutt, and other MUA's dependant on sendmail (or exteneral) MTA(s) and be able to check mail easy and automaticly. I assume you at least know how to setup a mail client such as Mozilla Thunderbird or Outlook Express (or can get the relivent info) and know how to edit files as root when needed.


First we have to kill sendmail. For this we need to edit the /etc/rc.conf file, since I've cleaned mine up to place various options in related 'sections' heres the relivent one from my rf.cofing. Note all the sendmail_* options at the bottom.

#########################################################################
#                               SERVICES                                #
#########################################################################


#cupsd_enable="YES"
#background_cupsd="YES"

samba_enable="YES"

ntpdate_enable="NO"
ntpd_enable="YES"
ntpd_falgs="-c /etc/ntp.conf -f /var/db/ntpd.drift"

# Completly kill sendmail
sendmail_enable="NONE"
sendmail_submit_enable="NO"
sendmail_outbound_enable="NO"
sendmail_msp_queue_enable="NO"

Save rf.config with those sendmail lines in it and we can stop sendmail from working. Sendmails probably the worlds most used Mail Transfer Agent but for a desktop we don't really need it. While its well known for its history of security problems according to some OpenBSD people, at least they still patch it. Now with sendmail gone we have two problems.

  1. Daily run messages are usually mailed to root and this might break that a tad.
  2. MUA's dependant on external MTA or utils dependant on sendmail may require configuration changes or stop working

Now to fix this we want some thing small that will allow us to send e-mail through some thing sendmail compatible'ish. I'll assume that you have ports installed or know how - so go do it and update them. Personally I try to update my ports tree every few days or just before building a port if I rarly install stuff on the machine. I also prefer cvsup/csup :-)

Ok, now that you have ports ready to go lets install some software. Open a shell (or use a GUI) to cd into /usr/ports/mail/sstmp/ so we can build it. Run the commands

make install replace clean

it shouldn't take long to install so no need to go on coffee break :-P
In case your wondering what ssmtp is heres the pkg-descr:
A secure, effective and simple way of getting mail off a system to your
mail hub. It contains no suid-binaries or other dangerous things - no mail
spool to poke around in, and no daemons running in the background. Mail is
simply forwarded to the configured mailhost. Extremely easy configuration.

WARNING: the above is all it does; it does not receive mail, expand aliases
or manage a queue. That belongs on a mail hub with a system administrator.

WWW: http://packages.debian.org/testing/mail/ssmtp.html

Basically it doesn't handle fetching or checking mail or reading it but it lets you send it. While some thing like sendmail, qmail, or postfix should at least provide send/recieve if you want to go bugger setting up a full blown mail server be my guest :-)

sSMTP is really s send-only app that tries to emulate sendmail, most of the command line options to sendmail are accepted but many are just ignored. Some MUA's can check mail for us, mutt springs to mind but I rather like using getmail so far. At first I thought I would use sendmail/fetchmail/ but I saw an app called 'getmail' in ports and checked it out. Its not as buggy as fetchmail is *said* to be, its got great documentation, and its really simple. So if your going to use getmail once ssmtp is done building start on /usr/ports/mail/getmail/ while we open another terminal to configure ssmtp while getmail compiles.

Using a shell or file manager like konqueror cd over to /usr/local/etc/ssmtp/ . We can ether use the .sample files here or create new ones from scratch. We to create a ssmtp.conf file that tells ssmtp how to send e-mail to our out going mail server. The config file syntax is a cake walk, its key=value and # for comments to end of line like many a language or file has.

# Your E-Mail _address_
root=email_username@isp.net
# Your outgoing mail server, normally the TLD is .net, .com, or .org
mailhub=mail.isp.topleveldomain
# Where mail looks like it came from, just stick in your e-mail address.
rewriteDomain=email_username@isp.net
# Your hostname, your e-mail address should be fine if your not a mail server
hostname=email_username@isp.net
# Set this to never rewrite the "From:" line (unless not given) and to
# use that address in the "from line" of the envelope.
FromLineOverride=YES

save as /usr/local/etc/ssmtp/ssmtp.config and that takes care of that. You might want to nuke sendmail or reboot of course for this to take effect. Now since we do want our daily run stuff to still work we will set up an alias so mail sent to our user account locally will actually be sent to our e-mail address. We'll do this with the revaliases file in the same directory.

This ones a little bit og a bug but its not once you figure out how. Basically the syntax is like this

your_login_name_on_this_computer:your_email_address_to_send_to:the_out_going_mailhub_to_use

# Alias e-mail to the system root account to go to my private e-mail
root:myemailaddr@myisp.tld:mail.myisp.tld
# Alias my_username to my email address so I get my cron-job reports
my_username:myemailaddr@myisp.tld:mail.myisp.tld

This way the daily run and cron e-mail messages will still work and they will be in my e-mail rather then /var/mail/${USER} where I often forget to check 8=)

I've yet to figure out how to set up ssmtp for multiple outgoing mail servers but I'll figure it out later & post it.

Ok, now lets get back to getmail