#!/usr/bin/python3 # Open Infrastructure: compute-tools # Copyright (C) 2014-2023 Daniel Baumann # # SPDX-License-Identifier: GPL-3.0+ # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from os import access, X_OK from pathlib import Path from subprocess import run from sys import exit, stderr, stdout import compute_tools.container as container def main(): # pre hooks pre_hooks = Path('/etc/compute-tools/hooks').glob('pre-version.*') if pre_hooks: # hooks exist for hook in pre_hooks: if access(hook, X_OK): # hook is executable run(str(hook), shell=True, stderr=stderr, stdout=stdout) # run container.print_version() # post hooks post_hooks = Path('/etc/compute-tools/hooks').glob('post-version.*') if post_hooks: # hooks exist for hook in post_hooks: if access(hook, X_OK): # hook is executable run(str(hook), shell=True, stderr=stderr, stdout=stdout) exit(0) if __name__ == '__main__': main()