PApp

 view release on metacpan or  search on metacpan

bin/papp-admin  view on Meta::CPAN

               \my($name),
               "select name from app
                where appset is not null
                order by name";

   $| = 1;
   while ($st->fetch) {
      print "$name...";
      (load_app PApp $name)->upgrade;
      print "ok\n";
   }
}

sub list_apps {
   my $st = sql_exec 
               \my($name, $appset, $path),
               "select a.name, s.name, a.path from app a left join appset s on (a.appset = s.id)
                where a.name like ?
                order by 1",
               @_ ? shift : "%";

   printf "%-9s %-9s %-15s\n", "NAME", "APPSET", "PATH";
   while ($st->fetch) {
      printf "%-9s %-9s %-15s\n",
         $name,
         defined $appset ? $appset : "<disabled>",
         $path;
   }
}

sub list_appsets {
   my $st = sql_exec 
               \my($id, $name),
               "select id, name from appset order by name";

   printf "%-5s %s\n", "ID", "NAME";
   while ($st->fetch) {
      printf "%-5s %s\n",
         $id, $name;
   }
}

sub list_groups {
   my $st = sql_exec 
               \my($id, $name, $desc),
               "select id, name, comment
                from grp
                where id = ? or name like ?
                order by 2",
               $_[0], $_[0];

   printf "%4s %-15s %-59.59s\n", "GID", "NAME", "COMMENT";
   while ($st->fetch) {
      printf "%4s %-15s %-59.59s\n", $id, $name, $desc;
   }
}

sub list_users {
   my $st = sql_exec 
               \my($id),
               "select uid from prefs
                where path = '' and name = 'papp_username'
                      and value like ?
                order by 1",
               $_[0];

   printf "%4s %-9s %s\n", "UID", "NAME", "COMMENT";
   while ($st->fetch) {
      printf "%4s %-9s %s\n",
         $id,
         (username $id),
         $PApp::prefs->user_get($id, "papp_comment");
   }
}

sub parsetime {
   my $time = shift;
   $time =~ m{^\s*(\d+)([smhdDMyY]?)\s*$}
      or die "$time: unparseable time value\n";

   return $1 * 60 * 60 * 24 * 365.2425  if $2 eq "y" or $2 eq "Y";
   return $1 * 60 * 60 * 24 * 30.436875 if              $2 eq "M";
   return $1 * 60 * 60 * 24             if $2 eq "d" or $2 eq "D";
   return $1 * 60 * 60                  if $2 eq "h";
   return $1 * 60                       if $2 eq "m";
   return $1;
}

=head1 NAME

papp-admin - administrate papp

=head1 SYNOPSIS

   Usage: papp-admin [opts...]

       -h | --help             this list
       -v | --verbose          be more verbose
       -q | --quiet            be very quiet
       -V | --version          show papp version string
          
            --initdb           initialize/upgrade database (NYI)
          | --addset <set>     create appset <set>
          | --delset <set>     delete appset <set>
            --list-apps        list applications
            --list-appsets     list application sets
            --list-users       list (registered) users
            --list-groups      list groups / access rights

            --upgrade-apps     upgrade all mounted applications.

       -a | --app <name>       select/create application <name>
            --appset <name>    set application set <name>
            --path <path>      set application path
            --mount <cfg>      set <cfg> as mountconfig (or location)
            --config <cfg>     set <cfg> as application config

       -g | --group <name>     select/create group <name>
            --comment <text>   set the group comment string

       -u | --user <name>      select/create user <name>
            --password <pw>    set new password (dangerous!)
            --comment <text>   set the user comment string
            --grant <group>    add user to <group>
            --revoke <group>   remove user from <group>

       -d | --delete           delete selected object
       -s | --show             show currently selected object

            --expire           expire the state and user db
                               see the following arguments
            --keepuser t       keep anon. users this long



( run in 1.193 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )