File: diskless-newimage

package info (click to toggle)
diskless 0.3.6
  • links: PTS
  • area: main
  • in suites: potato
  • size: 460 kB
  • ctags: 111
  • sloc: perl: 2,467; sh: 375; makefile: 104
file content (64 lines) | stat: -rwxr-xr-x 1,092 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/perl -w
use lib "/usr/lib/diskless";
use strict;
use diskless;
use imagedir_server;

my $m=0;

if ($#ARGV >= 0) 
{ 
	if ($ARGV[0] eq "--help")
	{
		print<<EOT;

No help currently available

EOT
		exit 0;
	}
}

my $imagedir="";
if ($m <= $#ARGV)
{
	$imagedir=$ARGV[$m]; $m++;
}

my %options;
while ($m <= $#ARGV && $ARGV[$m] =~ /^([A-Za-z_0-9]+)=(.*)$/)
{
	$options{$1}=$2; $m++;
}

if ( $imagedir eq "" )
{
	$imagedir = "diskless"->input("Image directory","/var/lib/diskless/default/root");
}

my $error = undef;
my $theimagedir = "imagedir_server"->get($imagedir,\$error);
if (defined($error) && $error->id == "error"->notfound)
{
	print "Creating a NEW image directory\n";
	$error=undef;
	$theimagedir = "imagedir_server"->create($imagedir,\$error);
	die($error->msg."\n") if (defined($error));
}
elsif (defined($error))
{
	die($error->msg."\n");
}
else
{
	print "Re-configuring existing image directory\n";
	print "WARNING: this image directory must already be installed\n";
	$theimagedir->config(\%options,\$error);
}

if (defined($error))
{
	die($error->msg."\n");
}

exit 0;