summaryrefslogtreecommitdiffstats
path: root/perl-install/any.pm
blob: 5b2fef5c34c2d8c888fe5a8b225fe6d6ebfb6826 (plain)
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
package any;

use diagnostics;
use strict;

#-######################################################################################
#- misc imports
#-######################################################################################
use common qw(:file :system :common :functional);

sub addKdmUsers {
    my ($prefix, @users) = @_;
    require timezone;
    my @u1 = my @users_male = qw(tie default curly);
    my @u2 = my @users_female = qw(brunette girl woman-blond);
    foreach (@users) {
	my $l = rand() < timezone::sexProb($_->{name}) ? \@u2 : \@u1;
	my $u = splice(@$l, rand(@$l), 1); #- known biased (see cookbook for better)
	symlink "../../../../icons/user-$u-mdk.xpm", "$prefix/usr/share/apps/kdm/pics/users/$_.xpm";
	@u1 = @users_male   unless @u1;
	@u2 = @users_female unless @u2;
    }
    symlinkf "../../../../icons/user-hat-mdk.xpm", "$prefix/usr/share/apps/kdm/pics/users/root.xpm" unless $::isStandalone;
}

sub addUsers {
    my ($prefix, @users) = @_;
    my $msec = "$prefix/etc/security/msec";
    foreach my $u (@users) {
	substInFile { s/^$u\n//; $_ .= "$u\n" if eof } "$msec/user.conf" if -d $msec;
    }
    run_program::rooted($prefix, "/etc/security/msec/init-sh/grpuser.sh --refresh");

    addKdmUsers($prefix, @users);
}

1;