Welcome to zewaren.net. This site presents myself and mostly archives the solutions to some problems I once had.

How to get ruby's strftime to have localized dates

Not so frequently asked questions and stuff: 

Here is how to use ruby's strftime in French:

require 'date'
newv = [
{'Janvier' => 1, 'Février' => 2, 'Mars' => 3, 'Avril' => 4, 'Mai' => 5, 'Juin' => 6, 'Juillet' => 7, 'Août' => 8, 'Septembre'=> 9, 'Octobre' =>10, 'Novembre' =>11, 'Décembre' => 12},
{'Dimanche' => 0, 'Lundi' => 1, 'Mardi' => 2, 'Mercredi' => 3, 'Jeudi'=> 4, 'Vendredi' => 5, 'Samedi' => 6},
{'jan' => 1, 'fév' => 2, 'mar' => 3, 'avr' => 4, 'mai' => 5, 'juin' => 6, 'juil' => 7, 'aoû' => 8, 'sep' => 9, 'oct' =>10, 'nov' =>11, 'déc' => 12},
{'dim' => 0, 'lun' => 1, 'mar' => 2, 'mer' => 3, 'jeu' => 4, 'ven' => 5, 'sam' => 6},
[nil] + %w(Janvier Février Mars Avril Mai Juin Juillet Août Septembre Octobre Novembre Décembre),
%w(Dimanche Lundi Mardi Mercredi Jeudi Vendredi Samedi),
[nil] + %w(jan fév mar avr mai juin juil aoû sep oct nov déc),
%w(dim lun mar mer jeu ven sam)
]
Date::FRENCH_MONTHS=newv[0]
Date::FRENCH_DAYS=newv[1]
Date::FRENCH_ABBR_MONTHS=newv[2]
Date::FRENCH_ABBR_DAYS=newv[3]
Date::FRENCH_MONTHNAMES=newv[4]
Date::FRENCH_DAYNAMES=newv[5]
Date::FRENCH_ABBR_MONTHNAMES=newv[6]
Date::FRENCH_ABBR_DAYNAMES=newv[7]

class Time

  def strftime_french(format)
    format = format.dup
    format.gsub!(/%a/, Date::FRENCH_ABBR_DAYNAMES[self.wday])
    format.gsub!(/%A/, Date::FRENCH_DAYNAMES[self.wday])
    format.gsub!(/%b/, Date::FRENCH_ABBR_MONTHNAMES[self.mon])
    format.gsub!(/%B/, Date::FRENCH_MONTHNAMES[self.mon])
    self.strftime(format)
  end
end

class Date

  def strftime_french(format)
    format = format.dup
    format.gsub!(/%a/, Date::FRENCH_ABBR_DAYNAMES[self.wday])
    format.gsub!(/%A/, Date::FRENCH_DAYNAMES[self.wday])
    format.gsub!(/%b/, Date::FRENCH_ABBR_MONTHNAMES[self.mon])
    format.gsub!(/%B/, Date::FRENCH_MONTHNAMES[self.mon])
    self.strftime(format)
  end
end

I did not want to override strftime, because a lot of libraries use it, and this can lead to unexpected behavior (e.g. the imap protocol use dates like 05 Feb 2012 which would get translated as 05 Fév 2012 and trigger an error).

Boot Wester Digital's diagnostic tool "Data Lifeguard Diagnostic" using PXE

AttachmentSize
Package icon pxe-diag-westerndigital-Diag504fCD.zip506.76 KB

The system used here is a Debian Lenny.

Create the image:

You will need:

  • Data Lifeguard Diagnostic for DOS (CD)
  • FreeDOS
zwm-server:~/western# wget "ftp://ftp.ibiblio.org/pub/micro/pc-stuff/freedos/files/distributions/1.0/fdboot.img"
zwm-server:~/western# wget "http://support.wdc.com/download/dlg/Diag504fCD.iso"

Mount the FreeDOS image and the CD:

zwm-server:~/western# mkdir fdboot ourimage DiagCD
zwm-server:~/western# mount -o loop fdboot.img fdboot
zwm-server:~/western# mount -o loop Diag504fCD.iso DiagCD/

Create and mount a 2MB fat image:

zwm-server:~/western# dd if=/dev/zero of=ourimage.img bs=1M count=2
zwm-server:~/western# apt-get install dosfstools
zwm-server:~/western# mkfs.msdos ourimage.img
zwm-server:~/western# mount -o loop ourimage.img ourimage

Copy the FreeDOS files and the CD contents to the newly created image disk:

zwm-server:~/western# cp -r fdboot/* ourimage/
zwm-server:~/western# mkdir ourimage/western
zwm-server:~/western# cp -r DiagCD/* ourimage/western/

Umount eveything:

zwm-server:~/western# umount ourimage/
zwm-server:~/western# umount DiagCD/
zwm-server:~/western# umount fdboot/

Copy the boot sector from the original FreeDOS image to ours:

zwm-server:~/western# dd if=fdboot.img of=ourimage.img bs=1 count=446 seek=62 skip=62 conv=notrunc

Boot the image:

What you need:

  • pxelinux.0
  • memdisk
  • pxelinux's config file (pxelinux.cfg/default):
    DEFAULT wd_iso
    
    LABEL wd_iso
      KERNEL memdisk
      INITRD ourimage.img
    

Boot your computer, start FreeDOS and run the Wester Digital utility from the western folder.

Sources:

Boot Hitachi's drive test tool "Drive Fitness" using PXE

What you need:

How to use jails with epair with FreeBSD 9.0

Not so frequently asked questions and stuff: 

Introduction

System used:

FreeBSD testjails 9.0-RELEASE FreeBSD 9.0-RELEASE #1: Thu Jan 19 10:47:03 CET 2012     root@testjails:/usr/obj/usr/src/sys/JAILKERNEL  i386

Build and install a kernel including VIMAGE, epair and briged interfaces

Configure the kernel: (/usr/src/sys/i386/conf/JAILKERNEL)

include GENERIC

cpu             I686_CPU
ident           JAILKERNEL

# Virtual networking for jail
options         VIMAGE
device          epair
device          if_bridge

# The nullFS to mount local directory
options         NULLFS

Make and install the kernel:

cd /usr/src
make buildkernel KERNCONF=JAILKERNEL
make installkernel KERNCONF=JAILKERNEL
reboot

Create the jail's environement

mkdir /jails/somejail/
cd /usr/src
make buildworld
make installworld DESTDIR=/jails/somejail/
make distribution DESTDIR=/jails/somejail/
echo 'hostname="testjail.example.com"' >> /jails/somejail/etc/rc.conf
echo 'nameserver 8.8.8.8"' >> /jails/somejail/etc/resolv.conf
mkdir /jails/somejail/usr/ports

Start and use the jail manually

Start the jail:

# jail -c vnet name=testjail host.hostname=testjail path=/jails/somejail persist
# jls
   JID  IP Address      Hostname                      Path
     1  -               testjail                      /jails/somejail

Create the virtual ethernet cable:

# ifconfig epair0 create
epair0a
# ifconfig epair0b vnet testjail

Create the bridge:

# ifconfig bridge0 create
# ifconfig bridge0 addm em0 addm epair0a
# ifconfig bridge0 up

Configure the network on both sides:

# ifconfig em0 192.168.1.1/24
# ifconfig
em0: flags=8943 metric 0 mtu 1500
        options=98
        inet 192.168.1.1 netmask 0xffffff00 broadcast 192.168.1.255
        nd6 options=29
        media: Ethernet autoselect (1000baseT )
        status: active
epair0a: flags=8943 metric 0 mtu 1500
        options=8
        nd6 options=29
        media: Ethernet 10Gbase-T (10Gbase-T )
        status: active
bridge0: flags=8843 metric 0 mtu 1500
        nd6 options=29
        id 00:00:00:00:00:00 priority 32768 hellotime 2 fwddelay 15
        maxage 20 holdcnt 6 proto rstp maxaddr 100 timeout 1200
        root id 00:00:00:00:00:00 priority 32768 ifcost 0 port 0
        member: epair0a flags=143
                ifmaxaddr 0 port 5 priority 128 path cost 14183
        member: em0 flags=143
                ifmaxaddr 0 port 1 priority 128 path cost 20000
# jexec testjail ifconfig epair0b 192.168.1.2/24
# jexec testjail ifconfig
lo0: flags=8008 metric 0 mtu 16384
        options=3
        nd6 options=21
epair0b: flags=8843 metric 0 mtu 1500
        options=8
        inet6 fe80::c0:a4ff:fe00:60b%epair0b prefixlen 64 scopeid 0x2
        inet 192.168.1.2 netmask 0xffffff00 broadcast 192.168.1.255
        nd6 options=21
        media: Ethernet 10Gbase-T (10Gbase-T )
        status: active

Test the connection:

# jexec testjail ping -c 1 192.168.1.1
PING 192.168.1.1 (192.168.3.223): 56 data bytes
64 bytes from 192.168.1.1: icmp_seq=0 ttl=64 time=0.795 ms

--- 192.168.1.1 ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.795/0.795/0.795/0.000 ms

# jexec testjail route add default 192.168.1.250
add net default: gateway 192.168.1.250

# jexec testjail ping -c 1 example.net
PING example.net (192.0.43.10): 56 data bytes
64 bytes from 192.0.43.10: icmp_seq=0 ttl=243 time=92.568 ms

--- example.net ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 92.568/92.568/92.568/0.000 ms

Stop the jail:

# jail -r testjail
enceinte# jls
   JID  IP Address      Hostname                      Path

Clean the network:

# ifconfig epair0a destroy
# ifconfig bridge0 destroy

Start the jail automatically

As of 2011/08/01, /etc/rc.d/jail has problems using the new jail command (v2), so you must patch it if you want to use vnets:
http://www.freebsd.org/cgi/query-pr.cgi?pr=142972
Also, you need this patch to be able to put the epair interface in the jail's vnet after it is created, but before starting the jail's rc.script (via earlypoststart entries in rc.conf).

See also:
http://lists.freebsd.org/pipermail/freebsd-stable/2012-January/065556.html

My original /etc/rc.d/jail script was revision 1.47.

Here is the modified patch that worked for me:
fbsd9_rcdjail147_vnet_patch

Then, in /etc/rc.conf:

#
# Jails networking
#
cloned_interfaces="bridge0"
ifconfig_bridge0="addm em0"

#
# Jails configuration
#
jail_enable="YES"
jail_v2_enable="YES"
jail_list="testjail"

jail_testjail_name="testjail"
jail_testjail_hostname="testjail.example.net"
jail_testjail_devfs_enable="YES"
jail_testjail_rootdir="/jails/somejail"
jail_testjail_vnet_enable="YES"
jail_testjail_exec_prestart0="ifconfig epair0 create"
jail_testjail_exec_prestart1="ifconfig bridge0 addm epair0a"
jail_testjail_exec_prestart2="ifconfig epair0a up"
jail_testjail_exec_earlypoststart0="ifconfig epair0b vnet testjail"
jail_testjail_exec_afterstart0="ifconfig lo0 127.0.0.1"
jail_testjail_exec_afterstart1="ifconfig epair0b 192.168.1.2/24 up"
jail_testjail_exec_afterstart2="route add default 192.168.1.250"
jail_testjail_exec_afterstart3="/bin/sh /etc/rc"
jail_testjail_exec_poststop0="ifconfig bridge0 deletem epair0a"
jail_testjail_exec_poststop1="ifconfig epair0a destroy"

Then:

# /etc/rc.d/jail onestart testjail
Configuring jails:.
Starting jails:epair0a
add net default: gateway 192.168.1.250
Setting hostname: testjail.example.com.
Creating and/or trimming log files.
Starting syslogd.
ELF ldconfig path: /lib /usr/lib /usr/lib/compat
a.out ldconfig path: /usr/lib/aout /usr/lib/compat/aout
Clearing /tmp (X related).
Updating motd:.
Starting cron.

Thu Jan 19 11:45:24 UTC 2012
 testjail.example.net.
testjails# jls
   JID  IP Address      Hostname                      Path
     1  -               testjail.example.com          /jails/somejail
# jexec testjail ifconfig
lo0: flags=8049 metric 0 mtu 16384
        options=3
        inet 127.0.0.1 netmask 0xff000000
        inet6 ::1 prefixlen 128
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
        nd6 options=21
epair0b: flags=8843 metric 0 mtu 1500
        options=8
        inet6 fe80::c0:a4ff:fe00:70b%epair0b prefixlen 64 scopeid 0x2
        inet 192.168.1.2 netmask 0xffffff00 broadcast 192.168.1.255
        nd6 options=21
        media: Ethernet 10Gbase-T (10Gbase-T )
        status: active
# jexec testjail ping -c 1 example.net
PING example.net (192.0.43.10): 56 data bytes
64 bytes from 192.0.43.10: icmp_seq=0 ttl=243 time=92.799 ms

--- example.net ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 92.799/92.799/92.799/0.000 ms

Sources:

How to install FreeBSD 82 via PXE from anywhere (i.e. without a NFS server)

Not so frequently asked questions and stuff: 

The situation

