%PDF-1.5 %���� ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY
Server IP : 188.40.95.74 / Your IP : 216.73.216.188 Web Server : Apache System : Linux cp01.striminghost.net 3.10.0-1160.119.1.el7.tuxcare.els13.x86_64 #1 SMP Fri Nov 22 06:29:45 UTC 2024 x86_64 User : vlasotin ( 1054) PHP Version : 5.6.40 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/share/leapp-repository/repositories/system_upgrade/common/actors/createresumeservice/ |
Upload File : |
import os import shutil from leapp import reporting from leapp.actors import Actor from leapp.exceptions import StopActorExecutionError from leapp.libraries.stdlib import api from leapp.reporting import create_report, Report from leapp.tags import FinalizationPhaseTag, IPUWorkflowTag class CreateSystemdResumeService(Actor): """ Add a systemd service to launch Leapp. Create a systemd service which will resume Leapp upgrade after the first reboot. """ name = 'create_systemd_service' consumes = () produces = (Report,) tags = (FinalizationPhaseTag, IPUWorkflowTag) def process(self): service_name = 'leapp_resume.service' systemd_dir = '/etc/systemd/system' service_templ_fpath = self.get_file_path(service_name) shutil.copyfile(service_templ_fpath, os.path.join(systemd_dir, service_name)) service_path = '/etc/systemd/system/{}'.format(service_name) symlink_path = '/etc/systemd/system/default.target.wants/{}'.format(service_name) # in case nothing is enabled in the default target, the directory does not exist try: os.mkdir(os.path.join(systemd_dir, 'default.target.wants')) except OSError: pass if os.path.exists(symlink_path): api.current_logger().debug( 'Symlink {} already exists (from previous upgrade?). Removing... '.format(symlink_path) ) os.unlink(symlink_path) try: os.symlink(service_path, symlink_path) except OSError as e: raise StopActorExecutionError( 'Could not create a symlink to enable {}'.format(service_name), details={"details": str(e)}) create_report([ reporting.Title('Leapp resume systemd service enabled'), reporting.Summary( '{} enabled as oneshot systemd service to resume Leapp execution ' 'after reboot.'.format(service_name) ), reporting.Severity(reporting.Severity.INFO), reporting.Groups([reporting.Groups.UPGRADE_PROCESS]), reporting.RelatedResource('file', service_path), reporting.RelatedResource('file', symlink_path), reporting.RelatedResource('service', service_name) ])