le1t0-deprec 2.1.6.057 → 2.1.6.058
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/deprec/recipes/app/passenger.rb +70 -18
- data/lib/deprec/recipes/iptables.rb +8 -9
- data/lib/deprec/recipes/profiles.rb +84 -0
- data/lib/deprec/recipes/redis.rb +2 -7
- data/lib/deprec/recipes/ruby/rvm.rb +75 -0
- data/lib/deprec/recipes/sphinx/thinking_sphinx.rb +3 -3
- data/lib/deprec/recipes/sphinx/ultrasphinx.rb +3 -3
- data/lib/deprec/recipes/syslog/syslog_ng.rb +6 -6
- data/lib/deprec/recipes/ubuntu.rb +35 -0
- data/lib/deprec/recipes/xen.rb +97 -29
- data/lib/deprec/recipes/xentools.rb +97 -58
- data/lib/deprec/templates/iptables/firewall-init.erb +141 -175
- data/lib/deprec/templates/passenger/passenger.conf.erb +1 -1
- data/lib/deprec/templates/redis/redis-conf.erb +225 -45
- data/lib/deprec/templates/ubuntu/getlibs.erb +599 -0
- data/lib/deprec/templates/xentools/{98-custom → 01-mount-devpts.erb} +2 -5
- data/lib/deprec/templates/xentools/98-custom.erb +42 -0
- data/lib/deprec/templates/xentools/99-devpts-umount.erb +14 -0
- data/lib/deprec/templates/xentools/kernel-img.conf.example.erb +10 -0
- data/lib/deprec/templates/xentools/update-grub-xenu.example.erb +4 -0
- data/lib/deprec/templates/xentools/xm.tmpl.erb +20 -48
- data/lib/deprec.rb +15 -1
- metadata +18 -13
- data/lib/deprec/recipes/rvm.rb +0 -32
- data/lib/deprec/templates/iptables/firewall-default.erb +0 -13
- data/lib/deprec/templates/xentools/100-ubuntu-setup +0 -26
- data/lib/deprec/templates/xentools/15-disable-hwclock +0 -40
- data/lib/deprec/templates/xentools/30-disable-gettys +0 -57
- data/lib/deprec/templates/xentools/31-ubuntu-setup +0 -32
- data/lib/deprec/templates/xentools/40-setup-networking +0 -145
- data/lib/deprec/templates/xentools/xen-tools.conf.erb +0 -278
@@ -6,20 +6,19 @@
|
|
6
6
|
#
|
7
7
|
# Kernel + memory size
|
8
8
|
#
|
9
|
-
{ if ( ( $kernel ) && ( !defined($
|
9
|
+
{ if ( ( $kernel ) && ( !defined($bootloader)) )
|
10
10
|
{
|
11
|
-
$OUT.= "kernel = '$kernel'";
|
11
|
+
$OUT.= "kernel = '$kernel'\n";
|
12
12
|
}
|
13
13
|
}
|
14
|
-
{ if ( ( $initrd ) && ( !defined($
|
14
|
+
{ if ( ( $initrd ) && ( !defined($bootloader)) )
|
15
15
|
{
|
16
|
-
$OUT.= "ramdisk = '$initrd'";
|
16
|
+
$OUT.= "ramdisk = '$initrd'\n";
|
17
17
|
}
|
18
18
|
}
|
19
|
-
{
|
20
|
-
if ( $pygrub )
|
19
|
+
{ if ( $bootloader )
|
21
20
|
{
|
22
|
-
$OUT .= "bootloader = '
|
21
|
+
$OUT .= "bootloader = '$bootloader'\n";
|
23
22
|
}
|
24
23
|
}
|
25
24
|
memory = '{$memory}'
|
@@ -27,55 +26,28 @@ memory = '{$memory}'
|
|
27
26
|
#
|
28
27
|
# Disk device(s).
|
29
28
|
#
|
30
|
-
{
|
31
|
-
|
29
|
+
{
|
30
|
+
$ROOTDISKOUT = "";
|
31
|
+
for ( my $i = 0; $i <= $#PARTITIONS; $i++ )
|
32
32
|
{
|
33
|
-
for ( my $i = $#PARTITIONS; $i >= 0 ; $i-- )
|
34
|
-
{
|
35
33
|
if ( $PARTITIONS[$i]{'mountpoint'} eq '/' )
|
36
34
|
{
|
35
|
+
$ROOTDISKOUT = " '$PARTITIONS[$i]{'imagetype'}$PARTITIONS[$i]{'image'},$device" . ( $i + 1 ) .",w',\n";
|
37
36
|
$OUT .= "root = '/dev/$device" . ($i + 1) . " ro'\n";
|
38
37
|
}
|
39
|
-
}
|
40
|
-
$OUT .= "disk = [\n";
|
41
|
-
for ( my $i = $#PARTITIONS; $i >= 0 ; $i-- )
|
42
|
-
{
|
43
|
-
$OUT .= " '$PARTITIONS[$i]{'imagetype'}$PARTITIONS[$i]{'image'},$device" . ( $i + 1 ) .",w',\n";
|
44
|
-
}
|
45
|
-
$OUT .= " ]\n";
|
46
38
|
}
|
39
|
+
$OUT .= "disk = [\n";
|
40
|
+
$OUT .= $ROOTDISKOUT;
|
41
|
+
for ( my $i = 0; $i <= $#PARTITIONS; $i++ )
|
42
|
+
{
|
43
|
+
if ( $PARTITIONS[$i]{'mountpoint'} ne '/' )
|
44
|
+
{
|
45
|
+
$OUT .= " '$PARTITIONS[$i]{'imagetype'}$PARTITIONS[$i]{'image'},$device" . ( $i + 1 ) .",w',\n";
|
46
|
+
}
|
47
|
+
}
|
48
|
+
$OUT .= " ]\n";
|
47
49
|
}
|
48
50
|
|
49
|
-
#
|
50
|
-
# Physical volumes
|
51
|
-
#
|
52
|
-
{
|
53
|
-
if ( ( $swap_vbd ) && ( $image_vbd ) )
|
54
|
-
{
|
55
|
-
$OUT .= "root = '/dev/$device" . "2 ro'\n";
|
56
|
-
|
57
|
-
$OUT .= "disk = [ ";
|
58
|
-
|
59
|
-
if ( $image_vbd )
|
60
|
-
{
|
61
|
-
$OUT .= "'$image_vbd," . $device . "2,w'";
|
62
|
-
|
63
|
-
}
|
64
|
-
|
65
|
-
if ( $swap_vbd )
|
66
|
-
{
|
67
|
-
if ( $image_vbd )
|
68
|
-
{
|
69
|
-
$OUT .= ",";
|
70
|
-
}
|
71
|
-
|
72
|
-
$OUT .= "'$swap_vbd," . $device . "1,w'";
|
73
|
-
}
|
74
|
-
$OUT .= " ]\n";
|
75
|
-
}
|
76
|
-
}
|
77
|
-
|
78
|
-
|
79
51
|
#
|
80
52
|
# Hostname
|
81
53
|
#
|
data/lib/deprec.rb
CHANGED
@@ -39,4 +39,18 @@ Capistrano::Configuration.instance.deprec.namespaces.keys.each do |ns_name|
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
42
|
-
|
42
|
+
unless ns.respond_to?(:check_roles)
|
43
|
+
Capistrano::Configuration.instance.namespace :deprec do
|
44
|
+
namespace ns_name do
|
45
|
+
task :check_roles do
|
46
|
+
user_defined_roles = roles.keys
|
47
|
+
recipe_declared_roles = Capistrano::Configuration.instance.deprec.send(ns_name).tasks.collect { |k,v| v.options.has_key?(:roles) ? v.options[:roles] : nil }.compact.flatten.uniq
|
48
|
+
|
49
|
+
missing_roles = recipe_declared_roles - user_defined_roles
|
50
|
+
|
51
|
+
abort "You should define role(s): #{missing_roles.join(', ')}" unless missing_roles.empty?
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: le1t0-deprec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 11
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 2
|
7
8
|
- 1
|
8
9
|
- 6
|
9
|
-
-
|
10
|
-
version: 2.1.6.
|
10
|
+
- 58
|
11
|
+
version: 2.1.6.058
|
11
12
|
platform: ruby
|
12
13
|
authors:
|
13
14
|
- Le1t0
|
@@ -15,16 +16,18 @@ autorequire:
|
|
15
16
|
bindir: bin
|
16
17
|
cert_chain: []
|
17
18
|
|
18
|
-
date: 2010-
|
19
|
+
date: 2010-11-23 00:00:00 +01:00
|
19
20
|
default_executable: depify
|
20
21
|
dependencies:
|
21
22
|
- !ruby/object:Gem::Dependency
|
22
23
|
name: le1t0-capistrano
|
23
24
|
prerelease: false
|
24
25
|
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
25
27
|
requirements:
|
26
28
|
- - "="
|
27
29
|
- !ruby/object:Gem::Version
|
30
|
+
hash: 45
|
28
31
|
segments:
|
29
32
|
- 2
|
30
33
|
- 5
|
@@ -105,7 +108,7 @@ files:
|
|
105
108
|
- lib/deprec/recipes/redis.rb
|
106
109
|
- lib/deprec/recipes/ruby/mri.rb
|
107
110
|
- lib/deprec/recipes/ruby/ree.rb
|
108
|
-
- lib/deprec/recipes/rvm.rb
|
111
|
+
- lib/deprec/recipes/ruby/rvm.rb
|
109
112
|
- lib/deprec/recipes/s3utils.rb
|
110
113
|
- lib/deprec/recipes/sphinx/thinking_sphinx.rb
|
111
114
|
- lib/deprec/recipes/sphinx/ultrasphinx.rb
|
@@ -164,7 +167,6 @@ files:
|
|
164
167
|
- lib/deprec/templates/integrity/apache_vhost.erb
|
165
168
|
- lib/deprec/templates/integrity/config.ru.erb
|
166
169
|
- lib/deprec/templates/integrity/config.yml.erb
|
167
|
-
- lib/deprec/templates/iptables/firewall-default.erb
|
168
170
|
- lib/deprec/templates/iptables/firewall-init.erb
|
169
171
|
- lib/deprec/templates/keepalived/keepalived-init.erb
|
170
172
|
- lib/deprec/templates/keepalived/keepalived.conf.erb
|
@@ -246,6 +248,7 @@ files:
|
|
246
248
|
- lib/deprec/templates/trac/tracd-init.erb
|
247
249
|
- lib/deprec/templates/trac/users.htdigest.erb
|
248
250
|
- lib/deprec/templates/tsung/tsung.xml.erb
|
251
|
+
- lib/deprec/templates/ubuntu/getlibs.erb
|
249
252
|
- lib/deprec/templates/vnstat/config.php
|
250
253
|
- lib/deprec/templates/wordpress/apache2_wordpress_vhost.conf.erb
|
251
254
|
- lib/deprec/templates/wordpress/wp-config.php.erb
|
@@ -254,13 +257,11 @@ files:
|
|
254
257
|
- lib/deprec/templates/xen/xend-config.sxp.erb
|
255
258
|
- lib/deprec/templates/xen/xend-init.erb
|
256
259
|
- lib/deprec/templates/xen/xendomains.erb
|
257
|
-
- lib/deprec/templates/xentools/
|
258
|
-
- lib/deprec/templates/xentools/
|
259
|
-
- lib/deprec/templates/xentools/
|
260
|
-
- lib/deprec/templates/xentools/
|
261
|
-
- lib/deprec/templates/xentools/
|
262
|
-
- lib/deprec/templates/xentools/98-custom
|
263
|
-
- lib/deprec/templates/xentools/xen-tools.conf.erb
|
260
|
+
- lib/deprec/templates/xentools/01-mount-devpts.erb
|
261
|
+
- lib/deprec/templates/xentools/98-custom.erb
|
262
|
+
- lib/deprec/templates/xentools/99-devpts-umount.erb
|
263
|
+
- lib/deprec/templates/xentools/kernel-img.conf.example.erb
|
264
|
+
- lib/deprec/templates/xentools/update-grub-xenu.example.erb
|
264
265
|
- lib/deprec/templates/xentools/xm.tmpl.erb
|
265
266
|
- lib/deprec.rb
|
266
267
|
- lib/deprec_cmd_completion.sh
|
@@ -285,23 +286,27 @@ rdoc_options: []
|
|
285
286
|
require_paths:
|
286
287
|
- lib
|
287
288
|
required_ruby_version: !ruby/object:Gem::Requirement
|
289
|
+
none: false
|
288
290
|
requirements:
|
289
291
|
- - ">="
|
290
292
|
- !ruby/object:Gem::Version
|
293
|
+
hash: 3
|
291
294
|
segments:
|
292
295
|
- 0
|
293
296
|
version: "0"
|
294
297
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
298
|
+
none: false
|
295
299
|
requirements:
|
296
300
|
- - ">="
|
297
301
|
- !ruby/object:Gem::Version
|
302
|
+
hash: 3
|
298
303
|
segments:
|
299
304
|
- 0
|
300
305
|
version: "0"
|
301
306
|
requirements: []
|
302
307
|
|
303
308
|
rubyforge_project:
|
304
|
-
rubygems_version: 1.3.
|
309
|
+
rubygems_version: 1.3.7
|
305
310
|
signing_key:
|
306
311
|
specification_version: 3
|
307
312
|
summary: deployment recipes for capistrano
|
data/lib/deprec/recipes/rvm.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
# Copyright 2010 by le1t0@github. All rights reserved.
|
2
|
-
Capistrano::Configuration.instance(:must_exist).load do
|
3
|
-
namespace :deprec do
|
4
|
-
namespace :rvm do
|
5
|
-
|
6
|
-
set :rvm_rubies, %w(ruby-1.8.7-p160) # First ruby will be set as default if rvm_default_ruby is nil or empty
|
7
|
-
set :rvm_default_ruby, nil
|
8
|
-
|
9
|
-
desc "Install Rvm"
|
10
|
-
task :install do
|
11
|
-
run <<-EOF
|
12
|
-
version=$(curl http://rvm.beginrescueend.com/releases/stable-version.txt) ;
|
13
|
-
mkdir -p ~/.rvm/src/ && curl -O http://rvm.beginrescueend.com/releases/rvm-${version}.tar.gz | tar zxf - && cd rvm-${version} && ./install
|
14
|
-
|
15
|
-
EOF
|
16
|
-
end
|
17
|
-
|
18
|
-
desc "Install rubies"
|
19
|
-
task :install_rubies do
|
20
|
-
rvm_rubies.each_with_index do |ruby, i|
|
21
|
-
run "rvm install #{ruby}"
|
22
|
-
run "rvm --default #{ruby}" if i == 0 && (rvm_default_ruby.nil? || rvm_default_ruby.empty?)
|
23
|
-
end
|
24
|
-
if !(rvm_default_ruby.nil? || rvm_default_ruby.empty?)
|
25
|
-
set_default = rvm_default_ruby == "system" ? rvm_default_ruby : "--default #{rvm_default_ruby}"
|
26
|
-
run "rvm #{set_default}"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# define tcp ports allowed for the world: "tcp:80,443"
|
2
|
-
# define non-tcp/udp/icmp protocols allowed for the world: "pptp"
|
3
|
-
# define tcp/udp ports allowed for specific networks/IPs: "tcp:389;udp:514@10.0.1.2,192.168.0.0/24 tcp,udp:22@192.168.0.3"
|
4
|
-
# define non-tcp/udp/icmp protocols allowed for specific networks/IPs: "vrrp@192.168.0.0/24"
|
5
|
-
# example: allowed="tcp:80,443 udp:138 pptp tcp:21,443@192.168.0.0/24 tcp:389;udp:514@10.0.1.2,10.0.1.5 vrrp@192.168.0.0/24 gre@10.0.1.2"
|
6
|
-
allowed="<%= iptables_allowed %>"
|
7
|
-
|
8
|
-
# example: forwards="192.168.0.1:8080>192.168.0.2:80;tcp 192.168.0.1:514>192.168.0.2:514;udp"
|
9
|
-
forwards="<%= iptables_forwards %>"
|
10
|
-
|
11
|
-
DRYRUN="NO" # Set to exactly YES to enable dry runs
|
12
|
-
IPTABLES="<%= iptables_binary %>"
|
13
|
-
IPTABLES_SAVE="<%= iptables_save_binary %>"
|
@@ -1,26 +0,0 @@
|
|
1
|
-
#!/bin/sh
|
2
|
-
#
|
3
|
-
# This script setups the ubuntu guests up properly.
|
4
|
-
#
|
5
|
-
|
6
|
-
prefix=$1
|
7
|
-
|
8
|
-
#
|
9
|
-
# Source our common functions
|
10
|
-
#
|
11
|
-
if [ -e /usr/lib/xen-tools/common.sh ]; then
|
12
|
-
. /usr/lib/xen-tools/common.sh
|
13
|
-
else
|
14
|
-
. ./hooks/common.sh
|
15
|
-
fi
|
16
|
-
|
17
|
-
chroot ${prefix} /usr/sbin/update-rc.d -f hwclock.sh remove
|
18
|
-
chroot ${prefix} /usr/sbin/update-rc.d -f hwclockfirst.sh remove
|
19
|
-
chroot ${prefix} rm -f /etc/udev/rules.d/85-hwclock.rules
|
20
|
-
chroot ${prefix} ln -sf /bin/true /sbin/hwclock
|
21
|
-
|
22
|
-
#
|
23
|
-
# Change first console setting to xvc0 upstart
|
24
|
-
#
|
25
|
-
echo "xvc0" >> ${prefix}/etc/securetty
|
26
|
-
sed -i "s/tty1/xvc0/" ${prefix}/etc/event.d/tty1
|
@@ -1,40 +0,0 @@
|
|
1
|
-
#!/bin/sh
|
2
|
-
#
|
3
|
-
# This script disables the hardware clock.
|
4
|
-
#
|
5
|
-
# Steve
|
6
|
-
# --
|
7
|
-
# http://www.steve.org.uk/
|
8
|
-
|
9
|
-
|
10
|
-
prefix=$1
|
11
|
-
|
12
|
-
|
13
|
-
#
|
14
|
-
# Source our common functions
|
15
|
-
#
|
16
|
-
if [ -e /usr/lib/xen-tools/common.sh ]; then
|
17
|
-
. /usr/lib/xen-tools/common.sh
|
18
|
-
else
|
19
|
-
. ./hooks/common.sh
|
20
|
-
fi
|
21
|
-
|
22
|
-
|
23
|
-
#
|
24
|
-
# Log our start
|
25
|
-
#
|
26
|
-
logMessage Script $0 starting
|
27
|
-
|
28
|
-
|
29
|
-
#
|
30
|
-
# Disable the startup scripts from all runlevels.
|
31
|
-
#
|
32
|
-
chroot ${prefix} /usr/sbin/update-rc.d -f hwclock.sh remove
|
33
|
-
chroot ${prefix} /usr/sbin/update-rc.d -f hwclockfirst.sh remove
|
34
|
-
rm -f ${prefix}/etc/init.d/hwclock.sh ${prefix}/etc/init.d/hwclockfirst.sh ${prefix}/etc/udev/rules.d/85-hwclock.rules
|
35
|
-
|
36
|
-
#
|
37
|
-
# Log our finish
|
38
|
-
#
|
39
|
-
logMessage Script $0 finished.
|
40
|
-
|
@@ -1,57 +0,0 @@
|
|
1
|
-
#!/bin/sh
|
2
|
-
#
|
3
|
-
# This script comments out all virtual terminals which aren't on the
|
4
|
-
# first console - that must remain so that 'xm console ...' works
|
5
|
-
# correctly.
|
6
|
-
#
|
7
|
-
|
8
|
-
|
9
|
-
prefix=$1
|
10
|
-
|
11
|
-
|
12
|
-
#
|
13
|
-
# Source our common functions
|
14
|
-
#
|
15
|
-
if [ -e /usr/lib/xen-tools/common.sh ]; then
|
16
|
-
. /usr/lib/xen-tools/common.sh
|
17
|
-
else
|
18
|
-
. ./hooks/common.sh
|
19
|
-
fi
|
20
|
-
|
21
|
-
|
22
|
-
#
|
23
|
-
# Log our start
|
24
|
-
#
|
25
|
-
logMessage Script $0 starting
|
26
|
-
|
27
|
-
#
|
28
|
-
# Remove the links for upstart
|
29
|
-
#
|
30
|
-
rm ${prefix}/etc/event.d/tty[!1]
|
31
|
-
|
32
|
-
|
33
|
-
#
|
34
|
-
# Are we using an alternative serial device?
|
35
|
-
#
|
36
|
-
if [ ! -z "${serial_device}" ]; then
|
37
|
-
|
38
|
-
serial_device=`basename ${serial_device}`
|
39
|
-
|
40
|
-
# Let the user know.
|
41
|
-
logMessage "Replacing default serial device (tty1) with ${serial_device}"
|
42
|
-
|
43
|
-
chroot ${prefix} mknod /dev/${serial_device} c 204 191
|
44
|
-
|
45
|
-
# replace existing device.
|
46
|
-
mv ${prefix}/etc/event.d/tty1 ${prefix}/etc/event.d/${serial_device}
|
47
|
-
sed -i -e s/tty1/${serial_device}/ ${prefix}/etc/event.d/${serial_device}
|
48
|
-
|
49
|
-
# make sure that it is allowed to login.
|
50
|
-
echo $serial_device >> ${prefix}/etc/securetty
|
51
|
-
fi
|
52
|
-
|
53
|
-
|
54
|
-
#
|
55
|
-
# Log our finish
|
56
|
-
#
|
57
|
-
logMessage Script $0 finished
|
@@ -1,32 +0,0 @@
|
|
1
|
-
#!/bin/sh
|
2
|
-
#
|
3
|
-
# This script setups the ubuntu guests up properly.
|
4
|
-
#
|
5
|
-
|
6
|
-
|
7
|
-
prefix=$1
|
8
|
-
|
9
|
-
#
|
10
|
-
# Source our common functions
|
11
|
-
#
|
12
|
-
if [ -e /usr/lib/xen-tools/common.sh ]; then
|
13
|
-
. /usr/lib/xen-tools/common.sh
|
14
|
-
else
|
15
|
-
. ./hooks/common.sh
|
16
|
-
fi
|
17
|
-
|
18
|
-
chroot ${prefix} /usr/sbin/update-rc.d -f hwclock.sh remove
|
19
|
-
chroot ${prefix} /usr/sbin/update-rc.d -f hwclockfirst.sh remove
|
20
|
-
chroot ${prefix} rm -f /etc/udev/rules.d/85-hwclock.rules
|
21
|
-
chroot ${prefix} ln -sf /bin/true /sbin/hwclock
|
22
|
-
chroot ${prefix} mknod /dev/xvda b 202 0
|
23
|
-
chroot ${prefix} mknod /dev/xvdb b 202 16
|
24
|
-
chroot ${prefix} mknod /dev/xvdc b 202 32
|
25
|
-
chroot ${prefix} mknod /dev/xvdd b 202 48
|
26
|
-
|
27
|
-
for i in 1 2 3 4 5 6 7 8 9; do
|
28
|
-
chroot ${prefix} mknod /dev/xvda$i b 202 $i
|
29
|
-
chroot ${prefix} mknod /dev/xvdb$i b 202 $i
|
30
|
-
chroot ${prefix} mknod /dev/xvdc$i b 202 $i
|
31
|
-
chroot ${prefix} mknod /dev/xvdd$i b 202 $i
|
32
|
-
done
|
@@ -1,145 +0,0 @@
|
|
1
|
-
#!/bin/sh
|
2
|
-
#
|
3
|
-
# This script sets up the /etc/network/interface file for the new
|
4
|
-
# image.
|
5
|
-
#
|
6
|
-
# Steve
|
7
|
-
# --
|
8
|
-
# http://www.steve.org.uk/
|
9
|
-
|
10
|
-
|
11
|
-
prefix=$1
|
12
|
-
|
13
|
-
#
|
14
|
-
# Source our common functions
|
15
|
-
#
|
16
|
-
if [ -e /usr/lib/xen-tools/common.sh ]; then
|
17
|
-
. /usr/lib/xen-tools/common.sh
|
18
|
-
else
|
19
|
-
. ./hooks/common.sh
|
20
|
-
fi
|
21
|
-
|
22
|
-
|
23
|
-
#
|
24
|
-
# Log our start
|
25
|
-
#
|
26
|
-
logMessage Script $0 starting
|
27
|
-
|
28
|
-
|
29
|
-
#
|
30
|
-
# Make sure we have an /etc/network directory.
|
31
|
-
#
|
32
|
-
mkdir -p ${prefix}/etc/network
|
33
|
-
|
34
|
-
|
35
|
-
#
|
36
|
-
# A function to setup DHCP for our new image.
|
37
|
-
#
|
38
|
-
setupDynamicNetworking ()
|
39
|
-
{
|
40
|
-
#
|
41
|
-
# The host is using DHCP.
|
42
|
-
#
|
43
|
-
cat <<E_O_DHCP > ${prefix}/etc/network/interfaces
|
44
|
-
# This file describes the network interfaces available on your system
|
45
|
-
# and how to activate them. For more information, see interfaces(5).
|
46
|
-
|
47
|
-
# The loopback network interface
|
48
|
-
auto lo
|
49
|
-
iface lo inet loopback
|
50
|
-
|
51
|
-
# The primary network interface
|
52
|
-
auto eth0
|
53
|
-
iface eth0 inet dhcp
|
54
|
-
post-up ethtool -K eth0 tx off
|
55
|
-
|
56
|
-
#
|
57
|
-
# The commented out line above will disable TCP checksumming which
|
58
|
-
# might resolve problems for some users. It is disabled by default
|
59
|
-
#
|
60
|
-
E_O_DHCP
|
61
|
-
}
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
#
|
66
|
-
# A function to setup static IP addresses for our new image.
|
67
|
-
#
|
68
|
-
setupStaticNetworking ()
|
69
|
-
{
|
70
|
-
#
|
71
|
-
# broadcast address?
|
72
|
-
#
|
73
|
-
bcast='';
|
74
|
-
if [ ! -z "${broadcast}" ]; then
|
75
|
-
bcast=" broadcast ${broadcast}"
|
76
|
-
fi
|
77
|
-
|
78
|
-
#
|
79
|
-
# We have a static IP address
|
80
|
-
#
|
81
|
-
cat <<E_O_STATIC >${prefix}/etc/network/interfaces
|
82
|
-
# This file describes the network interfaces available on your system
|
83
|
-
# and how to activate them. For more information, see interfaces(5).
|
84
|
-
|
85
|
-
# The loopback network interface
|
86
|
-
auto lo
|
87
|
-
iface lo inet loopback
|
88
|
-
|
89
|
-
# The primary network interface
|
90
|
-
auto eth0
|
91
|
-
iface eth0 inet static
|
92
|
-
address ${ip1}
|
93
|
-
gateway ${gateway}
|
94
|
-
netmask ${netmask}
|
95
|
-
${bcast}
|
96
|
-
post-up ethtool -K eth0 tx off
|
97
|
-
|
98
|
-
#
|
99
|
-
# The commented out line above will disable TCP checksumming which
|
100
|
-
# might resolve problems for some users. It is disabled by default
|
101
|
-
#
|
102
|
-
E_O_STATIC
|
103
|
-
|
104
|
-
interface=1
|
105
|
-
count=2
|
106
|
-
|
107
|
-
while [ "${count}" -le "${ip_count}" ]; do
|
108
|
-
|
109
|
-
value=\$ip${count}
|
110
|
-
value=`eval echo $value`
|
111
|
-
|
112
|
-
logMessage Adding etho:${interface}
|
113
|
-
|
114
|
-
cat <<E_O_STATIC >>${prefix}/etc/network/interfaces
|
115
|
-
auto eth0:${interface}
|
116
|
-
iface eth0:${interface} inet static
|
117
|
-
address ${value}
|
118
|
-
netmask ${netmask}
|
119
|
-
post-up ethtool -K eth0 tx off
|
120
|
-
E_O_STATIC
|
121
|
-
count=`expr $count + 1`
|
122
|
-
interface=`expr $interface + 1`
|
123
|
-
done
|
124
|
-
}
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
#
|
130
|
-
# Call the relevant function
|
131
|
-
#
|
132
|
-
if [ -z "${dhcp}" ]; then
|
133
|
-
logMessage "Setting up static networking"
|
134
|
-
setupStaticNetworking
|
135
|
-
|
136
|
-
else
|
137
|
-
logMessage "Setting up DHCP networking"
|
138
|
-
setupDynamicNetworking
|
139
|
-
fi
|
140
|
-
|
141
|
-
|
142
|
-
#
|
143
|
-
# Log our finish
|
144
|
-
#
|
145
|
-
logMessage Script $0 finished
|