55from leapp .reporting import Report , create_report
66from leapp .tags import FirstBootPhaseTag , IPUWorkflowTag
77from leapp .libraries .common .cllaunch import run_on_cloudlinux
8+ from leapp .models import InstalledControlPanel
9+
10+ from leapp .libraries .common .detectcontrolpanel import DIRECTADMIN_NAME
811
912
1013class UpdateDirectAdmin (Actor ):
@@ -13,21 +16,27 @@ class UpdateDirectAdmin(Actor):
1316 """
1417
1518 name = 'update_directadmin'
16- consumes = ()
19+ consumes = (InstalledControlPanel , )
1720 produces = (Report ,)
1821 tags = (FirstBootPhaseTag , IPUWorkflowTag )
1922
2023 @run_on_cloudlinux
2124 def process (self ):
22- if os .path .exists ('/bin/da' ):
23- try :
24- run (['/bin/da' , 'build' , 'all' ], checked = True )
25- self .log .info ('DirectAdmin update was successful' )
26- except CalledProcessError as e :
27- self .log .error (
28- 'Command "da build all" finished with exit code {}, '
29- 'the system might be unstable.\n '
30- 'Check /usr/local/directadmin/custombuild/custombuild.log, '
31- 'rerun "da build all" after fixing the issues. '
32- 'Contact DirectAdmin support for help.' .format (e .exit_code )
33- )
25+ panel = next (self .consume (InstalledControlPanel ), None )
26+ if panel is None :
27+ raise StopActorExecutionError (message = ("Missing information about the installed web panel." ))
28+
29+ if panel .name != DIRECTADMIN_NAME :
30+ self .log .debug ('DirectAdmin not detected, skip rebuilding' )
31+
32+ try :
33+ run (['/bin/da' , 'build' , 'all' ], checked = True )
34+ self .log .info ('DirectAdmin update was successful' )
35+ except CalledProcessError as e :
36+ self .log .error (
37+ 'Command "da build all" finished with exit code {}, '
38+ 'the system might be unstable.\n '
39+ 'Check /usr/local/directadmin/custombuild/custombuild.log, '
40+ 'rerun "da build all" after fixing the issues. '
41+ 'Contact DirectAdmin support for help.' .format (e .exit_code )
42+ )
0 commit comments