From d222b267cedd12542ef4cfead2b04e32d0f788b6 Mon Sep 17 00:00:00 2001 From: Anders Ingemann Date: Tue, 7 Jun 2016 19:12:39 +0200 Subject: [PATCH] Also disable autostart for daemons started through upstart --- bootstrapvz/common/tasks/apt.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/bootstrapvz/common/tasks/apt.py b/bootstrapvz/common/tasks/apt.py index 94c69e6..001d588 100644 --- a/bootstrapvz/common/tasks/apt.py +++ b/bootstrapvz/common/tasks/apt.py @@ -144,11 +144,12 @@ class DisableDaemonAutostart(Task): with open(rc_policy_path, 'w') as rc_policy: rc_policy.write(('#!/bin/sh\n' 'exit 101')) - import stat - os.chmod(rc_policy_path, - stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR | - stat.S_IRGRP | stat.S_IXGRP | - stat.S_IROTH | stat.S_IXOTH) + os.chmod(rc_policy_path, 0755) + initictl_path = os.path.join(info.root, 'sbin/initctl') + with open(initictl_path, 'w') as initctl: + initctl.write(('#!/bin/sh\n' + 'exit 0')) + os.chmod(initictl_path, 0755) class AptUpdate(Task): @@ -223,3 +224,4 @@ class EnableDaemonAutostart(Task): @classmethod def run(cls, info): os.remove(os.path.join(info.root, 'usr/sbin/policy-rc.d')) + os.remove(os.path.join(info.root, 'sbin/initctl'))