summaryrefslogtreecommitdiff
path: root/branding/scripts/check
diff options
context:
space:
mode:
authorkali kaneko (leap communications) <kali@leap.se>2020-10-09 18:53:11 +0200
committerRuben Pollan <meskio@sindominio.net>2020-10-13 19:08:54 +0200
commit73d0c7a96df2212d5a3ee6289fc286f3e6459028 (patch)
treed304904b19b1ef365213876a60e19e232a36c95a /branding/scripts/check
parente4a2efb527fb09b548c14b13d28d0780941ca72d (diff)
[pkg] refactor vendor init/check
Diffstat (limited to 'branding/scripts/check')
-rwxr-xr-xbranding/scripts/check62
1 files changed, 61 insertions, 1 deletions
diff --git a/branding/scripts/check b/branding/scripts/check
index 07b2a71..aab962e 100755
--- a/branding/scripts/check
+++ b/branding/scripts/check
@@ -1,4 +1,64 @@
#!/usr/bin/env python3
+import os
+import sys
+
+# TODO check file list
+# TODO remove fom README
+
+VENDOR_PATH = None
+
+def getVendorPath():
+ global VENDOR_PATH
+ VENDOR_PATH = os.environ.get("VENDOR_PATH")
+ if not VENDOR_PATH:
+ print("[ERROR] VENDOR_PATH not set")
+ sys.exit(1)
+
+ if not os.path.isdir(os.path.abspath(VENDOR_PATH)):
+ print("[ERROR] VENDOR_PATH folder does not exist:", VENDOR_PATH)
+ sys.exit(1)
+
+def checkCAFile(provider):
+ caFile = os.path.join(os.path.abspath(VENDOR_PATH), provider, provider + '-ca.crt')
+ if not os.path.isfile(caFile):
+ print("ERROR: Missing provider CA file:", caFile)
+ sys.exit(1)
+ print('[+] CA file ok:', caFile)
+
+def checkAssets(provider):
+ top = os.path.join(os.path.abspath(VENDOR_PATH), 'assets')
+ if os.path.isdir(top):
+ ok = checkAssetFiles(top)
+ if ok:
+ return
+ under = os.path.join(os.path.abspath(VENDOR_PATH), provider, 'assets')
+ if os.path.isdir(under):
+ ok = checkAssetFiles(under)
+ if ok:
+ return
+ print('[!] ERROR: cannot find some assets for provider {provider}'.format(provider=provider))
+ sys.exit(1)
+
+def checkAssetFiles(path):
+ for item in allAssets():
+ asset = os.path.join(path, item)
+ if not os.path.isfile(asset):
+ print("[!] Error: missing asset file:", asset)
+ return False
+ return True
+
+def allAssets():
+ with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "ASSETS_REQUIRED")) as f:
+ allAssets = f.readlines()
+ return list(map(lambda s: s.strip(), allAssets))
+
if __name__ == "__main__":
- print("[+] Checking your provider config... (WIP)")
+ print("[+] Checking your provider config...")
+ provider = sys.argv[1]
+ if not provider:
+ print("ERROR: must pass provider as first argument")
+ sys.exit(1)
+ getVendorPath()
+ checkCAFile(provider)
+ checkAssets(provider)