]> git.somenet.org - root/pub/somesible.git/blob - roles/base/apt/templates/policy-rc.d.j2
[roles/base/apt] configure package manager + update pkg-cache + upgrade packages
[root/pub/somesible.git] / roles / base / apt / templates / policy-rc.d.j2
1 #!/usr/bin/env -S python3 -Bu
2 ################################################
3 ### Managed by someone's ansible provisioner ###
4 ################################################
5 # Part of: https://git.somenet.org/root/pub/somesible.git
6 # 2017-2024 by someone <someone@somenet.org>
7 #
8 # Prevent apt/dpkg from (re)starting services we manage.
9 #
10 ##############
11 ### UNUSED ###
12 ### DELME? ###
13 ##############
14 import datetime
15 import os
16 import re
17 import sys
18
19 os.umask(0o077)
20
21 MANAGED_SERVICES = set("{{apt_ansible_managed_services | join(' ')}} {{apt_ansible_managed_services_extra | join(' ')}}".replace(".service","").split(" "))
22 SERVICE = re.sub(r"@.*", "", re.sub(r"\.service", "", sys.argv[1]))
23
24
25 if SERVICE in MANAGED_SERVICES:
26     with open("/tmp/policy-rc.d.log", "a") as fout:
27         fout.write(datetime.datetime.now().isoformat(timespec='seconds')+" -- managed, exit 101: " +str(sys.argv)+"\n")
28     sys.exit(101)
29
30
31 with open("/tmp/policy-rc.d.log", "a") as fout:
32     fout.write(datetime.datetime.now().isoformat(timespec='seconds')+" -- unmanaged, exit 0: " +str(sys.argv)+"\n")
33
34 sys.exit(0)