forked from jasontibbitts/majordomo
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpostinstall
121 lines (96 loc) · 3.2 KB
/
postinstall
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# Post-installation script for Majordomo
# Basic functions:
# 1. Create the list hierarchy if necessary.
# 2. Make sure the permissions and ownerships are proper.
# 3. Convert 1.x lists.
# (etc. Perhaps spit out aliases?)
use DirHandle;
use Data::Dumper;
require "./setup/query_util.pl";
require "./setup/install_util.pl";
require "./setup/setup_func.pl";
# We call mj_shell (which we make sure has the right permissions) to do the
# dirty work; it would be possible to include the routines directly, but
# this makes sure that everything was installed correctly. It's better to
# bomb here than to let a bad installation slip by.
$config = eval { require "./.mj_config" };
die retr_msg('no_mj_config', $lang)
unless $config;
$lang ||= $config->{'language'};
#@dirs = (); %files = (); # Silence warning.
# die "Can't get file index, $!"
# unless eval { require "./files/INDEX.pl" };
# Pull some variables from the environment
$ask = $ENV{ASK};
$skip = $ENV{SKIP};
$verb = $ENV{VERBOSE};
$quiet = $ENV{QUIET};
$| = 1;
# List of script files to be installed.
@sidscripts = (qw(mj_shell mj_confirm mj_shutdown mj_wwwadm mj_wwwusr));
@scripts = (qw(mj_trigger mj_queueserv mj_queuerun mj_setup));
if ($config->{mta} eq 'sendmail' or $config->{mta} eq 'qmail' or $config->{mta} eq 'opensmtpd') {
push @sidscripts, qw(mj_email mj_enqueue);
}
else {
push @scripts, qw(mj_email mj_enqueue);
}
set_script_perms(\@sidscripts, \@scripts);
if ($config->{cgi_bin}) {
copy_file('mj_confirm', "$config->{install_dir}/bin",
$config->{cgi_bin}, $config->{cgi_link});
copy_file('mj_wwwadm', "$config->{install_dir}/bin",
$config->{cgi_bin}, $config->{cgi_link});
copy_file('mj_wwwusr', "$config->{install_dir}/bin",
$config->{cgi_bin}, $config->{cgi_link});
}
# Create list directories and such
create_dirs($config->{'lists_dir'},
scalar getpwnam($config->{'uid'}),
scalar getgrnam($config->{'gid'}),
$config->{'umask'},
$config->{'domains'},
$config->{'tmpdir'},
);
# Install response files
install_response_files();
# Make the site config
do_site_config();
# Configure a few global parameters
if (!$skip && (!$ask || get_bool(retr_msg('global_config', $lang)))) {
for my $i (@{$config->{'domains'}}) {
do_default_config($i);
install_config_templates($config, $i);
}
}
# Convert lists if desired
# Give some basic MTA configuration
mta_setup(@{$config->{'domains'}}) unless $skip;
if ($config->{sendmail_make_symlinks}) {
print retr_msg('link_alias_files', $lang);
for my $i (@{$config->{'domains'}}) {
make_alias_symlinks($i, $config->{sendmail_symlink_location});
˙
}
print ".ok\n";
}
if (!$skip && !$quiet && -t STDIN) {
print retr_msg('crontab_head', $lang, 'UID' => $config->{'uid'});
}
open OUT, ">$config->{install_dir}/majordomo.crontab" or
die "Cannot open sample crontab file: $!";
my $ct;
$ct = suggest_crontab();
print $ct if -t STDIN && (!$skip && !$quiet);
print OUT $ct;
close OUT;
chownmod(scalar getpwnam($config->{'uid'}),
scalar getgrnam($config->{'gid'}), 0755,
"$config->{install_dir}/majordomo.crontab");
exit;
$verb = 0; # Quiet warning
1;
#
### Local Variables: ***
### cperl-indent-level:2 ***
### End: ***