summaryrefslogtreecommitdiffstats
path: root/libexec/container/version
diff options
context:
space:
mode:
Diffstat (limited to 'libexec/container/version')
-rwxr-xr-xlibexec/container/version56
1 files changed, 56 insertions, 0 deletions
diff --git a/libexec/container/version b/libexec/container/version
new file mode 100755
index 0000000..e567f8f
--- /dev/null
+++ b/libexec/container/version
@@ -0,0 +1,56 @@
+#!/usr/bin/python3
+
+# Open Infrastructure: compute-tools
+
+# Copyright (C) 2014-2023 Daniel Baumann <daniel.baumann@open-infrastructure.net>
+#
+# 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 <https://www.gnu.org/licenses/>.
+
+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()