Class: OsCtld::DistConfig::Distributions::Void::Configurator
- Inherits:
-
Configurator
- Object
- Configurator
- OsCtld::DistConfig::Distributions::Void::Configurator
- Defined in:
- lib/osctld/dist_config/distributions/void.rb
Instance Attribute Summary
Attributes inherited from Configurator
#ctid, #distribution, #network_backend, #rootfs, #version
Instance Method Summary collapse
- #network(netifs) ⇒ Object
- #network_class ⇒ Object protected
- #set_hostname(new_hostname, old_hostname: nil) ⇒ Object
Methods inherited from Configurator
#add_netif, #dns_resolvers, #initialize, #instantiate_network_class, #log_type, #remove_netif, #rename_netif, #unset_etc_hosts, #update_etc_hosts
Methods included from Helpers::Common
#systemd_service_enabled?, #systemd_service_masked?, #writable?
Constructor Details
This class inherits a constructor from OsCtld::DistConfig::Configurator
Instance Method Details
#network(netifs) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/osctld/dist_config/distributions/void.rb', line 35 def network(netifs) tpl_base = 'dist_config/network/void' cmds = netifs.map do |netif| OsCtld::ErbTemplate.render( File.join(tpl_base, netif.type.to_s), { netif: } ) end sv = File.join( rootfs, 'etc/runit/core-services', '90-vpsadminos-network.sh' ) File.write(sv, cmds.join("\n")) if writable?(sv) end |
#network_class ⇒ Object (protected)
55 56 57 |
# File 'lib/osctld/dist_config/distributions/void.rb', line 55 def network_class nil end |
#set_hostname(new_hostname, old_hostname: nil) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/osctld/dist_config/distributions/void.rb', line 8 def set_hostname(new_hostname, old_hostname: nil) # /etc/hostname writable?(File.join(rootfs, 'etc', 'hostname')) do |path| regenerate_file(path, 0o644) do |f| f.puts(new_hostname.local) end end # Hostname in void is set by /etc/runit/core-services/05-misc.sh. # Unfortunately, it tries to set it by writing to /proc/sys/kernel/hostname, # which an unprivileged container cannot do. We add out own service # to set the hostname using /bin/hostname, which uses a syscall that works. sv = File.join( rootfs, 'etc/runit/core-services', '10-vpsadminos-hostname.sh' ) return unless writable?(sv) OsCtld::ErbTemplate.render_to_if_changed( 'dist_config/network/void/hostname', {}, sv ) end |