/[smecontribs]/rpms/smeserver-affa/contribs10/smeserver-affa-change-host-domain.patch
ViewVC logotype

Contents of /rpms/smeserver-affa/contribs10/smeserver-affa-change-host-domain.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download)
Sun Nov 12 13:53:07 2023 UTC (11 months, 2 weeks ago) by jcrisp
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -0 lines
Error occurred while calculating annotation data.
FILE REMOVED
Import smeserver-affa-4

1 diff -ruN smeserver-affa-3.3.1.old/root/sbin/affa smeserver-affa-3.3.1/root/sbin/affa
2 --- smeserver-affa-3.3.1.old/root/sbin/affa 2021-09-21 17:52:05.129189459 +0200
3 +++ smeserver-affa-3.3.1/root/sbin/affa 2021-09-21 17:52:27.836562454 +0200
4 @@ -184,6 +184,7 @@
5 my $configDB = esmith::ConfigDB->open or die "Error: Couldn't open config db.";
6 my $LocalIP = $configDB->get("LocalIP")->value;
7 my $DomainName = $configDB->get("DomainName")->value;
8 +my $SystemName = $configDB->get("SystemName")->value;
9
10 my $rpmlist = "/home/e-smith/db/affa-rpmlist"; # list of installed RPMs
11
12 @@ -195,22 +196,9 @@
13
14 my $ServerBasename = "AFFA.$SystemName.$DomainName-$LocalIP";
15
16 -############## fin ajouts
17 -####################################################################################
18 -
19 my $allow_retry = 0;
20 my $defaultEmail = 'admin';
21
22 -my $SystemName = hostname();
23 -( my $Domain = $SystemName ) =~ s/([^\.]*)\.//;
24 -
25 -####################################################################################
26 -############# début modifs
27 -#my $hostname=$1;
28 -my $hostname = $SystemName;
29 -############# fin modifs
30 -####################################################################################
31 -
32 my $affaTitle = "Affa version $VERSION on $SystemName";
33 my $smbconf = '/etc/samba/smb.conf';
34
35 @@ -1909,7 +1897,7 @@
36 return -1;
37 }
38 if ( $nrpeStatus ne 'enabled' ) {
39 - lg("NRPE service is not running.")
40 + lg("NRPE service is not running.") ;
41 return;
42 }
43 open( FO, ">$af" );
44 @@ -2661,9 +2649,9 @@
45 $needed = int( $needed * 0.1 ) if $job{'DiskSpaceWarn'} eq 'risky';
46 if ( $avail < $needed ) {
47 my $msg = new Mail::Send;
48 - $msg->subject("Warning: Affa server $hostname running out of disk space!");
49 + $msg->subject("Warning: Affa server $SystemName running out of disk space!");
50 $msg->to( $job{'_EmailAddress'} );
51 - $msg->set( "From", "\"Affa Server $hostname\" <noreply\@$Domain>" );
52 + $msg->set( "From", "\"Affa Server $SystemName\" <noreply\@$DomainName>" );
53 my $s;
54 my $fh = $msg->open;
55 print $fh "This message was sent by job '$jobname'.\n";
56 @@ -3582,9 +3570,9 @@
57 if ( $job{'sendStatus'} || '' =~ /^(daily|weekly|monthly)$/ ) {
58 $job{'sendStatus'} = ucfirst( $job{'sendStatus'} );
59 my $msg = new Mail::Send;
60 - $msg->subject("$job{'sendStatus'} status from Affa server $hostname");
61 + $msg->subject("$job{'sendStatus'} status from Affa server $SystemName");
62 $msg->to( $job{'_EmailAddress'} );
63 - $msg->set( "From", "\"Affa Server $hostname\" <noreply\@$Domain>" );
64 + $msg->set( "From", "\"Affa Server $SystemName\" <noreply\@$DomainName>" );
65 my $fh = $msg->open;
66 print $fh "Status:\n";
67 print $fh getStatus();
68 @@ -3607,9 +3595,9 @@
69 }
70 my %job = getJobConfig($jobname);
71 my $msg = new Mail::Send;
72 - $msg->subject("Testmail from job '$jobname' on Affa server $hostname");
73 + $msg->subject("Testmail from job '$jobname' on Affa server $SystemName");
74 $msg->to( $job{'_EmailAddress'} );
75 - $msg->set( "From", "\"Affa Server $hostname\" <noreply\@$Domain>" );
76 + $msg->set( "From", "\"Affa Server $SystemName\" <noreply\@$DomainName>" );
77 my $fh = $msg->open;
78 print $fh "It works!\n\n";
79 $fh->close;
80 @@ -3635,65 +3623,81 @@
81
82 sub setupSamba() {
83 lg("Configuring Samba");
84 - if ( $smbdStatus ne 'enabled' ) lg("Samba service is not installed or not properly configured.");
85 - return;
86 -}
87 -my %inc;
88 -foreach my $jobname ( $cfg->Sections() ) {
89 - next if $jobname eq 'GlobalAffaConfig';
90 - my %job = getJobConfig($jobname);
91 - if ( not $job{'_SambaValidUser'} and $job{'SambaShare'} eq 'yes' ) {
92 - lg("Job $jobname: No Valid Users defined. Samba has been access disabled.");
93 - }
94 - my $affasmb = "/etc/samba/Affa-Job-$jobname.conf";
95 - if ( $job{'SambaShare'} eq 'yes' and $job{'_SambaValidUser'} ) {
96 - open( FD, ">$affasmb" ) or affaErrorExit("Could not create $affasmb");
97 - print FD "[$jobname]\n";
98 - print FD "path = $job{'RootDir'}/$jobname\n";
99 - print FD "comment = Affa archive: $job{'Description'}\n";
100 - print FD "valid users = $job{'_SambaValidUser'}\n";
101 - print FD "force user = root\n";
102 - print FD "read only = yes\n";
103 - print FD "writable = no\n";
104 - print FD "veto files = /.$jobname-setup.ini/,/.doneDates/,/.AFFA3-REPORT/,/.AFFA-REPORT/.AFFA-TRASH/\n\n";
105 - close(FD);
106 - $inc{"include = $affasmb"} = 1;
107 - }
108 - else {
109 - unlink($affasmb);
110 + if ( $smbdStatus ne 'enabled' ) {
111 + lg("Samba service is not installed or not properly configured.");
112 + return;
113 }
114 -}
115
116 -open( FD, "<$smbconf" ) or affaErrorExit("Could not open $smbconf");
117 -open( FW, ">$smbconf.$$" ) or affaErrorExit("Could not create $smbconf.$$");
118 -while (<FD>) {
119 - $_ = trim($_);
120 - if ( $_ =~ /include = (\/etc\/samba\/Affa-Job.*conf)/ and not $inc{$_} ) {
121 - unlink $1;
122 + my %inc;
123 + foreach my $jobname ( $cfg->Sections() ) {
124 + next if $jobname eq 'GlobalAffaConfig';
125 + my %job = getJobConfig($jobname);
126 + if ( not $job{'_SambaValidUser'} and $job{'SambaShare'} eq 'yes' ) {
127 + lg( "Job $jobname: No Valid Users defined. Samba has been access disabled."
128 + );
129 + }
130 + my $affasmb = "/etc/samba/Affa-Job-$jobname.conf";
131 + if ( $job{'SambaShare'} eq 'yes' and $job{'_SambaValidUser'} ) {
132 + open( FD, ">$affasmb" )
133 + or affaErrorExit("Could not create $affasmb");
134 + print FD "[$jobname]\n";
135 + print FD "path = $job{'RootDir'}/$jobname\n";
136 + print FD "comment = Affa archive: $job{'Description'}\n";
137 + print FD "valid users = $job{'_SambaValidUser'}\n";
138 + print FD "force user = root\n";
139 + print FD "read only = yes\n";
140 + print FD "writable = no\n";
141 + print FD
142 + "veto files = /.$jobname-setup.ini/,/.doneDates/,/.AFFA3-REPORT/,/.AFFA-REPORT/.AFFA-TRASH/\n\n";
143 + close(FD);
144 + $inc{"include = $affasmb"} = 1;
145 + }
146 + else {
147 + unlink($affasmb);
148 + }
149 }
150 - print FW "$_\n" if not $_ =~ /(include = \/etc\/samba\/Affa-Job|# Affa archives. Updated on)/;
151
152 - # ligne d'origine - Bug 9298 - if( $_ =~ /^\[global\]$/i ) {
153 - if ( $_ =~ /^#\[Affa-jobs\]$/i ) {
154 - printf FW "# Affa archives. Updated on " . formatHTime( Date::Format::time2str( "%Y%m%d%H%M", time() ) ) . "\n";
155 - print FW join( "\n", sort keys %inc ) . "\n";
156 + open( FD, "<$smbconf" ) or affaErrorExit("Could not open $smbconf");
157 + open( FW, ">$smbconf.$$" )
158 + or affaErrorExit("Could not create $smbconf.$$");
159 + while (<FD>) {
160 + $_ = trim($_);
161 + if ( $_ =~ /include = (\/etc\/samba\/Affa-Job.*conf)/
162 + and not $inc{$_} )
163 + {
164 + unlink $1;
165 + }
166 + print FW "$_\n"
167 + if not $_
168 + =~ /(include = \/etc\/samba\/Affa-Job|# Affa archives. Updated on)/;
169 +
170 + # ligne d'origine - Bug 9298 - if( $_ =~ /^\[global\]$/i ) {
171 + if ( $_ =~ /^#\[Affa-jobs\]$/i ) {
172 + printf FW "# Affa archives. Updated on "
173 + . formatHTime(
174 + Date::Format::time2str( "%Y%m%d%H%M", time() ) )
175 + . "\n";
176 + print FW join( "\n", sort keys %inc ) . "\n";
177 + }
178 }
179 -}
180 -close(FD);
181 -close(FW);
182 + close(FD);
183 + close(FW);
184 +
185 + rename( "$smbconf.$$", "$smbconf" )
186 + or affaErrorExit("Moving $smbconf.$$ to $smbconf failed");
187
188 -rename( "$smbconf.$$", "$smbconf" ) or affaErrorExit("Moving $smbconf.$$ to $smbconf failed");
189 #my @cmd = ( $servicecommand, 'smb', 'reload' ); # reetp changed to restart
190 #ExecCmd( @cmd, 0 ); # Reload Samba config
191
192 -$systemD->{'serviceName'} = 'smbd';
193 + $systemD->{'serviceName'} = 'smbd';
194
195 -my $smbdStatus = ( $systemD->reload() ); # reetp - failure??
196 + my $smbdStatus = ( $systemD->reload() ); # reetp - failure??
197
198 -print "Status $smbdStatus\n";
199 + print "Status $smbdStatus\n";
200
201 }
202
203 +
204 sub sendErrorMesssage() {
205 return if not $jobname or not $Command;
206 my %job;
207 @@ -3702,9 +3706,9 @@
208 }
209 return if not $job{'_EmailAddress'};
210 my $msg = new Mail::Send;
211 - $msg->subject("Error on Affa server $hostname: Job '$jobname' failed.");
212 + $msg->subject("Error on Affa server $SystemName: Job '$jobname' failed.");
213 $msg->to( $job{'_EmailAddress'} );
214 - $msg->set( "From", "\"Affa Server $hostname\" <noreply\@$Domain>" );
215 + $msg->set( "From", "\"Affa Server $SystemName\" <noreply\@$DomainName>" );
216 my $fh = $msg->open;
217 print $fh "Excerpt from log file $logfile:\n";
218
219 @@ -3730,9 +3734,9 @@
220 if ( not $err );
221 }
222 my $msg = new Mail::Send;
223 - $msg->subject("Success on Affa server $hostname: Job '$jobname' completed.");
224 + $msg->subject("Success on Affa server $SystemName: Job '$jobname' completed.");
225 $msg->to( $job{'_EmailAddress'} );
226 - $msg->set( "From", "\"Affa Server $hostname\" <noreply\@$Domain>" );
227 + $msg->set( "From", "\"Affa Server $SystemName\" <noreply\@$DomainName>" );
228 my $fh = $msg->open;
229 print $fh "Affa job '$jobname' successfully completed.\n\n";
230 print $fh listArchives() . "\n";

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed