Thursday, September 24, 2009

Convert p4 cygwin commands to p4 win commands

Here’s a simple little script which allows me to use p4.exe from cygwin.  Perforce actually releases a p4.exe for cygwin, but I wanted my p4win and p4.exe to be able to use the same client spec.  This isn’t possible when one requires a root starting with “C:\” and the other requires “/cygdrive/c/”.  

 

This script works by expanding and window-izing all arguments after the p4 command.

 

Here is a series which shows the transformation.

  • p4 edit README
  • p4 edit /home/gwarner/foo/README (where foo is a symbolic link)
  • p4 edit /cygdrive/c/perforceRoot/blah/blah/blah/README
  • p4 edit C:\perforceRoot\blah\blah\blah\README

 

Ta da!

 

1.     #!/usr/bin/python

2.     import sys

3.     from subprocess import *

4.      

5.     def win32Path(path):                                                                                       path = path.replace('/cygdrive/c/','C:\\')

6.         path = path.replace('/','\\')

7.         return '"%s"' % path.strip()                                                                       

8.     if __name__ == '__main__':

9.         p4command = sys.argv[1]

10.      fullFiles = []

11.                 

12.      for file in sys.argv[2:]:

13.          fullPath = Popen(['readlink.exe -f ' + file], stdout=PIPE, shell=True).communicate()[0]

14.          fullFiles.append(win32Path(fullPath))

15.   

16.      newCommand = 'p4 %s %s' % (p4command, ' '.join(fullFiles))

17.   

18.      print newCommand

19.      check_call(newCommand, shell=True)

20.      print 'done.'

 

 

Wednesday, September 02, 2009

The Trickyness that is called xhost, xauth, and X in general

Goal: Export a display from a linux client to a RHEL x-server with xauth security

I don't cover all of the details below, but just cover some gotchas.  For some good details on xhost and xauth, see here:

Here are some things that might get in your way:

1) iptables

RHEL blocks most ports out of the box.  The iptables configuration is found here: /etc/sysconfig/iptables.  After making changes, it can be reloaded by issuing this command: "service iptables restart".  

I noticed that ssh was connecting just fine, so I copied the line allowing port 22 connections and changed it to allow port 6000 (x11) connections.  

2) xhost

To disable host checking, issue the following: "xhost +".  Warning: This opens up your system completely as well as disables xauth.

To reenable: "xhost -"

To grant a host permission: "xhost +hostname"

3) xauth

Note: for xauth to work, xhost cannot be disabled.  Also, if xhost is granting permission to your client, it won't bother to check with xauth.  Moral of the story: Enable xhost, but don't add anything to it.

To make sure xauth is being used on the x-server, issue the following: "ps aux | grep auth" and look at the output.  You should see an .Xauthority (or similar file) being referenced.

Both the client and the server must have the cookie for xauth to work.  Run "xauth" and issue the command "list" at the prompt.  On the server, things should be in terms of the server's hostname.  On the client they should also be in terms of the server's hostname.






Some errors related to the above gotchas:
No protocol specified
Xt error: Can't open display ip:0.0




Tuesday, August 25, 2009

1776

Source: 1776 p 271
"Will it not be possible": Joseph Reed to George Washington, December 22, 1776 in PGW, VII, 415

It was time something was done. Something aggressive and surprising.  Even failure would be preferable to doing nothing.

Monday, August 24, 2009

Move /var to its own (logical) partition in LVM

(all this using Oracle EL 5, aka RHEL 5...)

From memory, so there may be errors:

  1. Boot off of the installation cd using "linux rescue"
  2. Unmount all of the drives in /mnt/syslinux
    • Note: Before unmounting /mnt/syslinux itself, you must unmount all of the mountpoints within it.
  3. $ resize2fs /dev/VolGroup00/ 5G
  4. ... boot back into regular linux ...
  5. $ lvreduce -L 6GB /dev/VolGroup00 (answer yes)
  6. $ lvcreate -L 10G -n var VolGroup00
  7. ... boot back into rescue mode ...
  8. mkdir /mnt/var
  9. mkfs -t ext3 /dev/VolGroup00/var
  10. mount -t ext3 /dev/VolGroup00/var/ /mnt/var
  11. mv /mnt/syslinux/var* /mnt/var
  12. (edit fstab so that it mounts the new logical volume to /var)
  13. resize2fs /dev/VolGroup00/LogVol00 (remember how I made this 5Gb when the LV was 6GB?)
  14. reboot!

On rebooting, syslogd had a problem starting. (Running in debug mode, it would complain of "permission denied" to /var/log/secure and all other log files).  It was an SELinux problem and was remedied by relabeling the filesystem.

Wednesday, August 12, 2009

Basic .hgignore for web2py

This should do the trick!

syntax: glob
*.pyc

syntax: regexp
^errors
^languages
^sessions
^static/output
^cache
^cron

Wednesday, July 22, 2009

Restoring a USB disk

The other day, I imaged a USB disk to do a linux install.  The image was only a few hundred megabytes.  When I was done, I couldn't get the USB drive to reformat to anything other than the size of the image. (thus wasting a large portion of the disk).

Killdisk (http://www.killdisk.com/) was a tool I found that pretty much writes the usb drive with zeros.  I believe you only need to do so for a few minutes to overwrite the table which holds the partitions and then cancel it and upon reformatting it in windows, you'll discover that you've got all your space back!

Pyjamas