from .UpdatePfSenseConfiguration import UpdatePfSenseConfiguration
from ..General.CheckForSshSession import CheckForSSHSession
from ..OpsiServer.ApplyCertificatesToOpsi import ApplyCertificatesToOpsi
from ..OpsiServer.CopyCertificates import CopyCertificates
from ..Server.ApplyFreeradiusCert import ApplyFreeradiusCert
from ..Server.RegenerateSslCerts import RegenerateSslCerts
from ..Server.SetupSso import SetupSso as ServerSetupSso
from ..OpsiServer.SetupSso import SetupSso as BackupSetupSso
from ..Server.UpdateAppCerts import UpdateAppCerts
from ...SetupSteps.Playbooks.Playbook import Playbook


class SslSetup(Playbook):
    def start(self):
        if not self.is_sub_playbook:
            self.run_steps(CheckForSSHSession())

        self.run_steps(
            RegenerateSslCerts(),
            # ServerSetupSso(),
            UpdateAppCerts(),
            CopyCertificates(),
            # BackupSetupSso(),
            ApplyCertificatesToOpsi(),
            ApplyFreeradiusCert()
        )

        if not self.is_sub_playbook:
            self.run_sub_playbook(UpdatePfSenseConfiguration)