/[vz-tools]/trunk/vz-create.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/vz-create.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4 by dpavlin, Sun Jan 7 12:11:36 2007 UTC revision 10 by dpavlin, Sun Jan 7 23:25:19 2007 UTC
# Line 15  my $debian_mirror_uri = 'http://debian.c Line 15  my $debian_mirror_uri = 'http://debian.c
15  my $ve_total = 2;  my $ve_total = 2;
16  # swap size (Mb)  # swap size (Mb)
17  my $swap_size = 512;  my $swap_size = 512;
18    # diskspace
19    my $diskspace = '2G:4G';
20    
21  print "Creating new OpenVZ instance...\n";  print "Creating new OpenVZ instance...\n";
22    
23  my $arg = shift @ARGV;  my $arg = shift @ARGV || '';
24    
25  my ($hostname, $ip);  my ($hostname, $ip) = ('localhost','');
26    
27  if ($arg =~ m/$RE{net}{IPv4}/) {  if ($arg =~ m/$RE{net}{IPv4}/) {
28          $ip = $arg;          $ip = $arg;
29          chomp($hostname);          chomp($hostname);
30          $hostname = host($arg);          $hostname = host($arg);
31          $hostname =~ s/^.*\s(\S+)$/$1/;          $hostname =~ s/^.*\s(\S+)$/$1/;
32  } else {  } elsif ($arg) {
33          $hostname = $arg;          $hostname = $arg;
34          $ip = host($arg);          $ip = host($arg);
35          chomp($ip);          chomp($ip);
# Line 87  if (-e $conf_path) { Line 89  if (-e $conf_path) {
89          vzctl('set', $ve_id, '--applyconfig', 'vps.basic', '--save');          vzctl('set', $ve_id, '--applyconfig', 'vps.basic', '--save');
90          vzctl('set', $ve_id, '--ipadd', $ip, '--save');          vzctl('set', $ve_id, '--ipadd', $ip, '--save');
91          vzctl('set', $ve_id, '--hostname', $hostname, '--save');          vzctl('set', $ve_id, '--hostname', $hostname, '--save');
92            vzctl('set', $ve_id, '--diskspace', $diskspace, '--save');
93  }  }
94    
95  sub create_file {  sub create_file {
# Line 104  create_file( Line 107  create_file(
107          "deb $debian_mirror_uri $dist main contrib non-free\n"          "deb $debian_mirror_uri $dist main contrib non-free\n"
108  );  );
109    
110  vzctl('start', $ve_id);  vzctl('start', $ve_id, '--wait');
111    
112  my $customize_sh = <<'__END_OF_SH__';  my $customize_sh = <<'__END_OF_SH__';
113    
# Line 116  apt-get update Line 119  apt-get update
119  apt-get upgrade  apt-get upgrade
120    
121  # install additional packages  # install additional packages
122  apt-get -y install vim less ssh  apt-get -y install vim less ssh sudo screen telnet finger
123    
124    # remove unwanted packages
125    apt-get -y remove nano
126    
127    # apt-iselect helper
128    wget -O /usr/local/bin/apt-iselect http://www.rot13.org/~dpavlin/projects/scripts/apt-iselect && chmod 755 /usr/local/bin/apt-iselect
129    
130  # lock root user  # lock root user
131  usermod -L root  usermod -L root

Legend:
Removed from v.4  
changed lines
  Added in v.10

  ViewVC Help
Powered by ViewVC 1.1.26