5 # dump_database.pl - script to dump data from the database to flat files so the ofher perl
6 # scripts can process it without needing to access the database.
9 require("/usr/lib/sourceforge/lib/include.pl"); # Include all the predefined functions
16 # Dump the users Table information
17 #my $query = "select unix_uid, unix_status, user_name, shell, unix_pw, realname from users where unix_status != \"N\"";
18 my $query = "select unix_uid, unix_status, user_name, shell, unix_pw, realname from users where unix_status != 'N'";
19 my $c = $dbh->prepare($query);
22 while(my ($id, $status, $username, $shell, $passwd, $realname) = $c->fetchrow()) {
23 $home_dir = $homedir_prefix.$username;
25 $userlist = "$id:$status:$username:$shell:$passwd:$realname\n";
27 push @user_array, $userlist;
31 # Dump the Groups Table information
32 $query = "select group_id,unix_group_name,status from groups";
33 $c = $dbh->prepare($query);
36 while(my ($group_id, $group_name, $status) = $c->fetchrow()) {
38 my $new_query = "select users.user_name AS user_name FROM users,user_group WHERE users.user_id=user_group.user_id AND group_id=$group_id";
39 my $d = $dbh->prepare($new_query);
44 while($user_name = $d->fetchrow()) {
45 $user_list .= "$user_name,";
48 $grouplist = "$group_name:$status:$group_id:$user_list\n";
51 push @group_array, $grouplist;
54 # Now write out the files
55 write_array_file($file_dir."dumps/user_dump", @user_array);
56 write_array_file($file_dir."dumps/group_dump", @group_array);