Request: OMV only partially rewrite /etc/hosts

  • Hi,


    Today, OMV is fully managing /etc/hosts, which means we cannot define custom entries into it. A solution mentioned in this thread suggests to change things at the DNS server level (in dnsmasq or whatever DNS server is used), but this is not always doable or recommendable.


    Would it be possible that OMV scripts only change /etc/hosts within some markers within the file? I think OMV already does that in some other file (sorry, can't remember which) where the content is only reset between the two lines # <<<< and # >>>>, letting the other user-specific lines unchanged.


    Thank you!

  • votdev

    Added the Label resolved
  • votdev

    Added the Label OMV 5.x
  • So nice, so powerful... Thank you votdev . Yet, my original suggestion looks a little simplier. What do you think about it? Or you may have so many things to do...


    For memo (if others were looking for it), a file where OMV is partially writing is /etc/fstab, where the OMV-written part is enclosed between

    Code
    # >>> [openmediavault]
    [... bla bla bla]
    # <<< [openmediavault]
    [here, is your own fstab mounts]
  • you could just a file (/srv/salt/omv/deploy/hosts/20myentries.sls) like the following and then maintain your entries in /etc/hosts2


    Code
    {% set hosts = salt['cmd.shell']('cat /etc/hosts2') %}
    append_custom_hosts:
    file.append:
    - name: "/etc/hosts"
    - text: {{ hosts }}

    omv 5.6.12 usul | 64 bit | 5.11 proxmox kernel | omvextrasorg 5.6.2 | kvm plugin 5.1.6
    omv-extras.org plugins source code and issue tracker - github


    Please read this before posting a question.
    Please don't PM for support... Too many PMs!

  • you could just a file (/srv/salt/omv/deploy/hosts/20myentries.sls) like the following and then maintain your entries in /etc/hosts2

    Does anything else need to be done to make this take effect?

    --
    Google is your friend and Bob's your uncle!


    OMV AMD64 5.x on ASRock Rack C2550D4I C0 Stepping - 16GB ECC - Silverstone DS380 + Silverstone DS380 DAS Box.

  • Thanks, just the info I needed for this problem:

    No it isn't. You will break apt-get update if the repo file points to an invalid ip. Just: sudo truncate -s 0 /etc/apt/sources.list.d/vscode.list

    RE: Microsoft repo installed on all Raspberry Pi’s

    omv 5.6.12 usul | 64 bit | 5.11 proxmox kernel | omvextrasorg 5.6.2 | kvm plugin 5.1.6
    omv-extras.org plugins source code and issue tracker - github


    Please read this before posting a question.
    Please don't PM for support... Too many PMs!

  • No it isn't. You will break apt-get update if the repo file points to an invalid ip. Just: sudo truncate -s 0 /etc/apt/sources.list.d/vscode.list

    RE: Microsoft repo installed on all Raspberry Pi’s

    Thanks, I first commented out the active line in that file, I just believe in belt and suspenders where some companies are involved. If it breaks apt update, I'll know it got reactivated without my knowledge or permission.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!