:wq - blog » sysadmin http://writequit.org/blog Tu fui, ego eris Mon, 22 Dec 2014 14:54:59 +0000 en-US hourly 1 http://wordpress.org/?v=4.1.5 The ZoomGo script, quickly move anywhere you want to be http://writequit.org/blog/2008/02/29/the-zoomgo-script-quickly-move-anywhere-you-want-to-be/ http://writequit.org/blog/2008/02/29/the-zoomgo-script-quickly-move-anywhere-you-want-to-be/#comments Fri, 29 Feb 2008 19:44:02 +0000 http://writequit.org/blog/?p=151 One of the most important traits of being a SysAdmin is laziness (well, not really laziness, but recognizing repetitive action and taking steps to automate it). In the effort to combat repetitive changing directories, I have written a tiny (< 100 lines) Ruby script to handle “zooming” to a particular directory.

Firstly, download the script here and put it somewhere in your path (rename it to “zg.rb”). Make sure to chmod +x it so it’s executable.

Note, 3 of the lines in the script *MAY* need to be changed, they are:

$DFDIR = "/Users/hinmanm/.zg"
$ZGCONF = $DFDIR + "/zg.conf"
$FINDCMD = "find"

Change the DFDIR entry to be where you plan on storing your ZoomGo files. Make sure you create the directory you specified, as you can see about, mine is set to ~/.zg. You shouldn’t have to change the ZGCONF file unless you want to. The FINDCMD variable is because on FreeBSD, when you install the “findutils” package, the find command is “gfind”, so change this to whatever your find command is (‘find’ should be fine for most people).

In the ~/.zg/zg.conf file (or wherever your DFDIR and ZGCONF locations are), entries are specified with a directory name, rescan time and directory name glob. The entries in my ~/.zg/zg.conf file are:

~/src:10:*
~/pcap:10:*
~/hex:10:*
~/Torrents:30:*
~/Random:60:*
~/Pictures:10:*
/Volumes/VAULT:20:*

What this means is: “look at my ~/src directory, rescan it if it’s older than 10 minutes and search for all directories (*)“, etc. I also search my pcap directory, the hex source tree directory, my Torrents and Random files and my TrueCrypt vault drive (When it’s mounted).

Next, I added the following line to my ~/.zshrc (I use ZSH, but the syntax for Bash would be almost exactly the same):

## For the "ZoomGo" ruby file
function zg () {
eval cd `zg.rb $1`
}

Yea, it’s kind of a hackish way to do it, but it works. After starting a new zsh, you should now be able to type “zg <dirname>” to use ZoomGo on a directory. For example:

~$ zg aimsnarf
Zooming directly to /Users/hinmanm/src/ruby/aimsnarf...
~/src/ruby/aimsnarf$

When you first run ZoomGo, it will rescan all the directories that you specified in the zg.conf file, saving the datafiles in the DFDIR. If the data file hasn’t been updated in the given rescan time (like 10 minutes for my ~/src directory) it will also rescan the directory and you’ll see messages like this:

rescanning ~/src...
rescanning ~/pcap...
rescanning ~/hex...

… and so on

You can also manually rescan all the directories by adding the “–rescan” flag.

Now, let’s say you have 2 directories that are both named the same thing, here’s an example when I run “zg aim”

~$ zg aim
2 directories were returned.
(1)    /Users/hinmanm/pcap/aim
(2)    /Volumes/VAULT/pcap/aim
1
~/pcap/aim$

See that? ZoomGo asks you to choose which directory to zoom to if there is more than 1 option, at the moment, it doesn’t like more than 9 directories, but hopefully I’ll fix that later

There, wasn’t that easier than typing “cd ~/pcap/aim”, now try it for a longer directory:

~$ zg nsm-console
2 directories were returned.
(1)    /Users/hinmanm/hex/hex/rawpacket-root/usr/home/analyzt/rp-NSM/nsm-console
(2)    /Users/hinmanm/hex/hex2/rawpacket-root/usr/home/analyzt/rp-NSM/nsm-console
2
~/hex/hex2/rawpacket-root/usr/home/analyzt/rp-NSM/nsm-console$

