@@ -249,55 +249,55 @@ function update($event_name, $data) {
249249 $ app ->log ('Network configuration disabled in server settings. ' , LOGLEVEL_DEBUG );
250250 }
251251 }
252-
252+
253253 //* Configure hostname
254- if ($ event_name == 'server_update ' && $ data [ ' mirrored ' ] == false ) {
255-
254+ if ($ event_name == 'server_update ' && $ conf [ ' mirror_server_id ' ] == 0 ) {
255+
256256 //* get old server config
257257 $ tmp = $ app ->ini_parser ->parse_ini_string (stripslashes ($ data ['old ' ]['config ' ]));
258258 $ old_server_config = $ tmp ['server ' ];
259259 unset($ tmp );
260-
260+
261261 $ new_hostname = trim ($ server_config ['hostname ' ]);
262262 $ old_hostname = trim ($ old_server_config ['hostname ' ]);
263-
263+
264264 if ($ new_hostname != '' && $ old_hostname != $ new_hostname ) {
265-
265+
266266 if (is_file ('/etc/hostname ' )) {
267267 $ app ->system ->file_put_contents ('/etc/hostname ' ,$ new_hostname );
268268 $ app ->log ('Changed /etc/hostname to ' .$ new_hostname , LOGLEVEL_DEBUG );
269269 }
270-
270+
271271 if (is_file ('/etc/mailname ' )) {
272272 $ app ->system ->file_put_contents ('/etc/mailname ' ,$ new_hostname );
273273 $ app ->log ('Changed /etc/mailname to ' .$ new_hostname , LOGLEVEL_DEBUG );
274274 }
275-
275+
276276 $ postconf_commands = array (
277277 'myhostname = ' .$ new_hostname ,
278278 'mydestination = ' .$ new_hostname .', localhost, localhost.localdomain '
279279 );
280-
280+
281281 //* Executing the postconf commands
282282 foreach ($ postconf_commands as $ cmd ) {
283283 $ command = "postconf -e ? " ;
284284 $ app ->system ->exec_safe ($ command , $ cmd );
285285 }
286-
286+
287287 $ app ->log ('Changed changed myhostname and mydestination in postfix main.cf to ' .$ new_hostname , LOGLEVEL_DEBUG );
288-
288+
289289 //* change /etc/hosts
290290 $ hosts = file_get_contents ('/etc/hosts ' );
291291 $ hosts = str_replace ($ old_hostname ,$ new_hostname ,$ hosts );
292292 $ app ->system ->file_put_contents ('/etc/hosts ' ,$ hosts );
293-
293+
294294 exec ($ app ->system ->getinitcommand ('postfix ' , 'restart ' ).' 2>&1 ' );
295295 exec ($ app ->system ->getinitcommand ('networking ' , 'restart ' ).' 2>&1 ' );
296-
296+
297297 }
298-
298+
299299 }
300-
300+
301301
302302 }
303303
0 commit comments