/[sysadmin-cookbook]/recepies/lxc/ve2lxc.sh
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /recepies/lxc/ve2lxc.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 86 - (hide annotations)
Sun May 17 20:54:48 2009 UTC (14 years, 11 months ago) by dpavlin
File MIME type: application/x-sh
File size: 965 byte(s)
convert OpenVZ container to LXC

1 dpavlin 86 #!/bin/sh -x
2    
3     test -z "$1" && echo "usage: $0 /path/to/ve/private" && exit
4    
5     dir=$1
6    
7     path=/$dir/etc/inittab
8     tmp=/tmp/inittab
9    
10     cp $path $tmp || exit
11    
12     function append() {
13     if ! grep "$1" $path ; then
14     echo "$1" >> $tmp
15     fi
16     }
17    
18     append "z6:6:respawn:/sbin/sulogin"
19     append "1:2345:respawn:/sbin/getty 38400 console"
20     append "c1:12345:respawn:/sbin/getty 38400 tty1 linux"
21     append "c2:12345:respawn:/sbin/getty 38400 tty2 linux"
22     append "c3:12345:respawn:/sbin/getty 38400 tty3 linux"
23     append "c4:12345:respawn:/sbin/getty 38400 tty4 linux"
24    
25     if ! diff -uw $path $tmp ; then
26     cp $path $path.old && mv $tmp $path
27     fi
28    
29     conf=/tmp/ve2lxc.conf
30     cp ve2lxc.conf $conf || exit
31     echo "lxc.rootfs = $dir" >> $conf
32    
33     lxc-stop -n ve2lxc
34     lxc-destroy -n ve2lxc
35    
36     test -d /cgroup || mkdir /cgroup
37     if ! grep /cgroup /etc/fstab ; then
38     echo "cgroup /cgroup cgroup rw 0 0" >> /etc/fstab
39     fi
40    
41     mount | grep /cgroup || mount /cgroup || exit
42    
43     lxc-create -n ve2lxc -f $conf && read && lxc-start -n ve2lxc

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26