mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
PHRAS-2140 Check OS for SMB or NFS folder strategy
This commit is contained in:
65
Vagrantfile
vendored
65
Vagrantfile
vendored
@@ -1,16 +1,4 @@
|
|||||||
Vagrant.require_version ">= 1.5"
|
Vagrant.require_version ">= 1.5"
|
||||||
$php = [ "5.6", "7.0", "7.1", "7.2" ]
|
|
||||||
$phpVersion = ENV['phpversion'] ? ENV['phpversion'] : "5.6";
|
|
||||||
|
|
||||||
unless Vagrant.has_plugin?('vagrant-hostmanager')
|
|
||||||
raise "vagrant-hostmanager is not installed! Please run\n vagrant plugin install vagrant-hostmanager\n\n"
|
|
||||||
end
|
|
||||||
|
|
||||||
unless $php.include?($phpVersion)
|
|
||||||
raise "You should specify php version before running vagrant\n\n (Available : 5.6, 7.0, 7.1, 7.2 | default => 5.6)\n\n Exemple: phpversion='7.0' vagrant up \n\n"
|
|
||||||
end
|
|
||||||
|
|
||||||
$root = File.dirname(File.expand_path(__FILE__))
|
|
||||||
|
|
||||||
# Check to determine whether we're on a windows or linux/os-x host,
|
# Check to determine whether we're on a windows or linux/os-x host,
|
||||||
# later on we use this to launch ansible in the supported way
|
# later on we use this to launch ansible in the supported way
|
||||||
@@ -26,6 +14,28 @@ def which(cmd)
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if which('ip')
|
||||||
|
$env = "mac"
|
||||||
|
else if which('ifconfig')
|
||||||
|
$env = "linux"
|
||||||
|
else
|
||||||
|
$env = "windows"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
$php = [ "5.6", "7.0", "7.1", "7.2" ]
|
||||||
|
$phpVersion = ENV['phpversion'] ? ENV['phpversion'] : "5.6";
|
||||||
|
|
||||||
|
unless Vagrant.has_plugin?('vagrant-hostmanager')
|
||||||
|
raise "vagrant-hostmanager is not installed! Please run\n vagrant plugin install vagrant-hostmanager\n\n"
|
||||||
|
end
|
||||||
|
|
||||||
|
unless $php.include?($phpVersion)
|
||||||
|
raise "You should specify php version before running vagrant\n\n (Available : 5.6, 7.0, 7.1, 7.2 | default => 5.6)\n\n Exemple: phpversion='7.0' vagrant up \n\n"
|
||||||
|
end
|
||||||
|
|
||||||
|
$root = File.dirname(File.expand_path(__FILE__))
|
||||||
|
|
||||||
def config_net(config)
|
def config_net(config)
|
||||||
config.hostmanager.aliases = [
|
config.hostmanager.aliases = [
|
||||||
$hostname + ".vb",
|
$hostname + ".vb",
|
||||||
@@ -41,11 +51,20 @@ def config_net(config)
|
|||||||
# vboxnet0 can be changed to use a specific private_network
|
# vboxnet0 can be changed to use a specific private_network
|
||||||
config.vm.network :private_network, type: "dhcp"
|
config.vm.network :private_network, type: "dhcp"
|
||||||
config.vm.provider "virtualbox" do |vb|
|
config.vm.provider "virtualbox" do |vb|
|
||||||
vb.customize ["modifyvm", :id, "--hostonlyadapter2", "vboxnet0"]
|
|
||||||
|
if $env == "mac" || $env == "linux"
|
||||||
|
vb.customize ["modifyvm", :id, "--hostonlyadapter2", "vboxnet0"]
|
||||||
|
else
|
||||||
|
vb.customize ["modifyvm", :id, "--hostonlyadapter2", "VirtualBox Host-Only Ethernet Adapter"]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
config.hostmanager.ip_resolver = proc do |vm, resolving_vm|
|
config.hostmanager.ip_resolver = proc do |vm, resolving_vm|
|
||||||
if vm.id
|
if vm.id
|
||||||
`VBoxManage guestproperty get #{vm.id} "/VirtualBox/GuestInfo/Net/1/V4/IP"`.split()[1]
|
if $env == "mac" || $env == "linux"
|
||||||
|
`VBoxManage guestproperty get #{vm.id} "/VirtualBox/GuestInfo/Net/1/V4/IP"`.split()[1]
|
||||||
|
else
|
||||||
|
`"C:/Program Files/Oracle/VirtualBox/VBoxManage" guestproperty get #{vm.id} "/VirtualBox/GuestInfo/Net/1/V4/IP"`.split()[1]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -53,11 +72,15 @@ end
|
|||||||
|
|
||||||
# By default, the name of the VM is the project's directory name
|
# By default, the name of the VM is the project's directory name
|
||||||
$hostname = File.basename($root).downcase
|
$hostname = File.basename($root).downcase
|
||||||
if which('ip')
|
|
||||||
|
if $env == "mac"
|
||||||
# $hostIps = `ip addr show | grep inet | grep -v inet6 | cut -d' ' -f6 | cut -d'/' -f1`.split("\n");
|
# $hostIps = `ip addr show | grep inet | grep -v inet6 | cut -d' ' -f6 | cut -d'/' -f1`.split("\n");
|
||||||
$hostIps = `ip addr show | sed -nE 's/[[:space:]]*inet ([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3})(.*)$/\\1/p'`.split("\n");
|
$hostIps = `ip addr show | sed -nE 's/[[:space:]]*inet ([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3})(.*)$/\\1/p'`.split("\n");
|
||||||
else
|
else if $env == "linux"
|
||||||
$hostIps = `ifconfig | sed -nE 's/[[:space:]]*inet ([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3})(.*)$/\\1/p'`.split("\n");
|
$hostIps = `ifconfig | sed -nE 's/[[:space:]]*inet ([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3})(.*)$/\\1/p'`.split("\n");
|
||||||
|
else
|
||||||
|
$hostIps = `resources/ansible/inventories/GetIpAdresses.cmd`
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Vagrant.configure("2") do |config|
|
Vagrant.configure("2") do |config|
|
||||||
@@ -115,5 +138,9 @@ Vagrant.configure("2") do |config|
|
|||||||
# config.vm.provision :shell, run: "always", path: "resources/ansible/windows-always.sh", args: ["default"]
|
# config.vm.provision :shell, run: "always", path: "resources/ansible/windows-always.sh", args: ["default"]
|
||||||
end
|
end
|
||||||
|
|
||||||
config.vm.synced_folder "./", "/vagrant", type: "nfs"
|
if $env == "mac" || $env == "linux"
|
||||||
end
|
config.vm.synced_folder "./", "/vagrant", type: "nfs", mount_options: ['rw', 'vers=3', 'tcp', 'fsc']
|
||||||
|
else
|
||||||
|
config.vm.synced_folder "./", "/vagrant", type: "smb", mount_options: ["vers=3.02","mfsymlinks"]
|
||||||
|
end
|
||||||
|
end
|
23
resources/ansible/inventories/GetIpAdresses.cmd
Normal file
23
resources/ansible/inventories/GetIpAdresses.cmd
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
@echo off
|
||||||
|
setlocal
|
||||||
|
setlocal enabledelayedexpansion
|
||||||
|
rem throw away everything except the IPv4 address line
|
||||||
|
for /f "usebackq tokens=*" %%a in (`ipconfig ^| findstr /i "ipv4"`) do (
|
||||||
|
rem we have for example "IPv4 Address. . . . . . . . . . . : 192.168.42.78"
|
||||||
|
rem split on : and get 2nd token
|
||||||
|
for /f delims^=^:^ tokens^=2 %%b in ('echo %%a') do (
|
||||||
|
rem we have " 192.168.42.78"
|
||||||
|
rem split on . and get 4 tokens (octets)
|
||||||
|
for /f "tokens=1-4 delims=." %%c in ("%%b") do (
|
||||||
|
set _o1=%%c
|
||||||
|
set _o2=%%d
|
||||||
|
set _o3=%%e
|
||||||
|
set _o4=%%f
|
||||||
|
rem strip leading space from first octet
|
||||||
|
set _3octet=!_o1:~1!.!_o2!.!_o3!.
|
||||||
|
echo !_3octet!
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
rem add additional commands here
|
||||||
|
endlocal
|
Reference in New Issue
Block a user