# Copyright (C) 2018 VyOS maintainers and contributors
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
# published by the Free Software Foundation.
#
# 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 <http://www.gnu.org/licenses/>.
#
#
import sys
import os
import stat
import pwd
+import copy
+import glob
import jinja2
import vyos.validate
from vyos.config import Config
from vyos import ConfigError
-config_file = r'/etc/default/tftpd-hpa'
+config_file = r'/etc/default/tftpd'
# Please be careful if you edit the template.
config_tmpl = """
### Autogenerated by tftp_server.py ###
+DAEMON_ARGS="--listen --user tftp --address {% for a in listen-%}{{ a }}{% endfor %} --secure{% if allow_upload %} --create --umask 000{% endif %} {{ directory }}"
-# See manual at https://linux.die.net/man/8/tftpd
-
-TFTP_USERNAME="tftp"
-TFTP_DIRECTORY="{{ directory }}"
-{% if listen_ipv4 and listen_ipv6 -%}
-TFTP_ADDRESS="{% for a in listen_ipv4 -%}{{ a }}:{{ port }}{{- " --address " if not loop.last -}}{% endfor -%} {% for a in listen_ipv6 %} --address [{{ a }}]:{{ port }}{% endfor -%}"
-{% elif listen_ipv4 -%}
-TFTP_ADDRESS="{% for a in listen_ipv4 -%}{{ a }}:{{ port }}{{- " --address " if not loop.last -}}{% endfor %} -4"
-{% elif listen_ipv6 -%}
-TFTP_ADDRESS="{% for a in listen_ipv6 -%}[{{ a }}]:{{ port }}{{- " --address " if not loop.last -}}{% endfor %} -6"
-{%- endif %}
-
-TFTP_OPTIONS="--secure {% if allow_upload %}--create --umask 000{% endif %}"