Skip to content

Commit

Permalink
f-93: creates constants for service and config dirs
Browse files Browse the repository at this point in the history
Signed-off-by: Aleix Ramírez <[email protected]>
  • Loading branch information
aleixrm committed Nov 25, 2024
1 parent 0c6b9e0 commit 10e1f7e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions appliances/VRouter/DHCP4v2/main.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ module DHCP4v2

ONEAPP_VNF_DHCP4_INTERFACES = env :ONEAPP_VNF_DHCP4_INTERFACES, '' # nil -> none, empty -> all

SERVICE_DIR = '/etc/one-appliance/service.d/VRouter/DHCP4v2/dhcpcore-onelease'
CONFIG_FILE_NAME = 'onelease-config.yml'

def parse_env
@interfaces ||= parse_interfaces ONEAPP_VNF_DHCP4_INTERFACES
@mgmt ||= detect_mgmt_nics
Expand Down Expand Up @@ -103,7 +106,7 @@ def generate_config(basedir, vars)
}
end

file "#{basedir}/onelease-config.yml", config.to_yaml, mode: 'u=rw,g=r,o=', overwrite: true
file "#{basedir}/#{CONFIG_FILE_NAME}", config.to_yaml, mode: 'u=rw,g=r,o=', overwrite: true
end

def install(initdir: '/etc/init.d')
Expand All @@ -113,8 +116,8 @@ def install(initdir: '/etc/init.d')
#!/sbin/openrc-run
source /run/one-context/one_env
BASE_DIR="/etc/one-appliance/service.d/VRouter/DHCP4v2/dhcpcore-onelease"
CONFIG_FILE="$BASE_DIR/onelease-config.yml"
BASE_DIR="#{SERVICE_DIR}"
CONFIG_FILE="$BASE_DIR/#{CONFIG_FILE_NAME}"
SERVICE_EXEC="$BASE_DIR/dhcpcore-onelease"
PIDFILE="/run/$RC_SVCNAME.pid"
LOG_DIR="/var/log/one-appliance"
Expand Down Expand Up @@ -146,7 +149,7 @@ def configure(basedir: '/etc/dhcpcore-onelease')

dhcp4_vars = parse_env

generate_config(basedir, dhcp4_vars)
generate_config(SERVICE_DIR, dhcp4_vars)

end

Expand Down

0 comments on commit 10e1f7e

Please sign in to comment.