Skip to content

Commit

Permalink
Prevent daemons to start at installation on debian like systems.
Browse files Browse the repository at this point in the history
  • Loading branch information
tonioo committed Mar 20, 2021
1 parent 4d64618 commit 6fdf57b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
16 changes: 16 additions & 0 deletions modoboa_installer/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ def preconfigure(self, name, question, qtype, answer):
"""Empty method."""
pass

def prepare_system(self):
pass

def restore_system(self):
pass


class DEBPackage(Package):
"""DEB based operations."""
Expand All @@ -25,6 +31,16 @@ class DEBPackage(Package):
def __init__(self, dist_name):
super(DEBPackage, self).__init__(dist_name)
self.index_updated = False
self.policy_file = "/usr/sbin/policy-rc.d"

def prepare_system(self):
"""Make sure services don't start at installation."""
with open(self.policy_file, "w") as fp:
fp.write("exit 101\n")
utils.exec_cmd("chmod +x {}".format(self.policy_file))

def restore_system(self):
utils.exec_cmd("rm -f {}".format(self.policy_file))

def update(self):
"""Update local cache."""
Expand Down
2 changes: 2 additions & 0 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def main(input_args):
"The process can be long, feel free to take a coffee "
"and come back later ;)", utils.BLUE)
utils.printcolor("Starting...", utils.GREEN)
package.backend.prepare_system()
package.backend.install_many(["sudo", "wget"])
ssl_backend = ssl.get_backend(config)
if ssl_backend and not args.upgrade:
Expand All @@ -126,6 +127,7 @@ def main(input_args):
scripts.install("postfix", config, args.upgrade)
scripts.install("dovecot", config, args.upgrade)
system.restart_service("cron")
package.backend.restore_system()
utils.printcolor(
"Congratulations! You can enjoy Modoboa at https://{} (admin:password)"
.format(config.get("general", "hostname")),
Expand Down

0 comments on commit 6fdf57b

Please sign in to comment.