diff --git a/src/opnsense/service/modules/addons/template_helpers.py b/src/opnsense/service/modules/addons/template_helpers.py index f4e811b15..81c01fb7c 100644 --- a/src/opnsense/service/modules/addons/template_helpers.py +++ b/src/opnsense/service/modules/addons/template_helpers.py @@ -175,6 +175,18 @@ class Helpers(object): return [lst] return lst + @staticmethod + def file_exists(pathname): + """ + :param pathname: absolute or relative path name depending if it starts with a / + :return: bool + """ + if pathname.startswith('/'): + return os.path.isfile(pathname) + else: + template_path = os.path.realpath("%s/../../templates/" % os.path.dirname(__file__)) + return os.path.isfile("%s/%s" % (template_path, pathname)) + @staticmethod def glob(pathname): """