diff --git a/freebsd-10.1-amd64.json b/freebsd-10.1-amd64.json index bfb86fdb0..cd872d82e 100644 --- a/freebsd-10.1-amd64.json +++ b/freebsd-10.1-amd64.json @@ -10,7 +10,7 @@ "mdmfs -s 100m md1 /tmp", "mdmfs -s 100m md2 /mnt", "dhclient -l /tmp/dhclient.lease.em0 em0", - "fetch -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/freebsd-10.1/install.sh && chmod +x /tmp/install.sh && /tmp/install.sh {{ .Name }}" + "fetch -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/{{user `install_path`}} && chmod +x /tmp/install.sh && /tmp/install.sh {{ .Name }}" ], "boot_wait": "10s", "disk_size": 10140, @@ -18,11 +18,11 @@ "guest_os_type": "FreeBSD_64", "headless": "{{ user `headless` }}", "http_directory": "http", - "iso_checksum": "0c3d64ce48c3ef761761d0fea07e1935e296f8c045c249118bc91a7faf053a6b", - "iso_checksum_type": "sha256", - "iso_url": "{{user `mirror`}}/releases/amd64/amd64/ISO-IMAGES/10.1/FreeBSD-10.1-RELEASE-amd64-disc1.iso", - "output_directory": "packer-freebsd-10.1-amd64-virtualbox", - "shutdown_command": "echo 'shutdown -p now' > shutdown.sh; cat 'shutdown.sh' | su -", + "iso_checksum": "{{user `iso_checksum`}}", + "iso_checksum_type": "{{user `iso_checksum_type`}}", + "iso_url": "{{user `mirror`}}/{{user `mirror_directory`}}/{{user `iso_name`}}", + "output_directory": "packer-{{user `template`}}-virtualbox", + "shutdown_command": "su -m root -c 'shutdown -p now'", "ssh_password": "vagrant", "ssh_port": 22, "ssh_username": "vagrant", @@ -56,18 +56,18 @@ "mdmfs -s 100m md2 /mnt", "dhclient -l /tmp/dhclient.lease.em0 em0", "", - "fetch -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/freebsd-10.1/install.sh && chmod +x /tmp/install.sh && /tmp/install.sh {{ .Name }}" + "fetch -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/{{user `install_path`}} && chmod +x /tmp/install.sh && /tmp/install.sh {{ .Name }}" ], "boot_wait": "10s", "disk_size": 10140, "guest_os_type": "freebsd-64", "headless": "{{ user `headless` }}", "http_directory": "http", - "iso_checksum": "0c3d64ce48c3ef761761d0fea07e1935e296f8c045c249118bc91a7faf053a6b", - "iso_checksum_type": "sha256", - "iso_url": "{{user `mirror`}}/releases/amd64/amd64/ISO-IMAGES/10.1/FreeBSD-10.1-RELEASE-amd64-disc1.iso", - "output_directory": "packer-freebsd-10.1-amd64-vmware", - "shutdown_command": "echo 'shutdown -p now' > shutdown.sh; cat 'shutdown.sh' | su -", + "iso_checksum": "{{user `iso_checksum`}}", + "iso_checksum_type": "{{user `iso_checksum_type`}}", + "iso_url": "{{user `mirror`}}/{{user `mirror_directory`}}/{{user `iso_name`}}", + "output_directory": "packer-{{user `template`}}-vmare", + "shutdown_command": "su -m root -c 'shutdown -p now'", "ssh_password": "vagrant", "ssh_port": 22, "ssh_username": "vagrant", @@ -91,17 +91,17 @@ "mdmfs -s 100m md1 /tmp", "mdmfs -s 100m md2 /mnt", "dhclient -l /tmp/dhclient.lease.em0 em0", - "fetch -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/freebsd-10.1/install.sh && chmod +x /tmp/install.sh && /tmp/install.sh {{ .Name }}" + "fetch -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/{{user `install_path`}} && chmod +x /tmp/install.sh && /tmp/install.sh {{ .Name }}" ], - "boot_wait": "10s", + "boot_wait": "8s", "disk_size": 10140, "guest_os_type": "freebsd", "headless": "{{ user `headless` }}", "http_directory": "http", - "iso_checksum": "0c3d64ce48c3ef761761d0fea07e1935e296f8c045c249118bc91a7faf053a6b", - "iso_checksum_type": "sha256", - "iso_url": "{{user `mirror`}}/releases/amd64/amd64/ISO-IMAGES/10.1/FreeBSD-10.1-RELEASE-amd64-disc1.iso", - "output_directory": "packer-freebsd-10.1-amd64-parallels", + "iso_checksum": "{{user `iso_checksum`}}", + "iso_checksum_type": "{{user `iso_checksum_type`}}", + "iso_url": "{{user `mirror`}}/{{user `mirror_directory`}}/{{user `iso_name`}}", + "output_directory": "packer-{{user `template`}}-parallels", "parallels_tools_mode": "disable", "prlctl": [ [ @@ -138,7 +138,7 @@ ] ], "prlctl_version_file": ".prlctl_version", - "shutdown_command": "echo 'shutdown -p now' > shutdown.sh; cat 'shutdown.sh' | su -", + "shutdown_command": "su -m root -c 'shutdown -p now'", "ssh_password": "vagrant", "ssh_port": 22, "ssh_username": "vagrant", @@ -150,12 +150,8 @@ "post-processors": [ { "output": "builds/{{user `box_basename`}}.{{.Provider}}.box", - "override": { - "parallels": { - "vagrantfile_template": "vagrantfile_templates/parallels/freebsd.rb" - } - }, - "type": "vagrant" + "type": "vagrant", + "vagrantfile_template": "vagrantfile_templates/freebsd.rb" } ], "provisioners": [ @@ -165,29 +161,44 @@ "type": "file" }, { - "environment_vars": [], - "execute_command": "export {{.Vars}} && cat {{.Path}} | su -m", + "environment_vars": [ + "HOME_DIR=/home/vagrant", + "http_proxy={{user `http_proxy`}}", + "https_proxy={{user `https_proxy`}}", + "no_proxy={{user `no_proxy`}}" + ], + "execute_command": "{{.Vars}} su -m root -c 'sh -eux {{.Path}}'", "scripts": [ "scripts/common/metadata.sh", + "scripts/freebsd/update.sh", "scripts/freebsd/postinstall.sh", - "scripts/freebsd/cleanup.sh", + "scripts/freebsd/sudoers.sh", + "scripts/common/vagrant.sh", "scripts/freebsd/vmtools.sh", + "scripts/freebsd/cleanup.sh", "scripts/freebsd/minimize.sh" ], "type": "shell" } ], "variables": { - "arch": "64", - "box_basename": "freebsd-10.1", + "box_basename": "__unset_box_basename__", "build_timestamp": "{{isotime \"20060102150405\"}}", "git_revision": "__unknown_git_revision__", "headless": "", + "http_proxy": "{{env `http_proxy`}}", + "https_proxy": "{{env `https_proxy`}}", + "install_path": "freebsd-10.1/install.sh", + "iso_checksum": "0c3d64ce48c3ef761761d0fea07e1935e296f8c045c249118bc91a7faf053a6b", + "iso_checksum_type": "sha256", + "iso_name": "FreeBSD-10.1-RELEASE-amd64-disc1.iso", "metadata": "floppy/dummy_metadata.json", "mirror": "http://ftp.freebsd.org/pub/FreeBSD", + "mirror_directory": "releases/amd64/amd64/ISO-IMAGES/10.1", "name": "freebsd-10.1", + "no_proxy": "{{env `no_proxy`}}", "template": "freebsd-10.1-amd64", - "version": "2.0.TIMESTAMP" + "version": "2.1.TIMESTAMP" } } diff --git a/freebsd-10.1-i386.json b/freebsd-10.1-i386.json index 37e8c61e2..943e96c44 100644 --- a/freebsd-10.1-i386.json +++ b/freebsd-10.1-i386.json @@ -10,7 +10,7 @@ "mdmfs -s 100m md1 /tmp", "mdmfs -s 100m md2 /mnt", "dhclient -l /tmp/dhclient.lease.em0 em0", - "fetch -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/freebsd-10.1/install.sh && chmod +x /tmp/install.sh && /tmp/install.sh {{ .Name }}" + "fetch -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/{{user `install_path`}} && chmod +x /tmp/install.sh && /tmp/install.sh {{ .Name }}" ], "boot_wait": "10s", "disk_size": 10140, @@ -18,11 +18,11 @@ "guest_os_type": "FreeBSD", "headless": "{{ user `headless` }}", "http_directory": "http", - "iso_checksum": "fe31790b762b01c99791d33e7fd9ab97323654785ce21f588116c8b4eb381cd0", - "iso_checksum_type": "sha256", - "iso_url": "{{user `mirror`}}/releases/i386/i386/ISO-IMAGES/10.1/FreeBSD-10.1-RELEASE-i386-disc1.iso", - "output_directory": "packer-freebsd-10.1-i386-virtualbox", - "shutdown_command": "echo 'shutdown -p now' > shutdown.sh; cat 'shutdown.sh' | su -", + "iso_checksum": "{{user `iso_checksum`}}", + "iso_checksum_type": "{{user `iso_checksum_type`}}", + "iso_url": "{{user `mirror`}}/{{user `mirror_directory`}}/{{user `iso_name`}}", + "output_directory": "packer-{{user `template`}}-virtualbox", + "shutdown_command": "su -m root -c 'shutdown -p now'", "ssh_password": "vagrant", "ssh_port": 22, "ssh_username": "vagrant", @@ -56,18 +56,18 @@ "mdmfs -s 100m md2 /mnt", "dhclient -l /tmp/dhclient.lease.em0 em0", "", - "fetch -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/freebsd-10.1/install.sh && chmod +x /tmp/install.sh && /tmp/install.sh {{ .Name }}" + "fetch -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/{{user `install_path`}} && chmod +x /tmp/install.sh && /tmp/install.sh {{ .Name }}" ], "boot_wait": "10s", "disk_size": 10140, "guest_os_type": "freebsd", "headless": "{{ user `headless` }}", "http_directory": "http", - "iso_checksum": "fe31790b762b01c99791d33e7fd9ab97323654785ce21f588116c8b4eb381cd0", - "iso_checksum_type": "sha256", - "iso_url": "{{user `mirror`}}/releases/i386/i386/ISO-IMAGES/10.1/FreeBSD-10.1-RELEASE-i386-disc1.iso", - "output_directory": "packer-freebsd-10.1-i386-vmware", - "shutdown_command": "echo 'shutdown -p now' > shutdown.sh; cat 'shutdown.sh' | su -", + "iso_checksum": "{{user `iso_checksum`}}", + "iso_checksum_type": "{{user `iso_checksum_type`}}", + "iso_url": "{{user `mirror`}}/{{user `mirror_directory`}}/{{user `iso_name`}}", + "output_directory": "packer-{{user `template`}}-vmare", + "shutdown_command": "su -m root -c 'shutdown -p now'", "ssh_password": "vagrant", "ssh_port": 22, "ssh_username": "vagrant", @@ -91,17 +91,17 @@ "mdmfs -s 100m md1 /tmp", "mdmfs -s 100m md2 /mnt", "dhclient -l /tmp/dhclient.lease.em0 em0", - "fetch -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/freebsd-10.1/install.sh && chmod +x /tmp/install.sh && /tmp/install.sh {{ .Name }}" + "fetch -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/{{user `install_path`}} && chmod +x /tmp/install.sh && /tmp/install.sh {{ .Name }}" ], - "boot_wait": "10s", + "boot_wait": "8s", "disk_size": 10140, "guest_os_type": "freebsd", "headless": "{{ user `headless` }}", "http_directory": "http", - "iso_checksum": "fe31790b762b01c99791d33e7fd9ab97323654785ce21f588116c8b4eb381cd0", - "iso_checksum_type": "sha256", - "iso_url": "{{user `mirror`}}/releases/i386/i386/ISO-IMAGES/10.1/FreeBSD-10.1-RELEASE-i386-disc1.iso", - "output_directory": "packer-freebsd-10.1-i386-parallels", + "iso_checksum": "{{user `iso_checksum`}}", + "iso_checksum_type": "{{user `iso_checksum_type`}}", + "iso_url": "{{user `mirror`}}/{{user `mirror_directory`}}/{{user `iso_name`}}", + "output_directory": "packer-{{user `template`}}-parallels", "parallels_tools_mode": "disable", "prlctl": [ [ @@ -138,7 +138,7 @@ ] ], "prlctl_version_file": ".prlctl_version", - "shutdown_command": "echo 'shutdown -p now' > shutdown.sh; cat 'shutdown.sh' | su -", + "shutdown_command": "su -m root -c 'shutdown -p now'", "ssh_password": "vagrant", "ssh_port": 22, "ssh_username": "vagrant", @@ -150,12 +150,8 @@ "post-processors": [ { "output": "builds/{{user `box_basename`}}.{{.Provider}}.box", - "override": { - "parallels": { - "vagrantfile_template": "vagrantfile_templates/parallels/freebsd.rb" - } - }, - "type": "vagrant" + "type": "vagrant", + "vagrantfile_template": "vagrantfile_templates/freebsd.rb" } ], "provisioners": [ @@ -165,29 +161,44 @@ "type": "file" }, { - "environment_vars": [], - "execute_command": "export {{.Vars}} && cat {{.Path}} | su -m", + "environment_vars": [ + "HOME_DIR=/home/vagrant", + "http_proxy={{user `http_proxy`}}", + "https_proxy={{user `https_proxy`}}", + "no_proxy={{user `no_proxy`}}" + ], + "execute_command": "{{.Vars}} su -m root -c 'sh -eux {{.Path}}'", "scripts": [ "scripts/common/metadata.sh", + "scripts/freebsd/update.sh", "scripts/freebsd/postinstall.sh", - "scripts/freebsd/cleanup.sh", + "scripts/freebsd/sudoers.sh", + "scripts/common/vagrant.sh", "scripts/freebsd/vmtools.sh", + "scripts/freebsd/cleanup.sh", "scripts/freebsd/minimize.sh" ], "type": "shell" } ], "variables": { - "arch": "32", - "box_basename": "freebsd-10.1-i386", + "box_basename": "__unset_box_basename__", "build_timestamp": "{{isotime \"20060102150405\"}}", "git_revision": "__unknown_git_revision__", "headless": "", + "http_proxy": "{{env `http_proxy`}}", + "https_proxy": "{{env `https_proxy`}}", + "install_path": "freebsd-10.1/install.sh", + "iso_checksum": "fe31790b762b01c99791d33e7fd9ab97323654785ce21f588116c8b4eb381cd0", + "iso_checksum_type": "sha256", + "iso_name": "FreeBSD-10.1-RELEASE-i386-disc1.iso", "metadata": "floppy/dummy_metadata.json", "mirror": "http://ftp.freebsd.org/pub/FreeBSD", + "mirror_directory": "releases/i386/i386/ISO-IMAGES/10.1", "name": "freebsd-10.1-i386", + "no_proxy": "{{env `no_proxy`}}", "template": "freebsd-10.1-i386", - "version": "2.0.TIMESTAMP" + "version": "2.1.TIMESTAMP" } } diff --git a/freebsd-9.3-amd64.json b/freebsd-9.3-amd64.json index c038531b1..8061637d4 100644 --- a/freebsd-9.3-amd64.json +++ b/freebsd-9.3-amd64.json @@ -14,7 +14,7 @@ "mdmfs -s 100m md1 /tmp", "mdmfs -s 100m md2 /mnt", "dhclient -l /tmp/dhclient.lease.em0 em0", - "fetch -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/freebsd-9.3/install.sh && chmod +x /tmp/install.sh && /tmp/install.sh {{ .Name }}" + "fetch -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/{{user `install_path`}} && chmod +x /tmp/install.sh && /tmp/install.sh {{ .Name }}" ], "boot_wait": "10s", "disk_size": 10140, @@ -22,11 +22,11 @@ "guest_os_type": "FreeBSD_64", "headless": "{{ user `headless` }}", "http_directory": "http", - "iso_checksum": "5a3c82653d77bba7d7ded8bd7efbedc09d52cf4045d98ce52a82c9e0f8fa9b0e", - "iso_checksum_type": "sha256", - "iso_url": "{{user `mirror`}}/releases/amd64/amd64/ISO-IMAGES/9.3/FreeBSD-9.3-RELEASE-amd64-disc1.iso", - "output_directory": "packer-freebsd-9.3-amd64-virtualbox", - "shutdown_command": "echo 'shutdown -p now' > shutdown.sh; cat 'shutdown.sh' | su -", + "iso_checksum": "{{user `iso_checksum`}}", + "iso_checksum_type": "{{user `iso_checksum_type`}}", + "iso_url": "{{user `mirror`}}/{{user `mirror_directory`}}/{{user `iso_name`}}", + "output_directory": "packer-{{user `template`}}-virtualbox", + "shutdown_command": "su -m root -c 'shutdown -p now'", "ssh_password": "vagrant", "ssh_port": 22, "ssh_username": "vagrant", @@ -64,18 +64,18 @@ "mdmfs -s 100m md2 /mnt", "dhclient -l /tmp/dhclient.lease.em0 em0", "", - "fetch -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/freebsd-9.3/install.sh && chmod +x /tmp/install.sh && /tmp/install.sh {{ .Name }}" + "fetch -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/{{user `install_path`}} && chmod +x /tmp/install.sh && /tmp/install.sh {{ .Name }}" ], "boot_wait": "10s", "disk_size": 10140, "guest_os_type": "freebsd-64", "headless": "{{ user `headless` }}", "http_directory": "http", - "iso_checksum": "5a3c82653d77bba7d7ded8bd7efbedc09d52cf4045d98ce52a82c9e0f8fa9b0e", - "iso_checksum_type": "sha256", - "iso_url": "{{user `mirror`}}/releases/amd64/amd64/ISO-IMAGES/9.3/FreeBSD-9.3-RELEASE-amd64-disc1.iso", - "output_directory": "packer-freebsd-9.3-amd64-vmware", - "shutdown_command": "echo 'shutdown -p now' > shutdown.sh; cat 'shutdown.sh' | su -", + "iso_checksum": "{{user `iso_checksum`}}", + "iso_checksum_type": "{{user `iso_checksum_type`}}", + "iso_url": "{{user `mirror`}}/{{user `mirror_directory`}}/{{user `iso_name`}}", + "output_directory": "packer-{{user `template`}}-vmare", + "shutdown_command": "su -m root -c 'shutdown -p now'", "ssh_password": "vagrant", "ssh_port": 22, "ssh_username": "vagrant", @@ -103,17 +103,17 @@ "mdmfs -s 100m md1 /tmp", "mdmfs -s 100m md2 /mnt", "dhclient -l /tmp/dhclient.lease.em0 em0", - "fetch -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/freebsd-9.3/install.sh && chmod +x /tmp/install.sh && /tmp/install.sh {{ .Name }}" + "fetch -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/{{user `install_path`}} && chmod +x /tmp/install.sh && /tmp/install.sh {{ .Name }}" ], - "boot_wait": "10s", + "boot_wait": "8s", "disk_size": 10140, "guest_os_type": "freebsd", "headless": "{{ user `headless` }}", "http_directory": "http", - "iso_checksum": "5a3c82653d77bba7d7ded8bd7efbedc09d52cf4045d98ce52a82c9e0f8fa9b0e", - "iso_checksum_type": "sha256", - "iso_url": "{{user `mirror`}}/releases/amd64/amd64/ISO-IMAGES/9.3/FreeBSD-9.3-RELEASE-amd64-disc1.iso", - "output_directory": "packer-freebsd-9.3-amd64-parallels", + "iso_checksum": "{{user `iso_checksum`}}", + "iso_checksum_type": "{{user `iso_checksum_type`}}", + "iso_url": "{{user `mirror`}}/{{user `mirror_directory`}}/{{user `iso_name`}}", + "output_directory": "packer-{{user `template`}}-parallels", "parallels_tools_mode": "disable", "prlctl": [ [ @@ -150,7 +150,7 @@ ] ], "prlctl_version_file": ".prlctl_version", - "shutdown_command": "echo 'shutdown -p now' > shutdown.sh; cat 'shutdown.sh' | su -", + "shutdown_command": "su -m root -c 'shutdown -p now'", "ssh_password": "vagrant", "ssh_port": 22, "ssh_username": "vagrant", @@ -162,12 +162,8 @@ "post-processors": [ { "output": "builds/{{user `box_basename`}}.{{.Provider}}.box", - "override": { - "parallels": { - "vagrantfile_template": "vagrantfile_templates/parallels/freebsd.rb" - } - }, - "type": "vagrant" + "type": "vagrant", + "vagrantfile_template": "vagrantfile_templates/freebsd.rb" } ], "provisioners": [ @@ -177,11 +173,19 @@ "type": "file" }, { - "environment_vars": [], - "execute_command": "export {{.Vars}} && cat {{.Path}} | su -m", + "environment_vars": [ + "HOME_DIR=/home/vagrant", + "http_proxy={{user `http_proxy`}}", + "https_proxy={{user `https_proxy`}}", + "no_proxy={{user `no_proxy`}}" + ], + "execute_command": "{{.Vars}} su -m root -c 'sh -eux {{.Path}}'", "scripts": [ "scripts/common/metadata.sh", + "scripts/freebsd/update.sh", "scripts/freebsd/postinstall.sh", + "scripts/freebsd/sudoers.sh", + "scripts/common/vagrant.sh", "scripts/freebsd/vmtools.sh", "scripts/freebsd/cleanup.sh", "scripts/freebsd/minimize.sh" @@ -190,16 +194,23 @@ } ], "variables": { - "arch": "64", - "box_basename": "freebsd-9.3", + "box_basename": "__unset_box_basename__", "build_timestamp": "{{isotime \"20060102150405\"}}", "git_revision": "__unknown_git_revision__", "headless": "", + "http_proxy": "{{env `http_proxy`}}", + "https_proxy": "{{env `https_proxy`}}", + "install_path": "freebsd-9.3/install.sh", + "iso_checksum": "5a3c82653d77bba7d7ded8bd7efbedc09d52cf4045d98ce52a82c9e0f8fa9b0e", + "iso_checksum_type": "sha256", + "iso_name": "FreeBSD-9.3-RELEASE-amd64-disc1.iso", "metadata": "floppy/dummy_metadata.json", "mirror": "http://ftp.freebsd.org/pub/FreeBSD", + "mirror_directory": "releases/amd64/amd64/ISO-IMAGES/9.3", "name": "freebsd-9.3", + "no_proxy": "{{env `no_proxy`}}", "template": "freebsd-9.3-amd64", - "version": "2.0.TIMESTAMP" + "version": "2.1.TIMESTAMP" } } diff --git a/freebsd-9.3-i386.json b/freebsd-9.3-i386.json index 9e708df04..5424e1499 100644 --- a/freebsd-9.3-i386.json +++ b/freebsd-9.3-i386.json @@ -14,7 +14,7 @@ "mdmfs -s 100m md1 /tmp", "mdmfs -s 100m md2 /mnt", "dhclient -l /tmp/dhclient.lease.em0 em0", - "fetch -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/freebsd-9.3/install.sh && chmod +x /tmp/install.sh && /tmp/install.sh {{ .Name }}" + "fetch -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/{{user `install_path`}} && chmod +x /tmp/install.sh && /tmp/install.sh {{ .Name }}" ], "boot_wait": "10s", "disk_size": 10140, @@ -22,11 +22,11 @@ "guest_os_type": "FreeBSD", "headless": "{{ user `headless` }}", "http_directory": "http", - "iso_checksum": "cab6aad9c3d5ea6a3fb4059f808225c67f1edaea730c555a86a9707ac41ba75d", - "iso_checksum_type": "sha256", - "iso_url": "{{user `mirror`}}/releases/i386/i386/ISO-IMAGES/9.3/FreeBSD-9.3-RELEASE-i386-disc1.iso", - "output_directory": "packer-freebsd-9.3-i386-virtualbox", - "shutdown_command": "echo 'shutdown -p now' > shutdown.sh; cat 'shutdown.sh' | su -", + "iso_checksum": "{{user `iso_checksum`}}", + "iso_checksum_type": "{{user `iso_checksum_type`}}", + "iso_url": "{{user `mirror`}}/{{user `mirror_directory`}}/{{user `iso_name`}}", + "output_directory": "packer-{{user `template`}}-virtualbox", + "shutdown_command": "su -m root -c 'shutdown -p now'", "ssh_password": "vagrant", "ssh_port": 22, "ssh_username": "vagrant", @@ -64,18 +64,18 @@ "mdmfs -s 100m md2 /mnt", "dhclient -l /tmp/dhclient.lease.em0 em0", "", - "fetch -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/freebsd-9.3/install.sh && chmod +x /tmp/install.sh && /tmp/install.sh {{ .Name }}" + "fetch -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/{{user `install_path`}} && chmod +x /tmp/install.sh && /tmp/install.sh {{ .Name }}" ], "boot_wait": "10s", "disk_size": 10140, "guest_os_type": "freebsd", "headless": "{{ user `headless` }}", "http_directory": "http", - "iso_checksum": "cab6aad9c3d5ea6a3fb4059f808225c67f1edaea730c555a86a9707ac41ba75d", - "iso_checksum_type": "sha256", - "iso_url": "{{user `mirror`}}/releases/i386/i386/ISO-IMAGES/9.3/FreeBSD-9.3-RELEASE-i386-disc1.iso", - "output_directory": "packer-freebsd-9.3-i386-vmware", - "shutdown_command": "echo 'shutdown -p now' > shutdown.sh; cat 'shutdown.sh' | su -", + "iso_checksum": "{{user `iso_checksum`}}", + "iso_checksum_type": "{{user `iso_checksum_type`}}", + "iso_url": "{{user `mirror`}}/{{user `mirror_directory`}}/{{user `iso_name`}}", + "output_directory": "packer-{{user `template`}}-vmare", + "shutdown_command": "su -m root -c 'shutdown -p now'", "ssh_password": "vagrant", "ssh_port": 22, "ssh_username": "vagrant", @@ -103,15 +103,17 @@ "mdmfs -s 100m md1 /tmp", "mdmfs -s 100m md2 /mnt", "dhclient -l /tmp/dhclient.lease.em0 em0", - "fetch -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/freebsd-9.3/install.sh && chmod +x /tmp/install.sh && /tmp/install.sh {{ .Name }}" + "fetch -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/{{user `install_path`}} && chmod +x /tmp/install.sh && /tmp/install.sh {{ .Name }}" ], - "boot_wait": "10s", + "boot_wait": "8s", "disk_size": 10140, + "guest_os_type": "freebsd", + "headless": "{{ user `headless` }}", "http_directory": "http", - "iso_checksum": "cab6aad9c3d5ea6a3fb4059f808225c67f1edaea730c555a86a9707ac41ba75d", - "iso_checksum_type": "sha256", - "iso_url": "{{user `mirror`}}/releases/i386/i386/ISO-IMAGES/9.3/FreeBSD-9.3-RELEASE-i386-disc1.iso", - "output_directory": "packer-freebsd-9.3-i386-parallels", + "iso_checksum": "{{user `iso_checksum`}}", + "iso_checksum_type": "{{user `iso_checksum_type`}}", + "iso_url": "{{user `mirror`}}/{{user `mirror_directory`}}/{{user `iso_name`}}", + "output_directory": "packer-{{user `template`}}-parallels", "parallels_tools_mode": "disable", "prlctl": [ [ @@ -148,7 +150,7 @@ ] ], "prlctl_version_file": ".prlctl_version", - "shutdown_command": "echo 'shutdown -p now' > shutdown.sh; cat 'shutdown.sh' | su -", + "shutdown_command": "su -m root -c 'shutdown -p now'", "ssh_password": "vagrant", "ssh_port": 22, "ssh_username": "vagrant", @@ -160,12 +162,8 @@ "post-processors": [ { "output": "builds/{{user `box_basename`}}.{{.Provider}}.box", - "override": { - "parallels": { - "vagrantfile_template": "vagrantfile_templates/parallels/freebsd.rb" - } - }, - "type": "vagrant" + "type": "vagrant", + "vagrantfile_template": "vagrantfile_templates/freebsd.rb" } ], "provisioners": [ @@ -175,10 +173,19 @@ "type": "file" }, { - "execute_command": "export {{.Vars}} && cat {{.Path}} | su -m", + "environment_vars": [ + "HOME_DIR=/home/vagrant", + "http_proxy={{user `http_proxy`}}", + "https_proxy={{user `https_proxy`}}", + "no_proxy={{user `no_proxy`}}" + ], + "execute_command": "{{.Vars}} su -m root -c 'sh -eux {{.Path}}'", "scripts": [ "scripts/common/metadata.sh", + "scripts/freebsd/update.sh", "scripts/freebsd/postinstall.sh", + "scripts/freebsd/sudoers.sh", + "scripts/common/vagrant.sh", "scripts/freebsd/vmtools.sh", "scripts/freebsd/cleanup.sh", "scripts/freebsd/minimize.sh" @@ -187,16 +194,23 @@ } ], "variables": { - "arch": "32", - "box_basename": "freebsd-9.3-i386", + "box_basename": "__unset_box_basename__", "build_timestamp": "{{isotime \"20060102150405\"}}", "git_revision": "__unknown_git_revision__", "headless": "", + "http_proxy": "{{env `http_proxy`}}", + "https_proxy": "{{env `https_proxy`}}", + "install_path": "freebsd-9.3/install.sh", + "iso_checksum": "cab6aad9c3d5ea6a3fb4059f808225c67f1edaea730c555a86a9707ac41ba75d", + "iso_checksum_type": "sha256", + "iso_name": "FreeBSD-9.3-RELEASE-i386-disc1.iso", "metadata": "floppy/dummy_metadata.json", "mirror": "http://ftp.freebsd.org/pub/FreeBSD", - "name": "freebsd-9.3-i386", + "mirror_directory": "releases/i386/i386/ISO-IMAGES/9.3", + "name": "freebsd-9.3", + "no_proxy": "{{env `no_proxy`}}", "template": "freebsd-9.3-i386", - "version": "2.0.TIMESTAMP" + "version": "2.1.TIMESTAMP" } } diff --git a/scripts/common/vagrant.sh b/scripts/common/vagrant.sh index cf12a564a..b69c3a585 100644 --- a/scripts/common/vagrant.sh +++ b/scripts/common/vagrant.sh @@ -9,6 +9,8 @@ if command -v wget >/dev/null 2>&1; then wget --no-check-certificate "$pubkey_url" -O $HOME_DIR/.ssh/authorized_keys; elif command -v curl >/dev/null 2>&1; then curl --insecure --location "$pubkey_url" > $HOME_DIR/.ssh/authorized_keys; +elif command -v fetch >/dev/null 2>&1; then + fetch -am -o $HOME_DIR/.ssh/authorized_keys "$pubkey_url"; else echo "Cannot download vagrant public key"; exit 1; diff --git a/scripts/freebsd/cleanup.sh b/scripts/freebsd/cleanup.sh index dd8479794..7451cc824 100644 --- a/scripts/freebsd/cleanup.sh +++ b/scripts/freebsd/cleanup.sh @@ -1,11 +1,10 @@ -#!/bin/sh +#!/bin/sh -eux # Purge files we don't need any longer -rm -f /tmp/chef* -rm -rf /var/db/freebsd-update/files -mkdir /var/db/freebsd-update/files -rm -f /var/db/freebsd-update/*-rollback -rm -rf /var/db/freebsd-update/install.* -rm -rf /boot/kernel.old -rm -rf /usr/src/* -rm -f /*.core +rm -rf /var/db/freebsd-update/files; +mkdir -p /var/db/freebsd-update/files; +rm -f /var/db/freebsd-update/*-rollback; +rm -rf /var/db/freebsd-update/install.*; +rm -rf /boot/kernel.old; +rm -rf /usr/src/*; +rm -f /*.core; diff --git a/scripts/freebsd/minimize.sh b/scripts/freebsd/minimize.sh index 9a014d87f..670aca7ac 100644 --- a/scripts/freebsd/minimize.sh +++ b/scripts/freebsd/minimize.sh @@ -1,7 +1,7 @@ #!/bin/sh -eux -dd if=/dev/zero of=/EMPTY bs=1M -rm -f /EMPTY +dd if=/dev/zero of=/EMPTY bs=1M || echo "dd exit code $? is suppressed"; +rm -f /EMPTY; # Block until the empty file has been removed, otherwise, Packer # will try to kill the box while the disk is still full and that's bad -sync +sync; diff --git a/scripts/freebsd/postinstall.sh b/scripts/freebsd/postinstall.sh index d741ad298..5fb23ad3e 100644 --- a/scripts/freebsd/postinstall.sh +++ b/scripts/freebsd/postinstall.sh @@ -1,59 +1,25 @@ -#!/bin/sh -x +#!/bin/sh -eux -freebsd_major=`uname -r | awk -F. '{ print $1 }'` +# Set the time correctly +ntpdate -v -b in.pool.ntp.org; -#Set the time correctly -ntpdate -v -b in.pool.ntp.org +# Install sudo, curl and ca_root_nss +pkg install -y curl; +pkg install -y ca_root_nss; -date > /etc/vagrant_box_build_time +# Emulate the ETCSYMLINK behavior of ca_root_nss; this is for FreeBSD 10, +# where fetch(1) was massively refactored and doesn't come with +# SSL CAcerts anymore +ln -sf /usr/local/share/certs/ca-root-nss.crt /etc/ssl/cert.pem; -# allow freebsd-update to run fetch without stdin attached to a terminal -sed 's/\[ ! -t 0 \]/false/' /usr/sbin/freebsd-update > /tmp/freebsd-update -chmod +x /tmp/freebsd-update +# As sharedfolders are not in defaults ports tree, we will use NFS sharing +cat >>/etc/rc.conf << RC_CONF +rpcbind_enable="YES" +nfs_server_enable="YES" +mountd_flags="-r" +RC_CONF -# update FreeBSD -env PAGER=/bin/cat /tmp/freebsd-update fetch -env PAGER=/bin/cat /tmp/freebsd-update install - -# always use pkgng - pkg_add is EOL as of 1 September 2014 -env ASSUME_ALWAYS_YES=true pkg bootstrap -if [ $freebsd_major -lt 10 ]; then - echo WITH_PKGNG=yes >> /etc/make.conf -fi - -#Install sudo, curl and ca_root_nss -pkg update -pkg install -y sudo -pkg install -y curl -pkg install -y ca_root_nss - -# Emulate the ETCSYMLINK behavior of ca_root_nss; this is for FreeBSD 10, where fetch(1) was -# massively refactored and doesn't come with SSL CAcerts anymore -ln -sf /usr/local/share/certs/ca-root-nss.crt /etc/ssl/cert.pem - -#Installing vagrant keys -mkdir /home/vagrant/.ssh -chmod 700 /home/vagrant/.ssh -cd /home/vagrant/.ssh -fetch -am -o authorized_keys 'https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub' -chown -R vagrant /home/vagrant/.ssh -chmod -R go-rwsx /home/vagrant/.ssh - -# As sharedfolders are not in defaults ports tree -# We will use vagrant via NFS -# Enable NFS -echo 'rpcbind_enable="YES"' >> /etc/rc.conf -echo 'nfs_server_enable="YES"' >> /etc/rc.conf -echo 'mountd_flags="-r"' >> /etc/rc.conf - -# Enable passwordless sudo -echo "vagrant ALL=(ALL) NOPASSWD: ALL" >> /usr/local/etc/sudoers - -# disable X11 because vagrants are (usually) headless -cat >> /etc/make.conf << EOT +# Disable X11 because Vagrants VMs are (usually) headless +cat >>/etc/make.conf << MAKE_CONF WITHOUT_X11="YES" -EOT - -pw groupadd vboxusers -pw groupmod vboxusers -m vagrant - +MAKE_CONF diff --git a/scripts/freebsd/sudoers.sh b/scripts/freebsd/sudoers.sh new file mode 100644 index 000000000..d8c2032b4 --- /dev/null +++ b/scripts/freebsd/sudoers.sh @@ -0,0 +1,4 @@ +#!/bin/sh -eux + +pkg install -y sudo; +echo "vagrant ALL=(ALL) NOPASSWD: ALL" >>/usr/local/etc/sudoers; diff --git a/scripts/freebsd/update.sh b/scripts/freebsd/update.sh new file mode 100644 index 000000000..0055c2c74 --- /dev/null +++ b/scripts/freebsd/update.sh @@ -0,0 +1,19 @@ +#!/bin/sh -eux + +major_version="`uname -r | awk -F. '{print $1}'`"; + +# Allow freebsd-update to run fetch without stdin attached to a terminal +sed 's/\[ ! -t 0 \]/false/' /usr/sbin/freebsd-update >/tmp/freebsd-update; +chmod +x /tmp/freebsd-update; + +# Update FreeBSD +env PAGER=/bin/cat /tmp/freebsd-update fetch; +env PAGER=/bin/cat /tmp/freebsd-update install; + +# Always use pkgng - pkg_add is EOL as of 1 September 2014 +env ASSUME_ALWAYS_YES=true pkg bootstrap; +if [ "$major_version" -lt 10 ]; then + echo "WITH_PKGNG=yes" >>/etc/make.conf; +fi + +pkg update; diff --git a/scripts/freebsd/vmtools.sh b/scripts/freebsd/vmtools.sh index 9927f1760..8ad971857 100644 --- a/scripts/freebsd/vmtools.sh +++ b/scripts/freebsd/vmtools.sh @@ -1,52 +1,66 @@ -#!/bin/sh - -freebsd_major=`uname -r | awk -F. '{ print $1 }'` -pkg_command="pkg install -y" -if [ $freebsd_major -gt 9 ]; then - perl_pkg="perl5" -else - perl_pkg="perl" -fi - -if [ $PACKER_BUILDER_TYPE == 'virtualbox-iso' ]; then - # disable X11 because vagrants are (usually) headless - echo 'WITHOUT_X11="YES"' >> /etc/make.conf - - $pkg_command virtualbox-ose-additions - - echo 'vboxdrv_load="YES"' >> /boot/loader.conf - echo 'vboxnet_enable="YES"' >> /etc/rc.conf - echo 'vboxguest_enable="YES"' >> /etc/rc.conf - echo 'vboxservice_enable="YES"' >> /etc/rc.conf - - echo 'virtio_blk_load="YES"' >> /boot/loader.conf - if [ $freebsd_major -gt 9 ]; then - # Appeared in FreeBSD 10 - echo 'virtio_scsi_load="YES"' >> /boot/loader.conf - fi - echo 'virtio_balloon_load="YES"' >> /boot/loader.conf - echo 'if_vtnet_load="YES"' >> /boot/loader.conf - - echo 'ifconfig_vtnet0_name="em0"' >> /etc/rc.conf - echo 'ifconfig_vtnet1_name="em1"' >> /etc/rc.conf - echo 'ifconfig_vtnet2_name="em2"' >> /etc/rc.conf - echo 'ifconfig_vtnet3_name="em3"' >> /etc/rc.conf -fi - -if [ $PACKER_BUILDER_TYPE == 'vmware-iso' ]; then - mkdir /tmp/vmfusion - mkdir /tmp/vmfusion-archive - mdconfig -a -t vnode -f /home/vagrant/freebsd.iso -u 0 - mount -t cd9660 /dev/md0 /tmp/vmfusion - tar xzf /tmp/vmfusion/vmware-freebsd-tools.tar.gz -C /tmp/vmfusion-archive - $pkg_command $perl_pkg - # Welcome to 2005. Have you heard of this "YouTube" thing? - $pkg_command compat6x-`uname -m` - /tmp/vmfusion-archive/vmware-tools-distrib/vmware-install.pl --default - - echo 'ifconfig_vxn0="dhcp"' >> /etc/rc.conf - umount /tmp/vmfusion - rmdir /tmp/vmfusion - rm -rf /tmp/vmfusion-archive - rm /home/vagrant/freebsd.iso -fi +#!/bin/sh -eux + +freebsd_major="`uname -r | awk -F. '{print $1}'`"; + +case "$PACKER_BUILDER_TYPE" in + +virtualbox-iso|virtualbox-ovf) + # Disable X11 because vagrants are (usually) headless + echo 'WITHOUT_X11="YES"' >> /etc/make.conf; + + pkg install -y virtualbox-ose-additions; + + echo 'vboxdrv_load="YES"' >>/boot/loader.conf; + echo 'vboxnet_enable="YES"' >>/etc/rc.conf; + echo 'vboxguest_enable="YES"' >>/etc/rc.conf; + echo 'vboxservice_enable="YES"' >>/etc/rc.conf; + + echo 'virtio_blk_load="YES"' >>/boot/loader.conf; + if [ "$freebsd_major" -gt 9 ]; then + # Appeared in FreeBSD 10 + echo 'virtio_scsi_load="YES"' >>/boot/loader.conf; + fi + echo 'virtio_balloon_load="YES"' >>/boot/loader.conf; + echo 'if_vtnet_load="YES"' >>/boot/loader.conf; + + echo 'ifconfig_vtnet0_name="em0"' >>/etc/rc.conf; + echo 'ifconfig_vtnet1_name="em1"' >>/etc/rc.conf; + echo 'ifconfig_vtnet2_name="em2"' >>/etc/rc.conf; + echo 'ifconfig_vtnet3_name="em3"' >>/etc/rc.conf; + + pw groupadd vboxusers; + pw groupmod vboxusers -m vagrant; + ;; + +vmware-iso|vmware-vmx) + # Install Perl and other software needed by vmware-install.pl + pkg install -y perl5; + pkg install -y compat6x-`uname -m`; + # the install script is very picky about location of perl command + ln -s /usr/local/bin/perl /usr/bin/perl; + + mkdir -p /tmp/vmfusion; + mkdir -p /tmp/vmfusion-archive; + mdconfig -a -t vnode -f $HOME_DIR/freebsd.iso -u 0; + mount -t cd9660 /dev/md0 /tmp/vmfusion; + tar xzf /tmp/vmfusion/vmware-freebsd-tools.tar.gz -C /tmp/vmfusion-archive; + /tmp/vmfusion-archive/vmware-tools-distrib/vmware-install.pl --default; + echo 'ifconfig_vxn0="dhcp"' >>/etc/rc.conf; + umount /tmp/vmfusion; + rm -rf /tmp/vmfusion; + rm -rf /tmp/vmfusion-archive; + rm -f $HOME_DIR/*.iso; + + rm -f /usr/bin/perl; + ;; + +parallels-iso|parallels-pvm) + echo "No current support for Parallels tools, continuing" + ;; + +*) + echo "Unknown Packer Builder Type >>$PACKER_BUILDER_TYPE<< selected."; + echo "Known are virtualbox-iso|virtualbox-ovf|vmware-iso|vmware-vmx|parallels-iso|parallels-pvm."; + ;; + +esac diff --git a/vagrantfile_templates/freebsd.rb b/vagrantfile_templates/freebsd.rb new file mode 100644 index 000000000..b32e741b2 --- /dev/null +++ b/vagrantfile_templates/freebsd.rb @@ -0,0 +1,15 @@ +Vagrant.require_version '>= 1.1.0' + +Vagrant.configure(2) do |config| + config.ssh.shell = 'sh' + + # Disable the base shared folder, Guest Tools supporting this feature are + # unavailable for all providers. + config.vm.synced_folder '.', '/vagrant', disabled: true + + config.vm.provider :parallels do |prl, override| + # Guest Tools are unavailable. + prl.check_guest_tools = false + prl.functional_psf = false + end +end diff --git a/vagrantfile_templates/parallels/freebsd.rb b/vagrantfile_templates/parallels/freebsd.rb deleted file mode 100644 index 1f795a8c4..000000000 --- a/vagrantfile_templates/parallels/freebsd.rb +++ /dev/null @@ -1,17 +0,0 @@ -# -*- mode: ruby -*- -# # vi: set ft=ruby : - -Vagrant.require_version ">= 1.1.0" - -Vagrant.configure("2") do |config| - config.ssh.shell = "sh" - - # Disable the base shared folder, Guest Tools are unavailable. - config.vm.synced_folder ".", "/vagrant", disabled: true - - config.vm.provider :parallels do |prl| - # Guest Tools are unavailable. - prl.check_guest_tools = false - prl.functional_psf = false - end -end