[vhffs-dev] [1226] Next VHFFS version will be full CLI...

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 1226
Author:   beuss
Date:     2008-06-20 15:08:52 +0200 (Fri, 20 Jun 2008)

Log Message:
-----------
Next VHFFS version will be full CLI...

Modified Paths:
--------------
    trunk/vhffs-tools/src/Makefile.am

Added Paths:
-----------
    trunk/vhffs-tools/src/vhffs-useradd


Modified: trunk/vhffs-tools/src/Makefile.am
===================================================================
--- trunk/vhffs-tools/src/Makefile.am	2008-06-18 13:08:24 UTC (rev 1225)
+++ trunk/vhffs-tools/src/Makefile.am	2008-06-20 13:08:52 UTC (rev 1226)
@@ -7,6 +7,7 @@
 	vhffs-moderate \
 	vhffs-passwd \
 	vhffs-quota \
+	vhffs-useradd \
 	vhffs-userdel \
 	vhffs-userinfo \
 	vhffs-usermod \

Added: trunk/vhffs-tools/src/vhffs-useradd
===================================================================
--- trunk/vhffs-tools/src/vhffs-useradd	                        (rev 0)
+++ trunk/vhffs-tools/src/vhffs-useradd	2008-06-20 13:08:52 UTC (rev 1226)
@@ -0,0 +1,61 @@
+#!%PERL% -w
+
+use strict;
+
+use lib '%VHFFS_LIB_DIR%';
+use Vhffs::User;
+use Vhffs::Main;
+use Vhffs::Constants;
+use Term::ReadPassword;
+
+my $vhffs = init Vhffs::Main;
+
+my ($username, $password, $conf_password, $access_level, $mail, $firstname, $lastname, $city, $zipcode, $country, $address);
+
+print 'Username: ';
+chomp($username = <STDIN>);
+while(1) {
+	$password = read_password('Password: ');
+	$conf_password = read_password('Password (confirm): ');
+	if($password ne $conf_password) {
+		print "Password mismatch\n";
+		redo;
+	}
+	last;
+}
+
+while(1) {
+	print 'Is this user an [A]dministrator/[M]oderator/[R]egular user ? ';
+	my $answer;
+	chomp($answer = <STDIN>);
+	$access_level = Vhffs::Constants::USER_NORMAL if($answer eq 'R');
+	$access_level = Vhffs::Constants::USER_MODERATOR if($answer eq 'M');
+	$access_level = Vhffs::Constants::USER_ADMIN if($answer eq 'A');
+	unless(defined $access_level) {
+		print "Invalid access level\n";
+		redo;
+	}
+	last;
+}
+
+print 'Email address: ';
+chomp($mail = <STDIN>);
+print 'Firstname: ';
+chomp($firstname = <STDIN>);
+print 'Lastname: ';
+chomp($lastname = <STDIN>);
+print 'City: ';
+chomp($city = <STDIN>);
+print 'Zipcode: ';
+chomp($zipcode = <STDIN>);
+print 'Country: ';
+chomp($country = <STDIN>);
+print 'Address: ';
+chomp($address = <STDIN>);
+	
+if(defined Vhffs::User::create($vhffs, $username, $password, $access_level, $mail, $firstname, $lastname, $city, $zipcode, $country, $address)) {
+	print "User successfully created\n";
+} else {
+	print "Unable to create user (duplicate ?)\n";
+}
+


Property changes on: trunk/vhffs-tools/src/vhffs-useradd
___________________________________________________________________
Name: svn:executable
   + *


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/