Enjoy :)

]]>
http://writequit.org/blog/2008/02/29/the-zoomgo-script-quickly-move-anywhere-you-want-to-be/feed/ 1
How to convert a non-SMP RedHat VM into a SMP RedHat VM http://writequit.org/blog/2008/01/28/how-to-convert-a-non-smp-redhat-vm-into-a-smp-redhat-vm/ http://writequit.org/blog/2008/01/28/how-to-convert-a-non-smp-redhat-vm-into-a-smp-redhat-vm/#comments Mon, 28 Jan 2008 20:04:13 +0000 http://writequit.org/blog/?p=136 Today I got an interesting request, a user needed to change his 64 bit non-SMP VM image (running RedHat 4.0) to a SMP machine, problem is, I don’t really want to have to go through reconfiguring the kernel and rebuilding it, so here’s the easy way to do it (it’s pretty simple):

  1. Power the image down
  2. Right-click and edit the settings for the VM image (if you don’t know how to do this, this article is beyond your scope)
  3. Change the CPU settings from 1 to >1 (2 or 4 or 8 or whatever you want to use) (see picture)
    changecpu
  4. Power the VM image back on
  5. Put the RedHat CD #2 in your desktop CD drive (or using the ISO), connect the disc to the VM image (see picture, note that I selected the wrong ISO, should be disc #2)
    mountisoselectiso
  6. On the vmware image, mount the cd with: mount /media/cdrom
  7. Enter the directory: cd /media/cdrom/RedHat/RPMS
  8. In my case, I’m using a 64-bit kernel, so I would use the 64-bit SMP kernel:
    [root@lava2057 RPMS]# rpm -Uvh kernel-smp-2.6.9-42.EL.x86_64.rpm
  9. Unmount the CD, dettach the CD/ISO
  10. Run up2date to make sure the new kernel you installed is up to date (chances are that it isn’t, since RedHat has pushed out a new kernel since putting out the CDs)
  11. Edit the /boot/grub/grub.conf file, mine looks something like this before changes:
    default=2
    timeout=5
    splashimage=(hd0,0)/grub/splash.xpm.gz
    hiddenmenu
    title Red Hat Enterprise Linux ES (2.6.9-67.0.1.ELsmp)
    root (hd0,0)
    kernel /vmlinuz-2.6.9-67.0.1.ELsmp ro root=LABEL=/ rhgb quiet
    initrd /initrd-2.6.9-67.0.1.ELsmp.img
    title Red Hat Enterprise Linux ES (2.6.9-42.ELsmp)
    root (hd0,0)
    kernel /vmlinuz-2.6.9-42.ELsmp ro root=LABEL=/ rhgb quiet
    initrd /initrd-2.6.9-42.ELsmp.img
    title Red Hat Enterprise Linux ES (2.6.9-67.0.1.EL)
    root (hd0,0)
    kernel /vmlinuz-2.6.9-67.0.1.EL ro root=LABEL=/ rhgb quiet
    initrd /initrd-2.6.9-67.0.1.EL.img
    title Red Hat Enterprise Linux ES (2.6.9-42.EL)
    root (hd0,0)
    kernel /vmlinuz-2.6.9-42.EL ro root=LABEL=/ rhgb quiet
    initrd /initrd-2.6.9-42.EL.img
  12. I have 4 kernels installed, the initial install 64-bit (non-SMP), the 64-bit SMP I just installed and the most recently updated versions of each of these, as you can see, the line “default=2” is still pointing to our non-SMP image. We need to use the 2.6.9-67.0.1.ELsmp kernel, so I’m going to change it to “default=0
  13. Reboot the machine
  14. After it’s rebooted, log in and check ‘uname -a‘, mine shows:
    Linux lava2057.lss.emc.com 2.6.9-67.0.1.ELsmp #1 SMP Fri Nov 30 11:57:43 EST 2007 x86_64 x86_64 x86_64 GNU/Linux

Simple eh? I know it’s not related to security, but I figured it’d be helpful to someone out there. :)

]]>
http://writequit.org/blog/2008/01/28/how-to-convert-a-non-smp-redhat-vm-into-a-smp-redhat-vm/feed/ 1