You want to install FreeBSD on another machine. You don't want to use a NFS server, because you are either on a Windows computer or because you simply want to boot the installer using pxeboot or gpxe.

Step 1: build the FreeBSD image disk

Create some dirs:

# mkdir /tmp/build
# mkdir /tmp/build/iso.mnt
# mkdir /tmp/build/hd.mnt
# mkdir /tmp/build/mfs.mnt
# cd /tmp/build

Get the image:

# wget ftp://ftp.fr.freebsd.org/pub/FreeBSD/ISO-IMAGES-i386/8.2/FreeBSD-8.2-RELEASE-i386-bootonly.iso
--2011-12-15 09:30:41--  ftp://ftp.fr.freebsd.org/pub/FreeBSD/ISO-IMAGES-i386/8.2/FreeBSD-8.2-RELEASE-i386-bootonly.iso
           => `FreeBSD-8.2-RELEASE-i386-bootonly.iso.1'
Resolving ftp.fr.freebsd.org... 88.191.250.131
Connecting to ftp.fr.freebsd.org|88.191.250.131|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done.    ==> PWD ... done.
==> TYPE I ... done.  ==> CWD (1) /pub/FreeBSD/ISO-IMAGES-i386/8.2 ... done.
==> SIZE FreeBSD-8.2-RELEASE-i386-bootonly.iso ... 49262592
==> PASV ... done.    ==> RETR FreeBSD-8.2-RELEASE-i386-bootonly.iso ... done.
Length: 49262592 (47M) (unauthoritative)

100%[======================================>] 49,262,592  2.57M/s   in 18s

2011-12-15 09:30:59 (2.62 MB/s) - `FreeBSD-8.2-RELEASE-i386-bootonly.iso.1' saved [49262592]

Mount the image:

# mdconfig -a -t vnode -f /tmp/build/FreeBSD-8.2-RELEASE-i386-bootonly.iso
md0
# mount_cd9660 /dev/md0 /tmp/build/iso.mnt/

Create a hard disk image. Be sure to choose the right size.

# dd if=/dev/zero of=/tmp/build/FreeBSD-8.2-RELEASE-i386-bootonly.hd bs=1m count=60
60+0 records in
60+0 records out
62914560 bytes transferred in 0.737012 secs (85364374 bytes/sec)
# mdconfig -a -t vnode -f /tmp/build/FreeBSD-8.2-RELEASE-i386-bootonly.hd
md1
# fdisk -B -I /dev/md1
******* Working on device /dev/md1 *******
fdisk: invalid fdisk partition table found
fdisk: Class not found
# bsdlabel -B -w /dev/md1
# bsdlabel -e /dev/md1
# /dev/md1:
8 partitions:
#        size   offset    fstype   [fsize bsize bps/cpg]
  a:   122864       16    4.2BSD        0     0
  c:   122880        0    unused        0     0         # "raw" part, don't edit

# newfs /dev/md1a
/dev/md1a: 60.0MB (122864 sectors) block size 16384, fragment size 2048
        using 4 cylinder groups of 15.00MB, 960 blks, 1920 inodes.
