summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2024-07-22 20:13:52 +0200
committerGitHub <noreply@github.com>2024-07-22 20:13:52 +0200
commit1f5cb9d01536f2005f80e94845972e90dfcdd0fd (patch)
treed4f9d9a812b627090f07b0e4401f88737762be58 /src
parent748fb96319cc700dec9e8838e7162ec60d9b2c25 (diff)
parent2f52106dc160f217d6e27da45674c0231a93382a (diff)
downloadvyos-1x-1f5cb9d01536f2005f80e94845972e90dfcdd0fd.tar.gz
vyos-1x-1f5cb9d01536f2005f80e94845972e90dfcdd0fd.zip
Merge pull request #3827 from HollyGurza/T6525
T6525: Add default dir for ext-scripts without absolute path
Diffstat (limited to 'src')
-rwxr-xr-xsrc/conf_mode/service_snmp.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/conf_mode/service_snmp.py b/src/conf_mode/service_snmp.py
index 6f025cc23..c9c0ed9a0 100755
--- a/src/conf_mode/service_snmp.py
+++ b/src/conf_mode/service_snmp.py
@@ -41,6 +41,7 @@ config_file_client = r'/etc/snmp/snmp.conf'
config_file_daemon = r'/etc/snmp/snmpd.conf'
config_file_access = r'/usr/share/snmp/snmpd.conf'
config_file_user = r'/var/lib/snmp/snmpd.conf'
+default_script_dir = r'/config/user-data/'
systemd_override = r'/run/systemd/system/snmpd.service.d/override.conf'
systemd_service = 'snmpd.service'
@@ -85,8 +86,20 @@ def get_config(config=None):
tmp = {'::1': {'port': '161'}}
snmp['listen_address'] = dict_merge(tmp, snmp['listen_address'])
+ if 'script_extensions' in snmp and 'extension_name' in snmp['script_extensions']:
+ for key, val in snmp['script_extensions']['extension_name'].items():
+ if 'script' not in val:
+ continue
+ script_path = val['script']
+ # if script has not absolute path, use pre configured path
+ if not os.path.isabs(script_path):
+ script_path = os.path.join(default_script_dir, script_path)
+
+ snmp['script_extensions']['extension_name'][key]['script'] = script_path
+
return snmp
+
def verify(snmp):
if 'deleted' in snmp:
return None