Permalink
Browse files

rename dwimmer_setup to dwimmer_admin and add some new features

  • Loading branch information...
1 parent 0a21093 commit 236f61b8fc50bfb5c049149fa3527d55d7deb700 @szabgab committed Mar 18, 2012
Showing with 57 additions and 46 deletions.
  1. +3 −0 Changes
  2. +1 −1 Makefile.PL
  3. +2 −2 README
  4. +1 −1 script/dbic.pl
  5. +49 −41 script/{dwimmer_setup.pl → dwimmer_admin.pl}
  6. +1 −1 t/lib/Dwimmer/Test.pm
View
@@ -1,5 +1,8 @@
Changes to the Dwimmer system. See http://dwimmer.org/
+ - rename dwimmer_setup to dwimmer_admin
+ - lots of additional features to dwimmer_admin
+
0.27 2012.03.11
- rename /change_password to /change_my_password
View
@@ -62,7 +62,7 @@ homepage 'http://dwimmer.org/';
bugtracker 'http://github.com/szabgab/dwimmer';
repository 'http://github.com/szabgab/dwimmer';
-install_script 'script/dwimmer_setup.pl';
+install_script 'script/dwimmer_admin.pl';
install_script 'script/dwimmer_backup.pl';
install_script 'script/dwimmer';
View
4 README
@@ -14,14 +14,14 @@ Setup:
If you already have a CPAN enabled perl installed then type "cpan Dwimmer" in your command prompt.
If you don't have perl yet then we have a binary packaged version for windows. Install Dwimperl.
-dwimmer_setup.pl --password ADMIN_PASSWORD --email email-of-admin@company.com --root path/to/your/installation
+dwimmer_admin.pl --setup --password ADMIN_PASSWORD --email email-of-admin@company.com --root path/to/your/installation
------------
Upgrade:
cpan Dwimmer
-dwimmer_setup.pl --password ADMIN_PASSWORD --root path/to/your/installation --upgrade
+dwimmer_admin.pl --upgrade --password ADMIN_PASSWORD --root path/to/your/installation
View
@@ -19,7 +19,7 @@ BEGIN
my $temp = tempdir( CLEANUP => 0 );
my $root = File::Spec->catdir($temp, 'root');
-system "$^X -I$lib script/dwimmer_setup.pl --email dev\@dwimmer.org --password dwimmer --root $root";
+system "$^X -I$lib script/dwimmer_admin.pl --setup --email dev\@dwimmer.org --password dwimmer --root $root";
my $dbfile = File::Spec->catfile($root, 'db', 'dwimmer.db');
@@ -13,8 +13,8 @@
use File::Spec;
use File::ShareDir;
use Getopt::Long qw(GetOptions);
-use String::Random;
use Pod::Usage qw(pod2usage);
+use String::Random;
use Dwimmer::Tools qw(sha1_base64 save_page _get_db);
@@ -26,22 +26,36 @@
'dbonly',
'silent',
'share=s',
+
+ 'setup',
'upgrade',
- 'resetpw',
+
'username=s',
+ 'resetpw',
'listusers',
'showuser',
-
'verify=s',
);
usage() if not $opt{root};
+if ($opt{setup}) {
+ if (-e $opt{root} and not $opt{dbonly}) {
+ die "Root directory ($opt{root}) already exists"
+ }
-if ($opt{resetpw}) {
+ usage() if not $opt{email};
+ die 'Invalid e-mail' if not Email::Valid->address($opt{email});
+ usage() if not $opt{password};
+ die 'Password needs to be at least 6 characters' if length $opt{password} < 6;
+} else {
if (not -e $opt{root}) {
die "Root directory ($opt{root}) does NOT exist.";
}
+}
+
+
+if ($opt{resetpw}) {
if (not $opt{password}) {
die "Need password to set it";
}
@@ -80,10 +94,6 @@
}
if ($opt{listusers}) {
- if (not -e $opt{root}) {
- die "Root directory ($opt{root}) does NOT exist.";
- }
-
$ENV{DWIMMER_ROOT} = $opt{root};
my $db = _get_db();
my @users = $db->resultset('User')->all();
@@ -96,9 +106,6 @@
}
if ($opt{showuser}) {
- if (not -e $opt{root}) {
- die "Root directory ($opt{root}) does NOT exist.";
- }
if (not $opt{username}) {
die "Need username to ";
}
@@ -114,25 +121,17 @@
exit;
}
-if (-e $opt{root} and not $opt{dbonly} and not $opt{upgrade}) {
- die "Root directory ($opt{root}) already exists"
-}
-if ($opt{upgrade} and not -e $opt{root}) {
- die "Root directory ($opt{root}) does NOT exist."
+if (not $opt{upgrade} and not $opt{setup}) {
+ usage();
}
-if (not $opt{upgrade}) {
- usage() if not $opt{email};
- die 'Invalid e-mail' if not Email::Valid->address($opt{email});
- usage() if not $opt{password};
- die 'Password needs to be 6 characters' if length $opt{password} < 6;
-}
-my $dist_dir;
+
# When we are in the development environment (have .git) set this to the root directory
# When we are in the installation environment (have Makefile.PL) set this to the share/ subdirectory
+my $dist_dir;
if (-e File::Spec->catdir(dirname(dirname abs_path($0)) , '.git') ) {
$dist_dir = dirname(dirname abs_path($0))
} elsif (-e File::Spec->catdir(dirname(dirname abs_path($0)) , 'Makefile.PL') ) {
@@ -195,6 +194,7 @@
say 'You can now launch the application and visit the web site';
exit;
+##################################################################
sub setup_db {
my $dbfile = shift;
@@ -254,43 +254,51 @@ sub usage {
=head1 SYNOPSIS
+=head2 Required parameter:
-To setup a new instance:
+ --root PATH/TO/ROOT path to the root of the installation
+=head2 To setup a new instance:
+
+ --setup
--email email of administrator
--password PASSWORD of administrator
- --root ROOT path to the root of the installation
Optional parameters:
--dbonly Create only the database (for development)
--silent no success report (for testing)
-
-To upgrade run:
+=head2 To upgrade run:
--upgrade
- --root PATH/TO/ROOT
-To reset password give the following flags:
+=head2 Admin tools:
- --resetpw
- --root PATH/TO/ROOT
- --username USERNAME
- --password PASSWORD
+=over 4
-Show details of a user:
+=item * List users:
- --showuser
- --root PATH/TO/ROOT
- --username USERNAME
-
--listusers
- --root
+
+=item * Show details of a user:
+
+ --showuser
+ --username USERNAME
- --verify
- --root
+=item * Set or remove verified bit of a user:
+
+ --verify [0|1]
+ --username USERNAME
+
+=item * Set the password of a specific user:
+
+ --resetpw
+ --username USERNAME
+ --password PASSWORD
+
+=back
=cut
View
@@ -41,7 +41,7 @@ sub start {
my $root = File::Spec->catdir( $dir, 'dwimmer' );
system
- "$^X -Ilib script/dwimmer_setup.pl --root $root --email $admin_mail --password $password" and die $!;
+ "$^X -Ilib script/dwimmer_admin.pl --setup --root $root --email $admin_mail --password $password" and die $!;
mkdir "$root/polls" or die $!;
copy("t/files/testing-polls.json", "$root/polls") or die $!;

0 comments on commit 236f61b

Please sign in to comment.