mirror of
https://github.com/beclab/Olares
synced 2026-05-23 16:58:26 +00:00
fix(cli): remove state files of olaresd when uninstalling (#1530)
This commit is contained in:
parent
1aecc3495a
commit
5edba60295
2 changed files with 17 additions and 18 deletions
|
|
@ -133,8 +133,11 @@ type DisableTerminusdService struct {
|
|||
}
|
||||
|
||||
func (s *DisableTerminusdService) Execute(runtime connector.Runtime) error {
|
||||
if _, err := runtime.GetRunner().SudoCmd("systemctl disable --now olaresd", false, true); err != nil {
|
||||
return errors.Wrap(errors.WithStack(err), "disable olaresd failed")
|
||||
stdout, _ := runtime.GetRunner().SudoCmd("systemctl is-active olaresd", false, false)
|
||||
if stdout == "active" {
|
||||
if _, err := runtime.GetRunner().SudoCmd("systemctl disable --now olaresd", false, true); err != nil {
|
||||
return errors.Wrap(errors.WithStack(err), "disable olaresd failed")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -144,10 +147,18 @@ type UninstallTerminusd struct {
|
|||
}
|
||||
|
||||
func (r *UninstallTerminusd) Execute(runtime connector.Runtime) error {
|
||||
var olaresdFiles []string
|
||||
svcpath := filepath.Join("/etc/systemd/system", templates.TerminusdService.Name())
|
||||
svcenvpath := filepath.Join("/etc/systemd/system", templates.TerminusdEnv.Name())
|
||||
if _, err := runtime.GetRunner().SudoCmd(fmt.Sprintf("rm -rf %s && rm -rf %s && rm -rf /usr/local/bin/olaresd", svcpath, svcenvpath), false, false); err != nil {
|
||||
return errors.Wrap(errors.WithStack(err), "remove olaresd failed")
|
||||
binPath := "/usr/local/bin/olaresd"
|
||||
olaresdFiles = append(olaresdFiles, svcpath, svcenvpath, binPath)
|
||||
for _, pidFile := range []string{"installing.pid", "changingip.pid"} {
|
||||
olaresdFiles = append(olaresdFiles, filepath.Join(runtime.GetBaseDir(), pidFile))
|
||||
}
|
||||
for _, f := range olaresdFiles {
|
||||
if _, err := runtime.GetRunner().SudoCmd(fmt.Sprintf("rm -rf %s", f), false, false); err != nil {
|
||||
return errors.Wrap(errors.WithStack(err), "remove olaresd failed")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -133,24 +133,13 @@ func (p *phaseBuilder) phasePrepare() *phaseBuilder {
|
|||
PhaseFile: common.TerminusStateFilePrepared,
|
||||
BaseDir: p.runtime.GetBaseDir(),
|
||||
},
|
||||
&daemon.UninstallTerminusdModule{},
|
||||
&terminus.RemoveReleaseFileModule{},
|
||||
)
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
func (p *phaseBuilder) phaseDownload() *phaseBuilder {
|
||||
terminusdAction := &daemon.CheckTerminusdService{}
|
||||
err := terminusdAction.Execute()
|
||||
|
||||
if p.convert() >= PhaseDownload {
|
||||
if err == nil {
|
||||
p.modules = append(p.modules, &daemon.UninstallTerminusdModule{})
|
||||
}
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
func (p *phaseBuilder) phaseMacos() {
|
||||
p.modules = []module.Module{
|
||||
&precheck.GreetingsModule{},
|
||||
|
|
@ -178,8 +167,7 @@ func UninstallTerminus(phase string, runtime *common.KubeRuntime) pipeline.Pipel
|
|||
builder.
|
||||
phaseInstall().
|
||||
phaseStorage().
|
||||
phasePrepare().
|
||||
phaseDownload()
|
||||
phasePrepare()
|
||||
}
|
||||
|
||||
return pipeline.Pipeline{
|
||||
|
|
|
|||
Loading…
Reference in a new issue