Merge pull request #6515 from oliviermeurice/slack_net_conf
Slack net conf
This commit is contained in:
commit
f95b7914f7
|
@ -0,0 +1,19 @@
|
|||
module VagrantPlugins
|
||||
module GuestSlackware
|
||||
module Cap
|
||||
class ChangeHostName
|
||||
def self.change_host_name(machine, name)
|
||||
machine.communicate.tap do |comm|
|
||||
# Only do this if the hostname is not already set
|
||||
if !comm.test("sudo hostname | grep '#{name}'")
|
||||
comm.sudo("chmod o+w /etc/hostname")
|
||||
comm.sudo("echo #{name} > /etc/hostname")
|
||||
comm.sudo("chmod o-w /etc/hostname")
|
||||
comm.sudo("hostname -F /etc/hostname")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,36 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
require "tempfile"
|
||||
|
||||
require "vagrant/util/template_renderer"
|
||||
|
||||
module VagrantPlugins
|
||||
module GuestSlackware
|
||||
module Cap
|
||||
class ConfigureNetworks
|
||||
include Vagrant::Util
|
||||
|
||||
def self.configure_networks(machine, networks)
|
||||
interfaces = Array.new
|
||||
machine.communicate.sudo("ip -o -0 addr | grep -v LOOPBACK | awk '{print $2}' | sed 's/://'") do |_, result|
|
||||
interfaces = result.split("\n")
|
||||
end
|
||||
|
||||
networks.each do |network|
|
||||
network[:device] = interfaces[network[:interface]]
|
||||
|
||||
entry = TemplateRenderer.render("guests/slackware/network_#{network[:type]}", options: network)
|
||||
|
||||
temp = Tempfile.new("vagrant")
|
||||
temp.binmode
|
||||
temp.write(entry)
|
||||
temp.close
|
||||
|
||||
machine.communicate.upload(temp.path, "/tmp/vagrant_network")
|
||||
machine.communicate.sudo("mv /tmp/vagrant_network /etc/rc.d/rc.inet1.conf")
|
||||
machine.communicate.sudo("/etc/rc.d/rc.inet1")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,11 @@
|
|||
require "vagrant"
|
||||
|
||||
module VagrantPlugins
|
||||
module GuestSlackware
|
||||
class Guest < Vagrant.plugin("2", :guest)
|
||||
def detect?(machine)
|
||||
machine.communicate.test("cat /etc/slackware-version")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,25 @@
|
|||
require "vagrant"
|
||||
|
||||
module VagrantPlugins
|
||||
module GuestSlackware
|
||||
class Plugin < Vagrant.plugin("2")
|
||||
name "Slackware guest"
|
||||
description "Slackware guest support."
|
||||
|
||||
guest("slackware", "linux") do
|
||||
require File.expand_path("../guest", __FILE__)
|
||||
Guest
|
||||
end
|
||||
|
||||
guest_capability("slackware", "change_host_name") do
|
||||
require_relative "cap/change_host_name"
|
||||
Cap::ChangeHostName
|
||||
end
|
||||
|
||||
guest_capability("slackware", "configure_networks") do
|
||||
require_relative "cap/configure_networks"
|
||||
Cap::ConfigureNetworks
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,23 @@
|
|||
IPADDR[0]=""
|
||||
NETMASK[0]=""
|
||||
USE_DHCP[0]="yes"
|
||||
DHCP_HOSTNAME[0]=""
|
||||
|
||||
IPADDR[1]=""
|
||||
NETMASK[1]=""
|
||||
USE_DHCP[1]="yes"
|
||||
DHCP_HOSTNAME[1]=""
|
||||
|
||||
IPADDR[2]=""
|
||||
NETMASK[2]=""
|
||||
USE_DHCP[2]=""
|
||||
DHCP_HOSTNAME[2]=""
|
||||
|
||||
IPADDR[3]=""
|
||||
NETMASK[3]=""
|
||||
USE_DHCP[3]=""
|
||||
DHCP_HOSTNAME[3]=""
|
||||
|
||||
GATEWAY=""
|
||||
|
||||
DEBUG_ETH_UP="no"
|
|
@ -0,0 +1,25 @@
|
|||
IPADDR[0]=""
|
||||
NETMASK[0]=""
|
||||
USE_DHCP[0]="yes"
|
||||
DHCP_HOSTNAME[0]=""
|
||||
|
||||
IPADDR[1]="<%= options[:ip] %>"
|
||||
NETMASK[1]=""
|
||||
USE_DHCP[1]=""
|
||||
DHCP_HOSTNAME[1]=""
|
||||
|
||||
IPADDR[2]=""
|
||||
NETMASK[2]=""
|
||||
USE_DHCP[2]=""
|
||||
DHCP_HOSTNAME[2]=""
|
||||
|
||||
IPADDR[3]=""
|
||||
NETMASK[3]=""
|
||||
USE_DHCP[3]=""
|
||||
DHCP_HOSTNAME[3]=""
|
||||
|
||||
<% if options[:gateway] %>
|
||||
GATEWAY="<%= options[:gateway] %>"
|
||||
<% end %>
|
||||
|
||||
DEBUG_ETH_UP="no"
|
Loading…
Reference in New Issue