super-block backups (for fsck -b #) at:
 160, 30880, 61600, 92320
# mount /dev/md1a /tmp/build/hd.mnt

Copy the boot files from the iso to the disk image:

# cp -r /tmp/build/iso.mnt/boot /tmp/build/hd.mnt/boot

Umount everything:

# umount /tmp/build/hd.mnt
# mdconfig -d -u 1
# umount /tmp/build/iso.mnt
# mdconfig -d -u 0

You now have a bootable FreeBSD installer image disk.

Step2: Boot the image disk

Download pxelinux.0.
Download memdisk. You can find it packaged with syslinux: http://www.kernel.org/pub/linux/utils/boot/syslinux/

Create pxelinux config file (pxelinux.cfg/default):

DEFAULT fbsd

LABEL fbsd
 kernel memdisk
 append initrd=/FreeBSD82.hd harddisk

Setup your DHCP and TFTP servers to serve the directory and you're good.

Sources

How to kill javaw.exe

Not so frequently asked questions and stuff: 

The situation

You have some java processes running on your system but you can't stop or kill them. You tried using the task manager and sysinternals' process explorer.

The solution

Find the PID of your java process

C:\>jps -l -v
3100 sun.tools.jps.Jps -Dapplication.home=C:\Program Files\Java\jdk1.6.0_24 -Xms 8m
2904 C:\Program -Xms40m -Xmx256m -XX:MaxPermSize=96m -DXPCOM.RUNTIME=C:\Program
Files\Texas Instruments\ccsv4\DebugServer\win32 -Dxpcom.bridge.executeOnDedicate
dThread=yes -Dorg.eclipse.swt.browser.XULRunnerPath=C:\Program Files\Texas Instrument\ccsv4\DebugServer\win32 -Dosgi.instance.area.default=file:/C:/Documents and Settings/SomeUser/Mes documents/workspace/

Here we want to kill the nasty eclipse process 2904.

Use taskkill.

C:\>taskkill /F /PID 2904
Opération réussie : le processus avec PID 2904 a été terminé.

If you don't use option /F, the command will still execute successfully but nothing will happen.

Shells and editors configuration

This is part of my shell configuration

FreeBSD

This configuration allow, when using tmux:

  • Ctrl+arrow to move around words in tcsh and zsh
  • Ctrl+arrow to move around words in vim
  • Shift+arrow to selects characters in vim
  • Ctrl+Shift+arrow to selects words in vim
  • Many other things

~/.vimrc

set nocompatible
set tabstop=4
set shiftwidth=2
set showmatch
set guioptions-=T
set vb t_vb=
set ruler
set nohls
set incsearch
set virtualedit=all
set bs=2

syntax on
colorscheme zenburn
if !empty($TMUX)
    if &term =~ 'xterm-256color'
      " Disable Background Color Erase (BCE) so that color schemes
      " work properly when Vim is used inside tmux and GNU screen.
      " See also http://snk.tuxfamily.org/log/vim-256color-bce.html
      set term=cons25
      set t_ut=
      set t_Co=256

      "Ctrl + Arrows => Move fast
      map ^[[1;5C w
      map ^[[1;5D b
      imap ^[[1;5C w
      imap ^[[1;5D b
      "Del => Delete
      map ^[[3~ x
      imap ^[[3~ x

      "Shift + Arrow => Select
      map      ^[[1;2A vk
      map      ^[[1;2B vj
      map      ^[[1;2D vh
      map      ^[[1;2C vl
      inoremap ^[[1;2A vk
      vnoremap ^[[1;2A k
      inoremap ^[[1;2B vj
      vnoremap ^[[1;2B j
      inoremap ^[[1;2C vl
      vnoremap ^[[1;2C l
      inoremap ^[[1;2D vh
      vnoremap ^[[1;2D h

      "Simple arrows in visual mode gets back to normal mode
      vnoremap ^[[C vl
      vnoremap ^[[D vh
      vnoremap ^[[A vk
      vnoremap ^[[B vj

      "Shift + Select + Arrow => Select fast
      map      ^[[1;6C vw
      map      ^[[1;6D vb
      map      ^[[1;6A vk
      map      ^[[1;6B vj
      inoremap ^[[1;6C vw
      inoremap ^[[1;6D vb
      inoremap ^[[1;6A vk
      inoremap ^[[1;6B vj
      vnoremap ^[[1;6C w
      vnoremap ^[[1;6D b
      vnoremap ^[[1;6A k
      vnoremap ^[[1;6B j

      "End, Home
      map      ^[[F $
      map      ^[[H 0
      inoremap ^[[F $
      inoremap ^[[H 0
      vnoremap ^[[F $
      vnoremap ^[[H 0
      "Ctrl + End, Home => Document Start, End
      map      ^[[1;5F G
      map      ^[[1;5H gg
      inoremap ^[[1;5F G
      inoremap ^[[1;5H gg
      vnoremap ^[[1;5F G
      vnoremap ^[[1;5H gg
      map      ^[[1;2F v$
      map      ^[[1;2H v0
      inoremap ^[[1;2F v$
      inoremap ^[[1;2H v0
      vnoremap ^[[1;2F $
      vnoremap ^[[1;2H 0

      "PgUp, PgDown
      map      ^[[5~ 
      map      ^[[6~ 

      " backspace in Visual mode deletes selection
      vnoremap ^? d

    endif
else
    if &term =~ 'xterm-256color'
        set t_Co=256
        map ^[[C w
        map ^[[D b
        imap ^[[C w
        imap ^[[D b
    endif
endif

ZenBurn Color scheme

.cshrc, relevant parts

if ( $?tcsh ) then
        bindkey "^W" backward-delete-word
        bindkey -k up history-search-backward
        bindkey -k down history-search-forward
        bindkey "^[[1;5D" backward-word
        bindkey "^[[1;5C" forward-word
endif

.zshrc, relevant parts

bindkey "^[OD" backward-word
bindkey "^[OC" forward-word
bindkey "^[[1;5C" forward-word
bindkey "^[[1;5D" backward-word
bindkey "^[[1~" beginning-of-line
bindkey "^[[4~" end-of-line
bindkey "^[[3~" delete-char

.tmux.conf, relevant parts

set -g default-terminal "xterm-256color-tmuxed-zwm"
set -g terminal-overrides "xterm*:colors=256:XT:smcup@:rmcup@:kUP5=\eOA:kDN5=\eOB:kLFT5=\eOD:kRIT5=\eOC"
set-option -gw xterm-keys on

To get the full, experience, you need to SSH to your box using Futty.

Be sure to use a version with Ctrl+Shift+Keys enabled.

See: http://code.google.com/p/futty/issues/detail?id=23

How to do a netbios name reverse lookup using samba.

Not so frequently asked questions and stuff: 

How to do a netbios name reverse lookup using samba

Use nmblookup

# nmblookup -A 10.0.9.124
Looking up status of 10.0.9.124
        ZWM-SERVER      <00> -         H <ACTIVE>
        ZWM-SERVER      <03> -         H <ACTIVE>
        ZWM-SERVER      <20> -         H <ACTIVE>
        REZID           <1e> - <GROUP> H <ACTIVE>
        REZID           <00> - <GROUP> H <ACTIVE>

        MAC Address = 00-00-00-00-00-00

If you're on debian on don't have the command, install the package named samba-common-bin:

# apt-get install samba-common-bin

Sources:

How to use bazaar through a HTTP Proxy

Not so frequently asked questions and stuff: 

Bazaar Logo

How to use bazaar through a HTTP Proxy

This will quickly explain how to use bzr trough a HTTP proxy with authentication. We want to branch AND push. This requires the plugin bzr-plugins.

Windows

Download and install the plugin

Download the plugin:

>set http_proxy = http://user:pass@proxy:port
>set https_proxy = http://user:pass@proxy:port
>bzr branch lp:bzr-webdav
You have not informed bzr of your Launchpad ID, and you must do this to
write to Launchpad or access private data.  See "bzr help launchpad-login".
Branched 73 revision(s).

Copy it to C:\Program Files (x86)\Bazaar\plugins or wherever you installed bazaar, and rename it to webdav.

>move bzr-webdav webdav
        1 dir(s) moved.

>copy webdav "c:\Program Files (x86)\Bazaar\plugins"
webdav\COPYING.txt
webdav\info.py
webdav\NOTES
webdav\setup.py
webdav\TODO
webdav\webdav.py
webdav\__init__.py
        7 file(s) copied.

Install the plugin:

>cd "c:\Program Files (x86)\Bazaar\plugins\webdav"

>python.exe setup.py install
running install
running build
running build_py
copying .\info.py -> build\lib\bzrlib\plugins\webdav
copying .\webdav.py -> build\lib\bzrlib\plugins\webdav
copying .\__init__.py -> build\lib\bzrlib\plugins\webdav
copying tests\dav_server.py -> build\lib\bzrlib\plugins\webdav\tests
copying tests\test_webdav.py -> build\lib\bzrlib\plugins\webdav\tests
copying tests\__init__.py -> build\lib\bzrlib\plugins\webdav\tests
running install_lib
running install_egg_info
Removing c:\Python27\Lib\site-packages\bzr_webdav-1.12.3-py2.7.egg-info
Writing c:\Python27\Lib\site-packages\bzr_webdav-1.12.3-py2.7.egg-info

>bzr plugins
...
webdav 1.12.3dev
  An http transport, using webdav to allow pushing.
...

Use the plugin

>set http_proxy = http://user:pass@proxy:port
>bzr push http+webdav://bzr.example.org
HTTP bzr.example.org, Realm: 'SOMEREALM' username: test
HTTP test@bzr.example.org, Realm: 'SOMEREALM' password:
Pushed up to revision 7.

Ubuntu

Download and install the plugin

Configure apt to use the proxy (if necessary):

#export http_proxy = http://user:pass@proxy:port

Add the following lines to your source.list file:

deb http://ppa.launchpad.net/bzr/daily/ubuntu lucid main 
deb-src http://ppa.launchpad.net/bzr/daily/ubuntu lucid main 

Follow the link at https://launchpad.net/~bzr/+archive/daily to get the signing key: http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xD702BF6B8C6C1EFD and save it to a file.

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: SKS 1.0.10

mI0ESXSSBgEEAKqURmlbPIQuqZJ6Gip/Y4hElzJzW8po0k3cQkT+xc7pqqa9QVKi2W2L5XzU
1gXKpzF+dZ+JcVlNQUNLFWeLhLF/Viw5zZTGW4evsEO1Vilp5VHS2YPmJBkibIlZ5UJ+qhaM
lOkf66mFglogG5GZqktPStO9shZfx2MqUK/t6RFBABEBAAG0I0xhdW5jaHBhZCBQUEEgZm9y
IEJhemFhciBEZXZlbG9wZXJziEYEEBECAAYFAkl3aasACgkQ/vSRAed+jpjzngCgu79TtIck
IwSTAuYbrrziZH7oFjwAoKrTHhu41jQKgFhiW7t88JA6LCUMiEYEEBECAAYFAknOwVsACgkQ
9rPTxuzZSv1+IACfVS9KKRtFUF4eS8tLvpVahzkSJsEAoMP3/ASzUP5sHa9pf/UMyzpoaC9H
iEYEEBECAAYFAknS5Z0ACgkQrZORep7Yx+rC1gCglr4g4riENgChBciGIenDAOFgpdUAn3FI
ghBiV+VuBYIE3UlNkc3aRUf5iEYEEBECAAYFAkp/uc0ACgkQuL+o2Md08jv3ogCglVdsjTpj
IVgZJuss2J/oNqAlqIoAoIDctdsxd0iX3tBodkz00+ZpOn/5iLYEEwECACAFAkl0kgYCGwMG
CwkIBwMCBBUCCAMEFgIDAQIeAQIXgAAKCRDXAr9rjGwe/U17A/9DhXbxAzX2czO+KypV3OSz
/p5CjdnOIUbf6LHDOoH7Bxq4a3MUBve5jPe764cjmPPqYElbrtzky9byLjatUO5gSFo2M20I
LajoYUW57is5Fu+m1Y7IHRfLonC44od9XWPvpwROQ00/fqPGHmri5/mPJiaW0N3dniYu7a23
vdaVuQ==
=6i6T
-----END PGP PUBLIC KEY BLOCK-----

Import said key:

#gpg --ignore-time-conflict --no-options --no-default-keyring --secret-keyring /etc/apt/secring.gpg --trustdb-name /etc/apt/trustdb.gpg --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --import somekey 
gpg: clé 8C6C1EFD: « Launchpad PPA for Bazaar Developers » une nouvelle signature
gpg: Quantité totale traitée: 1
gpg:         nouvelles signatures: 1
gpg: aucune clé de confiance ultime n'a été trouvée

Install bzr-webdav using the new repository (this will also fetch the latest version of bzr and bzrlib).

#apt-get update
#apt-get install bzr-webdav

Check that bzr-webdav is installed and loaded

#bzr plugins
...
webdav 1.12.2
  An http transport, using webdav to allow pushing.
...

Use bzr-webdav

# bzr branch http://bzr.example.org
HTTP bzr.example.org, Realm: 'SOMEREALM' username: test
HTTP test@bzr.example.org, Realm: 'SOMEREALM' password: 
Branched 8 revisions.                    

# #Commit something

# bzr push http+webdav://bzr.example.org
HTTP bzr.example.org, Realm: 'SOMEREALM' username: test                            
HTTP test@bzr.example.org, Realm: 'SOMEREALM' password: 
Pushed up to revision 9.   

If your proxy configuration is system wide, you can even use the explorer:
Bazaar explorer pushing trough a proxy to a webdav repository

Remember the credentials

authentication.conf:

[EXAMPLE]
scheme=http
host=bzr.example.org
path=/
user=webdav_test
password=webdav_password

Sources:

How to use jails with epair with FreeBSD 8.2

Not so frequently asked questions and stuff: 

Introduction

System used:

FreeBSD testjail.example.net 8.2-RELEASE FreeBSD 8.2-RELEASE #0: Thu Aug 11 09:10:23 CEST 2011     root@testjail.example.net:/usr/obj/usr/src/sys/JAILKERNEL  amd64

Build and install a kernel including VIMAGE, epair and briged interfaces

Configure the kernel: (/usr/src/sys/amd64/conf/JAILKERNEL)

include GENERIC

cpu             HAMMER
ident           JAILKERNEL

# Firewalling
device          pf
device          pflog

# Virtual networking for jail
options         VIMAGE
device          epair
device          if_bridge

# The nullFS to mount local directory
options         NULLFS

Make and install the kernel:

cd /usr/src
make buildkernel KERNCONF=JAILKERNEL
make installkernel KERNCONF=JAILKERNEL
reboot

Create the jail's environement

mkdir /usr/jails/testjail
cd /usr/src
make installworld DESTDIR=/usr/jails/testjail
make distribution DESTDIR=/usr/jails/testjail
echo 'hostname="testjail.example.com"' >> /usr/jails/testjail/etc/rc.conf
echo 'nameserver 8.8.8.8"' >> /usr/jails/testjail/etc/resolv.conf
mkdir /usr/jails/testjail/usr/ports

Start and use the jail manually

Start the jail:

# jail -c vnet name=testjail host.hostname=testjail path=/usr/jails/testjail persist
# jls
   JID  IP Address      Hostname                      Path
      1  -                      testjail                               /usr/jails/testjail

Create the virtual ethernet cable:

# ifconfig epair0 create
epair0a
# ifconfig epair0b vnet 1

Create the bridge:

# ifconfig bridge create
bridge0
# ifconfig bridge0 addm epair0a addm bge0

Configure the network on both sides:

# ifconfig bge0 192.168.1.10/24
# ifconfig epair0a 192.168.1.11/24
# jexec testjail ifconfig epair0a 192.168.1.12/24
# jexec testjail ifconfig
lo0: flags=8008 metric 0 mtu 16384
        options=3
epair0b: flags=8843 metric 0 mtu 1500
        ether 02:06:d7:00:07:0b
        inet 192.168.1.12 netmask 0xffffff00 broadcast 192.168.3.255
        inet6 fe80::6:d7ff:fe00:70b%epair0b prefixlen 64 scopeid 0x2
        nd6 options=3

Test the connection:

# jexec testjail ping -c 1 192.168.1.11
PING 192.168.1.11 (192.168.1.11): 56 data bytes
64 bytes from 192.168.1.11: icmp_seq=0 ttl=64 time=0.059 ms

--- 192.168.1.11 ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.059/0.059/0.059/0.000 ms

# jexec web ping -c 1 192.168.1.10
PING 192.168.1.10 (192.168.1.10): 56 data bytes
64 bytes from 192.168.1.10: icmp_seq=0 ttl=64 time=0.094 ms

--- 192.168.1.10 ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.094/0.094/0.094/0.000 ms

Stop the jail:

# jail -r testjail
enceinte# jls
   JID  IP Address      Hostname                      Path

Clean the network:

# ifconfig epair0a destroy
# ifconfig bridge0 destroy

Start the jail automatically

As of 2011/08/01, /etc/rc.d/jail has problems using the new jail command (v2), so you must patch it if you want to use vnets:
http://www.freebsd.org/cgi/query-pr.cgi?pr=142972

In /etc/rc.conf:

#
# Jails networking
#
cloned_interfaces="bridge0"
ifconfig_bridge0="addm bge0"

#
# Jails configuration
#
jail_enable="YES"
jail_v2_enable="YES"
jail_list="testjail"

jail_testjail_name="testjail"
jail_testjail_hostname="testjail.example.net"
jail_testjail_devfs_enable="YES"
jail_testjail_rootdir="/usr/jails/testjail"
jail_testjail_vnet_enable="YES"
jail_testjail_exec_prestart0="ifconfig epair0 create"
jail_testjail_exec_prestart1="ifconfig bridge0 addm epair0a"
jail_testjail_exec_prestart2="ifconfig epair0a up"
jail_testjail_exec_earlypoststart0="ifconfig epair0b vnet testjail"
jail_testjail_exec_afterstart0="ifconfig lo0 127.0.0.1"
jail_testjail_exec_afterstart1="ifconfig epair0b 192.168.1.12 netmask 255.255.255.0 up"
jail_testjail_exec_afterstart2="route add default 192.168.1.1"
jail_testjail_exec_afterstart3="/bin/sh /etc/rc"
jail_testjail_exec_poststop0="ifconfig bridge0 deletem epair0a"
jail_testjail_exec_poststop1="ifconfig epair0a destroy"

Then:

# /etc/rc.d/jails start testjail

# jexec web ping -c 1 example.net
PING example.net (192.0.43.10): 56 data bytes
64 bytes from 192.0.43.10: icmp_seq=0 ttl=243 time=94.903 ms

--- example.net ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 94.903/94.903/94.903/0.000 ms

Sources:

Pages

Subscribe to Front page feed