From 2ab72d435c10eef100615b61e7b6d59629d34955 Mon Sep 17 00:00:00 2001 From: Ankur Agarwal Date: Wed, 29 Aug 2018 12:04:26 -0700 Subject: [PATCH 1/6] Update build json files and install scripts, refactor code Following changes were made: 1. Add a null.json build json template for quickly testing stand alone commands and functionality. 2. Add create user script invoked as part of minimal build to create a new user specified in newuser.json. 3. Parameterize new user creation by using a var-file newuser.json. 4. Refactor/update/rename install scripts for jdk, intellij, netbeans, nix to execute as sudo newuser. 5. Add install scripts for vmware-tools, ansible, svn. Modify install script for nix2.0.4 package manager. 6. Install xorg-x11-drv-vmware Xorg X11 vmware video driver as part of kick start file. 7. Remove some uneeded scripts. --- build.sh | 9 +++ c6x64/gui-dev-java.json | 111 +++++++++++++++++++++++++----------- c6x64/gui.json | 19 +++--- c6x64/kernel-ml-epel.json | 20 ++++--- c6x64/minimal.json | 37 ++++++++---- c6x64/minimal_vmware.json | 38 ++++++++++++ c6x64/newuser.json | 11 ++++ c6x64/null.json | 36 ++++++++++++ http/centos6.ks | 4 +- scripts/cleanup.sh | 2 +- scripts/createuser.sh | 56 ++++++++++++++++++ scripts/install-nix-2.0.4 | 60 +++++++++++++++++++ scripts/install_ansible.sh | 3 + scripts/install_git.sh | 12 ++++ scripts/install_intellij.sh | 16 ++++++ scripts/install_jdk.sh | 9 +++ scripts/install_netbeans.sh | 18 ++++++ scripts/install_svn.sh | 12 ++++ scripts/install_vmtools.sh | 11 ++++ scripts/intellij.sh | 41 ------------- scripts/jdk.sh | 41 ------------- scripts/netbeans.sh | 41 ------------- scripts/nix-chromium.sh | 26 +-------- scripts/nix.sh | 36 ------------ scripts/runovftool.sh | 76 ++++++++++++++++++++++++ scripts/sleep-debug.sh | 6 -- scripts/unsudo.sh | 29 ---------- 27 files changed, 495 insertions(+), 285 deletions(-) create mode 100755 build.sh create mode 100644 c6x64/minimal_vmware.json create mode 100644 c6x64/newuser.json create mode 100644 c6x64/null.json create mode 100644 scripts/createuser.sh create mode 100644 scripts/install-nix-2.0.4 create mode 100644 scripts/install_ansible.sh create mode 100644 scripts/install_git.sh create mode 100644 scripts/install_intellij.sh create mode 100644 scripts/install_jdk.sh create mode 100644 scripts/install_netbeans.sh create mode 100644 scripts/install_svn.sh create mode 100644 scripts/install_vmtools.sh delete mode 100644 scripts/intellij.sh delete mode 100644 scripts/jdk.sh delete mode 100644 scripts/netbeans.sh delete mode 100644 scripts/nix.sh create mode 100755 scripts/runovftool.sh delete mode 100644 scripts/sleep-debug.sh delete mode 100644 scripts/unsudo.sh diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..ebbae37 --- /dev/null +++ b/build.sh @@ -0,0 +1,9 @@ +#!/bin/bash -x + +time PACKER_LOG=1 packer build -on-error=ask -var-file=c6x64/newuser.json c6x64/minimal.json +sleep 5 +time PACKER_LOG=1 packer build -on-error=ask -var-file=c6x64/newuser.json c6x64/kernel-ml-epel.json +sleep 5 +time PACKER_LOG=1 packer build -on-error=ask -var-file=c6x64/newuser.json c6x64/gui.json +sleep 5 +time PACKER_LOG=1 packer build -on-error=ask -var-file=c6x64/newuser.json c6x64/gui-dev-java.json diff --git a/c6x64/gui-dev-java.json b/c6x64/gui-dev-java.json index 8d6fa95..b62075d 100644 --- a/c6x64/gui-dev-java.json +++ b/c6x64/gui-dev-java.json @@ -2,60 +2,103 @@ "provisioners": [ { "type": "file", - "source": "cache/nix-2.0.2-x86_64-linux.tar.bz2", - "destination": "nix-2.0.2-x86_64-linux.tar.bz2" - }, - { - "type": "file", - "source": "cache/ideaIC-2018.1.3.tar.gz", - "destination": "ideaIC-2018.1.3.tar.gz" - }, - { + "source": "cache/nix-2.0.4-x86_64-linux.tar.bz2", + "destination": "nix-2.0.4-x86_64-linux.tar.bz2" + }, + { "type": "file", "source": "cache/jdk-8u144-linux-x64.rpm", "destination": "jdk-8u144-linux-x64.rpm" - }, - { + }, + + { + "type": "file", + "source": "cache/VMwareTools-10.0.6-3595377.tar.gz", + "destination": "VMwareTools-10.0.6-3595377.tar.gz" + }, + + { + "type": "file", + "source": "cache/ideaIC-2018.1.6.tar.gz", + "destination": "ideaIC-2018.1.6.tar.gz" + }, + { "type": "file", - "source": "cache/netbeans-8.2-javase-linux.sh", - "destination": "netbeans-8.2-javase-linux.sh" + "source": "cache/netbeans-8.2-linux.sh", + "destination": "netbeans-8.2-linux.sh" }, - { + { "type": "shell", - "execute_command": "chmod +x {{ .Path }}; sudo {{ .Vars }} {{ .Path }}", + "environment_vars": [ "NEWUSERLOGIN={{ user `NEWUSERLOGIN` }}" ], + "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}", "scripts": [ - "scripts/nix.sh", - "scripts/nix-chromium.sh", - "scripts/jdk.sh", - "scripts/netbeans.sh", - "scripts/intellij.sh", - "scripts/cleanup.sh" - ] - } - ], + "scripts/install-nix-2.0.4" + ] +}, +{ + "type": "shell", + "environment_vars": [ "NEWUSERLOGIN={{ user `NEWUSERLOGIN` }}", "JDK_FILENAME={{user `JDK_FILENAME`}}" ], + "execute_command": "chmod +x {{ .Path }}; sudo {{ .Vars }} {{ .Path }}", + "scripts": [ + "scripts/install_jdk.sh" + ] +}, +{ + "type": "shell", + "environment_vars": [ "NEWUSERLOGIN={{ user `NEWUSERLOGIN` }}" ], + "execute_command": "chmod +x {{ .Path }}; sudo {{ .Vars }} {{ .Path }}", + "scripts": [ + "scripts/install_vmtools.sh" + ] +}, +{ + "type": "shell", + "environment_vars": [ "NEWUSERLOGIN={{ user `NEWUSERLOGIN` }}", "INTELLIJ_FILENAME={{ user `INTELLIJ_FILENAME` }}" ], + "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}", + "scripts": [ + "scripts/install_intellij.sh" + ] +}, +{ + "type": "shell", + "environment_vars": [ "NEWUSERLOGIN={{ user `NEWUSERLOGIN` }}", "NETBEANS_FILENAME={{ user `NETBEANS_FILENAME` }}" ], + "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}", + "scripts": [ + "scripts/install_netbeans.sh" + ] +} +], "builders": [ { "type": "virtualbox-ovf", - "source_path": "build/c6x64-gui.ova", + "source_path": "c6x64-gui.ova", "output_directory": "build/out", - "vm_name": "c6x64-gui-dev-java", + "vm_name": "c6x64-final", "boot_wait": "5s", "format": "ova", "guest_additions_mode": "disable", "http_directory": "http", - "ssh_username": "vagrant", + "ssh_username": "{{ user `NEWUSERLOGIN` }}", "ssh_password": "vagrant", "ssh_port": 22, "ssh_wait_timeout": "10000s", "shutdown_command": "echo 'rm -f /etc/ssh/ssh_host*; rm -f /tmp/shutdown.sh; /sbin/halt -h -p' > /tmp/shutdown.sh; sudo sh /tmp/shutdown.sh", "vboxmanage": [ - [ - "modifyvm", - "{{.Name}}", - "--memory", - "1024" - ] + ["modifyvm", "{{.Name}}", "--memory","8192"], + ["modifyvm", "{{.Name}}", "--cpus", "3"] ] } - ] +], + +"post-processors": [ + { + "type": "shell-local", + "command": "mv build/out/c6x64-final.ova . ; rm -rf build/*" + }, + { + "type": "shell-local", + "command": "scripts/runovftool.sh c6x64-final.ova" + } +] + } diff --git a/c6x64/gui.json b/c6x64/gui.json index 7c42bbd..af0f4c9 100644 --- a/c6x64/gui.json +++ b/c6x64/gui.json @@ -12,26 +12,27 @@ "builders": [ { "type": "virtualbox-ovf", - "source_path": "build/c6x64-kernel-ml-epel.ova", + "source_path": "c6x64-kernel-ml-epel.ova", "output_directory": "build/out", "vm_name": "c6x64-gui", "boot_wait": "5s", "format": "ova", "guest_additions_mode": "disable", "http_directory": "http", - "ssh_username": "vagrant", + "ssh_username": "{{ user `NEWUSERLOGIN` }}", "ssh_password": "vagrant", "ssh_port": 22, "ssh_wait_timeout": "10000s", "shutdown_command": "echo 'rm -f /etc/ssh/ssh_host*; rm -f /tmp/shutdown.sh; /sbin/halt -h -p' > /tmp/shutdown.sh; sudo sh /tmp/shutdown.sh", "vboxmanage": [ - [ - "modifyvm", - "{{.Name}}", - "--memory", - "1024" - ] + ["modifyvm", "{{.Name}}", "--memory","8192"], + ["modifyvm", "{{.Name}}", "--cpus", "3"] ] } - ] +], + +"post-processors": [{ + "type": "shell-local", + "command": "mv build/out/c6x64-gui.ova . ; rm -rf build/*" + }] } diff --git a/c6x64/kernel-ml-epel.json b/c6x64/kernel-ml-epel.json index 4061336..739cc33 100644 --- a/c6x64/kernel-ml-epel.json +++ b/c6x64/kernel-ml-epel.json @@ -7,6 +7,7 @@ "scripts": [ "scripts/elrepo-kernel-ml.sh", "scripts/epel.sh", + "scripts/install_ansible.sh", "scripts/cleanup.sh" ] } @@ -14,26 +15,27 @@ "builders": [ { "type": "virtualbox-ovf", - "source_path": "build/c6x64-minimal.ova", + "source_path": "c6x64-minimal.ova", "output_directory": "build/out", "vm_name": "c6x64-kernel-ml-epel", "boot_wait": "5s", "format": "ova", "guest_additions_mode": "disable", "http_directory": "http", - "ssh_username": "vagrant", + "ssh_username": "{{ user `NEWUSERLOGIN` }}", "ssh_password": "vagrant", "ssh_port": 22, "ssh_wait_timeout": "10000s", "shutdown_command": "echo 'rm -f /etc/ssh/ssh_host*; rm -f /tmp/shutdown.sh; /sbin/halt -h -p' > /tmp/shutdown.sh; sudo sh /tmp/shutdown.sh", + "post_shutdown_delay" : "2m", "vboxmanage": [ - [ - "modifyvm", - "{{.Name}}", - "--memory", - "1024" - ] + ["modifyvm", "{{.Name}}", "--memory","8192"], + ["modifyvm", "{{.Name}}", "--cpus", "3"] ] } - ] +], +"post-processors": [{ + "type": "shell-local", + "command": "mv build/out/c6x64-kernel-ml-epel.ova . ; rm -rf build/*" + }] } diff --git a/c6x64/minimal.json b/c6x64/minimal.json index eaab66f..895fa68 100644 --- a/c6x64/minimal.json +++ b/c6x64/minimal.json @@ -2,11 +2,22 @@ "provisioners": [ { "type": "shell", + "environment_vars": ["NEWUSERLOGIN={{ user `NEWUSERLOGIN` }}", + "NEWUSERFULLNAME={{ user `NEWUSERFULLNAME` }}", + "AWS_ACCESS_KEY_ID={{ user `AWS_ACCESS_KEY_ID`}}", + "AWS_SECRET_ACCESS_KEY={{user `AWS_SECRET_ACCESS_KEY`}}", + "AZURE_SECRET={{user `AZURE_SECRET`}}", + "SVN_SERVER_URL={{user `SVN_SERVER_URL`}}" + ], "execute_command": "chmod +x {{ .Path }}; sudo {{ .Vars }} {{ .Path }}", "scripts": [ + "scripts/createuser.sh", + "scripts/install_svn.sh", + "scripts/install_git.sh", "scripts/cleanup.sh" ] - } + } + ], "builders": [ { @@ -17,27 +28,29 @@ " text selinux=0 ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/centos6.ks" ], "boot_wait": "5s", - "disk_size": 409600, + "disk_size": 51200, "format": "ova", "guest_additions_mode": "disable", "guest_os_type": "RedHat_64", "http_directory": "http", - "iso_url": "http://mirrors.kernel.org/centos/6/isos/x86_64/CentOS-6.9-x86_64-minimal.iso", - "iso_checksum_type": "sha256", - "iso_checksum": "422af57b493b8af49d485885a730c5a1d955f803fac85aa51311c393168b9080", + "iso_url": "https://mirrors.edge.kernel.org/centos/6/isos/x86_64/CentOS-6.10-x86_64-minimal.iso", + "iso_checksum_type": "sha1", + "iso_checksum": "9cecc12a66c4f9a4225d18fe0aaab412ba367549", "ssh_username": "vagrant", "ssh_password": "vagrant", "ssh_port": 22, "ssh_wait_timeout": "10000s", "shutdown_command": "echo 'rm -f /etc/ssh/ssh_host*; rm -f /tmp/shutdown.sh; /sbin/halt -h -p' > /tmp/shutdown.sh; sudo sh /tmp/shutdown.sh", + "post_shutdown_delay" : "2m", "vboxmanage": [ - [ - "modifyvm", - "{{.Name}}", - "--memory", - "1024" - ] + ["modifyvm", "{{.Name}}", "--memory","8192"], + ["modifyvm", "{{.Name}}", "--cpus", "3"] ] } - ] +], + +"post-processors": [{ + "type": "shell-local", + "command": "mv build/out/c6x64-minimal.ova . ; rm -rf build/*" + }] } diff --git a/c6x64/minimal_vmware.json b/c6x64/minimal_vmware.json new file mode 100644 index 0000000..e118b5a --- /dev/null +++ b/c6x64/minimal_vmware.json @@ -0,0 +1,38 @@ +{ + "provisioners": [ + { + "type": "shell", + "execute_command": "chmod +x {{ .Path }}; sudo {{ .Vars }} {{ .Path }}", + "scripts": [ + "scripts/cleanup.sh" + ] + } + ], + "builders": [ + { + "type": "vmware-iso", + "output_directory": "build/out", + "vm_name": "c6x64-minimal", + "boot_command": [ + " text selinux=0 ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/centos6.ks" + ], + "boot_wait": "5s", + "disk_size": 10240, + "format": "ova", + "guest_os_type": "RedHat_64", + "http_directory": "http", + "iso_url": "https://mirrors.edge.kernel.org/centos/6/isos/x86_64/CentOS-6.10-x86_64-minimal.iso", + "iso_checksum_type": "sha1", + "iso_checksum": "9cecc12a66c4f9a4225d18fe0aaab412ba367549", + "ssh_username": "vagrant", + "ssh_password": "vagrant", + "ssh_port": 22, + "ssh_wait_timeout": "10000s", + "shutdown_command": "echo 'rm -f /etc/ssh/ssh_host*; rm -f /tmp/shutdown.sh; /sbin/halt -h -p' > /tmp/shutdown.sh; sudo sh /tmp/shutdown.sh", + "vmx_data": { + "memsize": "8192", + "numvcpus": "3" + } + } + ] +} diff --git a/c6x64/newuser.json b/c6x64/newuser.json new file mode 100644 index 0000000..3de996c --- /dev/null +++ b/c6x64/newuser.json @@ -0,0 +1,11 @@ +{ + "NEWUSERLOGIN": "flast", + "NEWUSERFULLNAME": "First Last", + "AWS_ACCESS_KEY_ID": "AWS_ACCESS_KEY_ID", + "AWS_SECRET_ACCESS_KEY": "AWS_SECRET_ACCESS_KEY", + "AZURE_SECRET" : "AZURE_SECRET\\nAZURE_SECRET2\\nAZURE_SECRET3", + "SVN_SERVER_URL": "SVN_SERVER_URL", + "JDK_FILENAME": "jdk-8u144-linux-x64.rpm", + "INTELLIJ_FILENAME": "ideaIC-2018.1.6.tar.gz", + "NETBEANS_FILENAME": "netbeans-8.2-linux.sh" +} diff --git a/c6x64/null.json b/c6x64/null.json new file mode 100644 index 0000000..9ce1c1d --- /dev/null +++ b/c6x64/null.json @@ -0,0 +1,36 @@ +{ + + "provisioners": [ + { + "type": "shell", + "environment_vars": ["NEWUSERLOGIN={{ user `NEWUSERLOGIN` }}", + "NEWUSERFULLNAME={{ user `NEWUSERFULLNAME` }}", + "AWS_ACCESS_KEY_ID={{ user `AWS_ACCESS_KEY_ID`}}", + "AWS_SECRET_ACCESS_KEY={{user `AWS_SECRET_ACCESS_KEY`}}", + "AZURE_SECRET={{user `AZURE_SECRET`}}", + "SVN_SERVER_URL={{user `SVN_SERVER_URL`}}" + ], + "execute_command": "chmod +x {{ .Path }}; sudo {{ .Vars }} {{ .Path }}", + "scripts": [ + "scripts/createuser.sh" + ] + }, + { + "type": "file", + "source": "cache/nix-2.0.2-x86_64-linuxaaaaaa.tar.bz2", + "destination": "nix-2.0.2-x86_64-linuxaaaaaa.tar.bz2" + } + ], + + "builders": [ + { + "type": "null", + "communicator": "ssh", + "ssh_timeout": "5s", + "ssh_host": "192.168.9.13", + "ssh_username": "{{ user `NEWUSERLOGIN` }}", + "ssh_port": 22, + "ssh_password": "vagrant" + } + ] +} diff --git a/http/centos6.ks b/http/centos6.ks index fdab22c..493617b 100644 --- a/http/centos6.ks +++ b/http/centos6.ks @@ -14,6 +14,7 @@ rootpw vagrant # user is given sudo in %post user --name=vagrant --password=vagrant + # US + UTC keyboard us lang en_US.UTF-8 @@ -46,9 +47,9 @@ selinux --disabled zerombr # Really disable selinux bootloader --location=mbr --append="selinux=0" + # Create a single ext4 partition covering the entire disk clearpart --all - # part / --fstype=ext4 --grow --asprimary --size=1 part /boot --fstype ext4 --size=1024 @@ -79,6 +80,7 @@ chvt 3 yum -y update # Install man pages yum -y install yum-utils man man-pages +yum -y install xorg-x11-drv-vmware # Disable graphical boot sed -i '/^splashimage/d' /boot/grub/grub.conf diff --git a/scripts/cleanup.sh b/scripts/cleanup.sh index 057578d..1d2025b 100644 --- a/scripts/cleanup.sh +++ b/scripts/cleanup.sh @@ -7,7 +7,7 @@ package-cleanup --oldkernels --count=1 -y yum -y clean all # Remove hardware specific udev rules so hardware is properly initialized when -# being instanciated on new hardware. Without this networking can fail to come +# being instantiated on new hardware. Without this networking can fail to come # up as the eth0 MAC address should have changed. rm -f /etc/udev/rules.d/70-*.rules # Remove other references to hardware specific things with repsect to networking diff --git a/scripts/createuser.sh b/scripts/createuser.sh new file mode 100644 index 0000000..f60b807 --- /dev/null +++ b/scripts/createuser.sh @@ -0,0 +1,56 @@ +#!/bin/bash -x + +echo "Running: useradd -m -d /home/$NEWUSERLOGIN -c $NEWUSERFULLNAME -s /bin/bash -r -U $NEWUSERLOGIN" +useradd -m -d /home/$NEWUSERLOGIN -c "$NEWUSERFULLNAME" -s /bin/bash -U $NEWUSERLOGIN +echo "Done.." + +echo "Running: usermod -g $NEWUSERLOGIN $NEWUSERLOGIN" +usermod -g $NEWUSERLOGIN $NEWUSERLOGIN +echo "Done.." + +echo "Setting up passwordless sudo for $NEWUSERLOGIN" +echo "$NEWUSERLOGIN ALL=(ALL) NOPASSWD: ALL" | sudo tee "/etc/sudoers.d/$NEWUSERLOGIN" &>/dev/null +echo "Done.." + +echo "Setting password for $NEWUSERLOGIN" +echo "$NEWUSERLOGIN:vagrant" | chpasswd +echo "Done.." + +echo "Doing echo $AWS_ACCESS_KEY_ID > /home/$NEWUSERLOGIN/.awssecret" +echo $AWS_ACCESS_KEY_ID > /home/$NEWUSERLOGIN/.awssecret +echo "Done.." + +echo "Doing $AWS_SECRET_ACCESS_KEY >> /home/$NEWUSERLOGIN/.awssecret" +echo $AWS_SECRET_ACCESS_KEY >> /home/$NEWUSERLOGIN/.awssecret # note >> for append +echo "Done.." + +echo "Doing echo -ne $AZURE_SECRET > /home/$NEWUSERLOGIN/.azuresecret" +echo -ne $AZURE_SECRET > /home/$NEWUSERLOGIN/.azuresecret +echo "Done.." + +echo "Doing chmod 600 /home/$NEWUSERLOGIN/.azuresecret" +chmod 600 /home/$NEWUSERLOGIN/.azuresecret +echo "Done.." + +echo "Doing chown $NEWUSERLOGIN:$NEWUSERLOGIN /home/$NEWUSERLOGIN/.azuresecret" +chown $NEWUSERLOGIN:$NEWUSERLOGIN /home/$NEWUSERLOGIN/.azuresecret +echo "Done.." + +echo "Doing chown $NEWUSERLOGIN:$NEWUSERLOGIN /home/$NEWUSERLOGIN/.awssecret" +chown $NEWUSERLOGIN:$NEWUSERLOGIN /home/$NEWUSERLOGIN/.awssecret +echo "Done.." + +echo "Creating ssh keys for $NEWUSERLOGIN" +su -l $NEWUSERLOGIN -c 'ssh-keygen -f ~/.ssh/id_rsa -N ""' +echo "Done.." + +echo "Setting up ~/.ssh/config for $NEWUSERLOGIN" +echo -e "\nHost $SVN_SERVER_URL svn1 svn\n User=$NEWUSERLOGIN" >> /home/$NEWUSERLOGIN/.ssh/config +echo "Done.." + +echo "Set up Publickey based ssh login to self" +cat /home/$NEWUSERLOGIN/.ssh/id_rsa.pub >> /home/$NEWUSERLOGIN/.ssh/authorized_keys +echo "Done.." + + +echo "User \"$NEWUSERLOGIN\" with full name \"$NEWUSERFULLNAME\" created successfully" diff --git a/scripts/install-nix-2.0.4 b/scripts/install-nix-2.0.4 new file mode 100644 index 0000000..8c2d64b --- /dev/null +++ b/scripts/install-nix-2.0.4 @@ -0,0 +1,60 @@ +#!/bin/sh + +# This script installs the Nix package manager on your system by +# downloading a binary distribution and running its installer script +# (which in turn creates and populates /nix). + +{ # Prevent execution if this script was only partially downloaded +oops() { + echo "$0:" "$@" >&2 + exit 1 +} + +tmpDir="$(mktemp -d -t nix-binary-tarball-unpack.XXXXXXXXXX || \ + oops "Can\'t create temporary directory for downloading the Nix binary tarball")" +cleanup() { + rm -rf "$tmpDir" +} +trap cleanup EXIT INT QUIT TERM + +require_util() { + type "$1" > /dev/null 2>&1 || which "$1" > /dev/null 2>&1 || + oops "you do not have '$1' installed, which I need to $2" +} + +case "$(uname -s).$(uname -m)" in + Linux.x86_64) system=x86_64-linux; hash=d6db178007014ed47ad5460c1bd5b2cb9403b1ec543a0d6507cb27e15358341f;; + Linux.i?86) system=i686-linux; hash=b2e5b62a66c6d1951fdd5e01109680592b498ef40f28bfc790341f5b986ba34d;; + Linux.aarch64) system=aarch64-linux; hash=248be69c25f599ac214bad1e4f4003e27f1da83cb17f7cd762746bd2c215a0df;; + Darwin.x86_64) system=x86_64-darwin; hash=ec6279bb6d628867d82a6e751dac2bcb64ccea3194d753756a309f75fd704d4c;; + *) oops "sorry, there is no binary distribution of Nix for your platform";; +esac + +tarball="/home/$NEWUSERLOGIN/nix-2.0.4-$system.tar.bz2" + +echo "copying Nix 2.0.4 binary tarball for $system from $tarball to $tmpDir ..." + +if type sha256sum > /dev/null 2>&1; then + hash2="$(sha256sum -b "$tarball" | cut -c1-64)" +elif type shasum > /dev/null 2>&1; then + hash2="$(shasum -a 256 -b "$tarball" | cut -c1-64)" +elif type openssl > /dev/null 2>&1; then + hash2="$(openssl dgst -r -sha256 "$tarball" | cut -c1-64)" +else + oops "cannot verify the SHA-256 hash of $tarball; you need one of 'shasum', 'sha256sum', or 'openssl'" +fi + +if [ "$hash" != "$hash2" ]; then + oops "SHA-256 hash mismatch in '$url'; expected $hash, got $hash2" +fi + +unpack=$tmpDir/unpack +mkdir -p "$unpack" +< "$tarball" bzcat | tar -xf - -C "$unpack" || oops "failed to unpack $tarball" + +script=$(echo "$unpack"/*/install) + +[ -e "$script" ] || oops "installation script is missing from the binary tarball!" +"$script" "$@" + +} # End of wrapping diff --git a/scripts/install_ansible.sh b/scripts/install_ansible.sh new file mode 100644 index 0000000..f8f2d54 --- /dev/null +++ b/scripts/install_ansible.sh @@ -0,0 +1,3 @@ +#!/bin/bash -x + +yum -y install ansible diff --git a/scripts/install_git.sh b/scripts/install_git.sh new file mode 100644 index 0000000..47ed1f1 --- /dev/null +++ b/scripts/install_git.sh @@ -0,0 +1,12 @@ +#!/bin/bash -x + +cat < /etc/yum.repos.d/WANdisco-git.repo +[WANdisco-git] +name=WANdisco Distribution of git +baseurl=http://opensource.wandisco.com/rhel/\$releasever/git/\$basearch +enabled=1 +gpgcheck=1 +gpgkey=http://opensource.wandisco.com/RPM-GPG-KEY-WANdisco +WANdisco-git + +yum -y install git diff --git a/scripts/install_intellij.sh b/scripts/install_intellij.sh new file mode 100644 index 0000000..7945bb3 --- /dev/null +++ b/scripts/install_intellij.sh @@ -0,0 +1,16 @@ +#!/bin/bash -x + +set -o errexit +set -o nounset +set -o pipefail + +[ -f "/home/${NEWUSERLOGIN}/${INTELLIJ_FILENAME}" ] + +EXTRACTDIR="$(dirname $(tar -ztf "${INTELLIJ_FILENAME}" | head -n1))" + +tar -zxf "/home/${NEWUSERLOGIN}/${INTELLIJ_FILENAME}" + +[ -f "/home/${NEWUSERLOGIN}/${EXTRACTDIR}/bin/idea.sh" ] + +# Desktop is not created until after graphical login +ln -s "/home/${NEWUSERLOGIN}/${EXTRACTDIR}/bin/idea.sh" "/home/${NEWUSERLOGIN}/IntelliJ_launcher" diff --git a/scripts/install_jdk.sh b/scripts/install_jdk.sh new file mode 100644 index 0000000..ccf7877 --- /dev/null +++ b/scripts/install_jdk.sh @@ -0,0 +1,9 @@ +#!/bin/bash -x + +set -o errexit +set -o nounset +set -o pipefail + +rpm -qp "/home/${NEWUSERLOGIN}/${JDK_FILENAME}" -K +sudo yum -y remove 'java-*-openj*' || /bin/true +sudo yum -y install "${JDK_FILENAME}" diff --git a/scripts/install_netbeans.sh b/scripts/install_netbeans.sh new file mode 100644 index 0000000..60102c0 --- /dev/null +++ b/scripts/install_netbeans.sh @@ -0,0 +1,18 @@ +#!/bin/bash -x + +set -o errexit +set -o nounset +set -o pipefail + + + +[ -f "/home/${NEWUSERLOGIN}/${NETBEANS_FILENAME}" ] + +/home/${NEWUSERLOGIN}/${NETBEANS_FILENAME} --silent + +[ -f "/home/${NEWUSERLOGIN}/netbeans-8.2/etc/netbeans.conf" ] + +sed -i 's|^netbeans_jdkhome=.*|netbeans_jdkhome="/usr/java/latest"|' "/home/${NEWUSERLOGIN}/netbeans-8.2/etc/netbeans.conf" + +# Desktop is not created until after graphical login +ln -s "/home/${NEWUSERLOGIN}/netbeans-8.2/bin/netbeans" "/home/${NEWUSERLOGIN}/netbeans8.2_launcher" diff --git a/scripts/install_svn.sh b/scripts/install_svn.sh new file mode 100644 index 0000000..f66961f --- /dev/null +++ b/scripts/install_svn.sh @@ -0,0 +1,12 @@ +#!/bin/bash -x + +cat < /etc/yum.repos.d/WANdisco-svn1.9.repo +[WANdisco-svn19] +name=WANdisco SVN Repo 1.9 - \$basearch +enabled=1 +baseurl=http://opensource.wandisco.com/rhel/6/svn-1.9/RPMS/\$basearch/ +gpgcheck=1 +gpgkey=http://opensource.wandisco.com/RPM-GPG-KEY-WANdisco +WANdisco-svn1.9 + +yum -y install subversion.x86_64 subversion-perl subversion-python subversion-tools diff --git a/scripts/install_vmtools.sh b/scripts/install_vmtools.sh new file mode 100644 index 0000000..bf46367 --- /dev/null +++ b/scripts/install_vmtools.sh @@ -0,0 +1,11 @@ +#!/bin/bash -x + +set -o errexit +set -o nounset +set -o pipefail + +tar -xzvf /home/$NEWUSERLOGIN/VMwareTools-10.0.6-3595377.tar.gz +sync +sleep 5 +sync +/home/$NEWUSERLOGIN/vmware-tools-distrib/vmware-install.pl -d diff --git a/scripts/intellij.sh b/scripts/intellij.sh deleted file mode 100644 index 8c5a81f..0000000 --- a/scripts/intellij.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -x - -set -o errexit -set -o nounset -set -o pipefail - -# The intention of this block is to recursively call this script without root -# permissions if invoked with sudo. If invoked as root without sudo, bail out. -if [ ${EUID} -eq 0 ]; then - # Running with root perms. Because of sudo? - if [ -z "${SUDO_USER:-}" ]; then - # script executed without sudo - echo "This script is not meant to run as root" >&2 - exit 1 - else - # script executed with sudo. recurse as the user that invoked this script - # so long as that user was not root. - SUDO_UID="$(id -u "${SUDO_USER}")" - if [ ${SUDO_UID} -eq 0 ]; then - echo "This script is not meant to run as root" >&2 - exit 1 - else - sudo -u "${SUDO_USER}" -i "${0}" ${@} - exit 0 - fi - fi -fi - -cd "${HOME}" - -INTELLIJ_URL="https://download.jetbrains.com/idea/ideaIC-2018.1.3.tar.gz" -INTELLIJ_FILENAME="$(basename "${INTELLIJ_URL}")" -#INTELLIJ_SHA256='9e3e0f4538707da37237106697fff4e0b5ed651085f456671764e1fbc9651bbe' - -#curl -L "${INTELLIJ_URL}" > "${INTELLIJ_FILENAME}" -[ -f "${INTELLIJ_FILENAME}" ] -#echo "${INTELLIJ_SHA256} ${INTELLIJ_FILENAME}" | sha256sum -c -EXTRACTDIR="$(dirname $(tar -ztf "${INTELLIJ_FILENAME}" | head -n1))" -tar -zxf "${INTELLIJ_FILENAME}" -[ -f "${HOME}/${EXTRACTDIR}/bin/idea.sh" ] -ln -s "${HOME}/${EXTRACTDIR}/bin/idea.sh" "${HOME}/Desktop/IntelliJ" diff --git a/scripts/jdk.sh b/scripts/jdk.sh deleted file mode 100644 index 01cb1f1..0000000 --- a/scripts/jdk.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -x - -set -o errexit -set -o nounset -set -o pipefail - -# The intention of this block is to recursively call this script without root -# permissions if invoked with sudo. If invoked as root without sudo, bail out. -if [ ${EUID} -eq 0 ]; then - # Running with root perms. Because of sudo? - if [ -z "${SUDO_USER:-}" ]; then - # script executed without sudo - echo "This script is not meant to run as root" >&2 - exit 1 - else - # script executed with sudo. recurse as the user that invoked this script - # so long as that user was not root. - SUDO_UID="$(id -u "${SUDO_USER}")" - if [ ${SUDO_UID} -eq 0 ]; then - echo "This script is not meant to run as root" >&2 - exit 1 - else - sudo -u "${SUDO_USER}" -i "${0}" ${@} - exit 0 - fi - fi -fi - -cd "${HOME}" - -#URL="http://download.oracle.com/otn-pub/java/jdk/8u60-b27/jdk-8u60-linux-x64.rpm" -#URL="http://download.oracle.com/otn-pub/java/jdk/8u66-b17/jdk-8u66-linux-x64.rpm" -#URL="http://download.oracle.com/otn-pub/java/jdk/8u77-b03/jdk-8u77-linux-x64.rpm" -#URL="http://download.oracle.com/otn-pub/java/jdk/8u91-b14/jdk-8u91-linux-x64.rpm" -URL="http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.rpm" -FILENAME="$(basename "${URL}")" -[ -f "${FILENAME}" ] -#curl -f -L -H 'Cookie: oraclelicense=accept-securebackup-cookie' "${URL}" > "${FILENAME}" -rpm -qp "${FILENAME}" -K -sudo yum -y remove 'java-*-openj*' || /bin/true -sudo yum -y install "${FILENAME}" diff --git a/scripts/netbeans.sh b/scripts/netbeans.sh deleted file mode 100644 index ca65756..0000000 --- a/scripts/netbeans.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -x - -set -o errexit -set -o nounset -set -o pipefail - -# The intention of this block is to recursively call this script without root -# permissions if invoked with sudo. If invoked as root without sudo, bail out. -if [ ${EUID} -eq 0 ]; then - # Running with root perms. Because of sudo? - if [ -z "${SUDO_USER:-}" ]; then - # script executed without sudo - echo "This script is not meant to run as root" >&2 - exit 1 - else - # script executed with sudo. recurse as the user that invoked this script - # so long as that user was not root. - SUDO_UID="$(id -u "${SUDO_USER}")" - if [ ${SUDO_UID} -eq 0 ]; then - echo "This script is not meant to run as root" >&2 - exit 1 - else - sudo -u "${SUDO_USER}" -i "${0}" ${@} - exit 0 - fi - fi -fi - -cd "${HOME}" - -NETBEANS_URL="http://download.netbeans.org/netbeans/8.2/final/bundles/netbeans-8.2-javase-linux.sh" -NETBEANS_FILENAME="$(basename "${NETBEANS_URL}")" -NETBEANS_MD5="dfa4af8f4a1fe88e3f8dea6b646882a7" - -#curl -f -L "${NETBEANS_URL}" > "${NETBEANS_FILENAME}" -[ -f "${NETBEANS_FILENAME}" ] -#echo "${NETBEANS_MD5} ${NETBEANS_FILENAME}" | md5sum -c -which java &>/dev/null -sh netbeans-8.2-javase-linux.sh --silent -[ -f "${HOME}/netbeans-8.2/etc/netbeans.conf" ] -sed -i 's|^netbeans_jdkhome=.*|netbeans_jdkhome="/usr/java/latest"|' "${HOME}/netbeans-8.2/etc/netbeans.conf" diff --git a/scripts/nix-chromium.sh b/scripts/nix-chromium.sh index 7cb6d37..1edf7b9 100644 --- a/scripts/nix-chromium.sh +++ b/scripts/nix-chromium.sh @@ -4,34 +4,10 @@ set -o errexit set -o nounset set -o pipefail -# The intention of this block is to recursively call this script without root -# permissions if invoked with sudo. If invoked as root without sudo, bail out. -if [ ${EUID} -eq 0 ]; then - # Running with root perms. Because of sudo? - if [ -z "${SUDO_USER:-}" ]; then - # script executed without sudo - echo "This script is not meant to run as root" >&2 - exit 1 - else - # script executed with sudo. recurse as the user that invoked this script - # so long as that user was not root. - SUDO_UID="$(id -u "${SUDO_USER}")" - if [ ${SUDO_UID} -eq 0 ]; then - echo "This script is not meant to run as root" >&2 - exit 1 - else - sudo -u "${SUDO_USER}" -i "${0}" ${@} - exit 0 - fi - fi -fi -which nix-env &> /dev/null +#which nix-env &> /dev/null nix-env -i chromium -# ${HOME}/.local/share/applications gets created on first graphical login. This -# doesn't happen during the build process so we have to create the directory. umask 0022 mkdir -p ${HOME}/.local/share/applications DESKTOP_SHORTCUT="$(nix-env -q chromium --out-path | awk '{print $2}')/share/applications/chromium.desktop" -#[ -f "${DESKTOP_SHORTCUT}" ] && cp "${DESKTOP_SHORTCUT}" ${HOME}/.local/share/applications/ diff --git a/scripts/nix.sh b/scripts/nix.sh deleted file mode 100644 index 71732e0..0000000 --- a/scripts/nix.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -x - -set -o errexit -set -o nounset -set -o pipefail - -# The intention of this block is to recursively call this script without root -# permissions if invoked with sudo. If invoked as root without sudo, bail out. -if [ ${EUID} -eq 0 ]; then - # Running with root perms. Because of sudo? - if [ -z "${SUDO_USER:-}" ]; then - # script executed without sudo - echo "This script is not meant to run as root" >&2 - exit 1 - else - # script executed with sudo. recurse as the user that invoked this script - # so long as that user was not root. - SUDO_UID="$(id -u "${SUDO_USER}")" - if [ ${SUDO_UID} -eq 0 ]; then - echo "This script is not meant to run as root" >&2 - exit 1 - else - sudo -u "${SUDO_USER}" -i "${0}" ${@} - exit 0 - fi - fi -fi - -cd "${HOME}" -[ -w . ] - -curl https://nixos.org/nix/install > nix_installer -# nixos.org can get hella slow, use a cached copy -sed -i 's/^curl -L "$url" | bzcat/bzcat nix-2.0.2-x86_64-linux.tar.bz2/' nix_installer -sh nix_installer -rm -f nix_installer diff --git a/scripts/runovftool.sh b/scripts/runovftool.sh new file mode 100755 index 0000000..cf2abd7 --- /dev/null +++ b/scripts/runovftool.sh @@ -0,0 +1,76 @@ +#!/bin/bash -x + +declare -r VM_FILENAME="$1" + +if [ -d "/Applications/VMware Fusion.app/Contents/Library" ]; then + declare -r VMWARE_LIBDIR="/Applications/VMware Fusion.app/Contents/Library" +elif [ -d "/opt/homebrew-cask/Caskroom/vmware-fusion/8.1.0-3272237/VMware Fusion.app/Contents/Library/" ]; then + declare -r VMWARE_LIBDIR="/opt/homebrew-cask/Caskroom/vmware-fusion/8.1.0-3272237/VMware Fusion.app/Contents/Library/" +else + echo "Unable to find VMWare" >&2 + exit 1 +fi + +declare -r VMRUN="${VMWARE_LIBDIR}/vmrun" +declare -r OVFTOOL="${VMWARE_LIBDIR}/VMware OVF Tool/ovftool" + +declare -r VMWARE_VMDIR="${HOME}/Documents/VirtualMachines" +declare -r VM_DIR="${VMWARE_VMDIR}/${VM_FILENAME/%ova/vmwarevm}" +declare -r VMXFILE="${VM_DIR}/${VM_FILENAME/%ova/vmx}" + +function error() { + echo "[ERROR] ${@}" >&2 + exit 1 +} + +function info() { + echo "[INFO] ${@}" +} + +function verify_os() { + info "Verifying OS is Mac OS X" + [ "$(uname -s)" == "Darwin" ] || error "Only Mac OS X is supported" +} + +function verify_vmware() { + info "Verifying VMware Fusion 7 or 8 is properly installed" + [[ -d "${VMWARE_LIBDIR}" ]] || \ + error "VMware Fusion 7 or 8 must be installed" + [[ -x "${VMRUN}" ]] || \ + error "Cannot locate vmrun, check VMware Fusion installation" + [[ -x "${OVFTOOL}" ]] || \ + error "Cannot locate ovftool, check VMware Fusion installation" + mkdir -p "${VMWARE_VMDIR}" + [[ -d "${VMWARE_VMDIR}" ]] || \ + error "Unable to create directory for VMware VMs: ${VMWARE_VMDIR}" +} + + +function vmware_import() { + + [[ -f "$1" ]] || error "File $1 not found" + + info "Importing $1" + + mkdir -p "${VM_DIR}" + + [[ -f "${VMXFILE}" ]] && error "A VM appears to already exist at ${VM_DIR}. Delete or rename it if you want to continue." + + "${OVFTOOL}" --lax "$1" "${VMXFILE}" + perl -pi -e 's/^guestos =.*/guestos = "rhel6-64"/' "${VMXFILE}" + + # Configure Video, CPU, and time settings + cat >> "${VMXFILE}" << EOF +virtualHW.productCompatibility = "hosted" +mks.enable3d = "TRUE" +svga.graphicsMemoryKB = "786432" +vhv.enable = "TRUE" +vpmc.enable = "TRUE" +tools.syncTime = "TRUE" +svga.minVRAMSize = "67108864" +EOF + # Start the VM + info "Starting the VM" + "${VMRUN}" -T fusion start "${VMXFILE}" +} +vmware_import $1 diff --git a/scripts/sleep-debug.sh b/scripts/sleep-debug.sh deleted file mode 100644 index 1262e29..0000000 --- a/scripts/sleep-debug.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -x - -env -echo -set -sleep 3600 diff --git a/scripts/unsudo.sh b/scripts/unsudo.sh deleted file mode 100644 index 133ca1a..0000000 --- a/scripts/unsudo.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash - -set -o errexit -set -o nounset -set -o pipefail - -# The intention of this block is to recursively call this script without root -# permissions if invoked with sudo. If invoked as root without sudo, bail out. -if [ ${EUID} -eq 0 ]; then - # Running with root perms. Because of sudo? - if [ -z "${SUDO_USER:-}" ]; then - # script executed without sudo - echo "This script is not meant to run as root" >&2 - exit 1 - else - # script executed with sudo. recurse as the user that invoked this script - # so long as that user was not root. - SUDO_UID="$(id -u "${SUDO_USER}")" - if [ ${SUDO_UID} -eq 0 ]; then - echo "This script is not meant to run as root" >&2 - exit 1 - else - sudo -u "${SUDO_USER}" -i "${0}" ${@} - exit 0 - fi - fi -fi - -echo "Do something" From 595e42eea92256cf21eb7c67da79a8bf7af29937 Mon Sep 17 00:00:00 2001 From: Ankur Agarwal Date: Wed, 5 Sep 2018 15:45:37 -0700 Subject: [PATCH 2/6] Create a patch file for install-nix-2.0.4 --- c6x64/gui-dev-java.json | 4 ++++ scripts/install-nix-2.0.4 | 23 +++++++++++++++-------- scripts/nixpatch | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 8 deletions(-) create mode 100644 scripts/nixpatch diff --git a/c6x64/gui-dev-java.json b/c6x64/gui-dev-java.json index b62075d..d467685 100644 --- a/c6x64/gui-dev-java.json +++ b/c6x64/gui-dev-java.json @@ -27,6 +27,10 @@ "source": "cache/netbeans-8.2-linux.sh", "destination": "netbeans-8.2-linux.sh" }, + { + "type": "shell-local", + "command": "patch scripts/install-nix-2.0.4 < scripts/nixpatch" + }, { "type": "shell", "environment_vars": [ "NEWUSERLOGIN={{ user `NEWUSERLOGIN` }}" ], diff --git a/scripts/install-nix-2.0.4 b/scripts/install-nix-2.0.4 index 8c2d64b..7adea1c 100644 --- a/scripts/install-nix-2.0.4 +++ b/scripts/install-nix-2.0.4 @@ -23,16 +23,23 @@ require_util() { } case "$(uname -s).$(uname -m)" in - Linux.x86_64) system=x86_64-linux; hash=d6db178007014ed47ad5460c1bd5b2cb9403b1ec543a0d6507cb27e15358341f;; - Linux.i?86) system=i686-linux; hash=b2e5b62a66c6d1951fdd5e01109680592b498ef40f28bfc790341f5b986ba34d;; - Linux.aarch64) system=aarch64-linux; hash=248be69c25f599ac214bad1e4f4003e27f1da83cb17f7cd762746bd2c215a0df;; - Darwin.x86_64) system=x86_64-darwin; hash=ec6279bb6d628867d82a6e751dac2bcb64ccea3194d753756a309f75fd704d4c;; + Linux.x86_64) system=x86_64-linux; hash=ad10b4da69035a585fe89d7330037c4a5d867a372bb0e52a1542ab95aec67999;; + Linux.i?86) system=i686-linux; hash=14b3b0c34971fb29f279164de83cae323ad443eb62529c368be38d5376bcb306;; + Linux.aarch64) system=aarch64-linux; hash=96c37fcb852d1bea19df29d49268d2b2878a73fef8f61801eec1434b7adc8d5a;; + Darwin.x86_64) system=x86_64-darwin; hash=938b2ab25fa344491eae51d8db7712028cc393b36a12250af7c5e87849631e0d;; *) oops "sorry, there is no binary distribution of Nix for your platform";; esac -tarball="/home/$NEWUSERLOGIN/nix-2.0.4-$system.tar.bz2" +url="https://nixos.org/releases/nix/nix-2.1.1/nix-2.1.1-$system.tar.bz2" -echo "copying Nix 2.0.4 binary tarball for $system from $tarball to $tmpDir ..." +tarball="$tmpDir/$(basename "$tmpDir/nix-2.1.1-$system.tar.bz2")" + +require_util curl "download the binary tarball" +require_util bzcat "decompress the binary tarball" +require_util tar "unpack the binary tarball" + +echo "downloading Nix 2.1.1 binary tarball for $system from '$url' to '$tmpDir'..." +curl -L "$url" -o "$tarball" || oops "failed to download '$url'" if type sha256sum > /dev/null 2>&1; then hash2="$(sha256sum -b "$tarball" | cut -c1-64)" @@ -41,7 +48,7 @@ elif type shasum > /dev/null 2>&1; then elif type openssl > /dev/null 2>&1; then hash2="$(openssl dgst -r -sha256 "$tarball" | cut -c1-64)" else - oops "cannot verify the SHA-256 hash of $tarball; you need one of 'shasum', 'sha256sum', or 'openssl'" + oops "cannot verify the SHA-256 hash of '$url'; you need one of 'shasum', 'sha256sum', or 'openssl'" fi if [ "$hash" != "$hash2" ]; then @@ -50,7 +57,7 @@ fi unpack=$tmpDir/unpack mkdir -p "$unpack" -< "$tarball" bzcat | tar -xf - -C "$unpack" || oops "failed to unpack $tarball" +< "$tarball" bzcat | tar -xf - -C "$unpack" || oops "failed to unpack '$url'" script=$(echo "$unpack"/*/install) diff --git a/scripts/nixpatch b/scripts/nixpatch new file mode 100644 index 0000000..b4d43ab --- /dev/null +++ b/scripts/nixpatch @@ -0,0 +1,33 @@ +26,29c26,29 +< Linux.x86_64) system=x86_64-linux; hash=ad10b4da69035a585fe89d7330037c4a5d867a372bb0e52a1542ab95aec67999;; +< Linux.i?86) system=i686-linux; hash=14b3b0c34971fb29f279164de83cae323ad443eb62529c368be38d5376bcb306;; +< Linux.aarch64) system=aarch64-linux; hash=96c37fcb852d1bea19df29d49268d2b2878a73fef8f61801eec1434b7adc8d5a;; +< Darwin.x86_64) system=x86_64-darwin; hash=938b2ab25fa344491eae51d8db7712028cc393b36a12250af7c5e87849631e0d;; +--- +> Linux.x86_64) system=x86_64-linux; hash=d6db178007014ed47ad5460c1bd5b2cb9403b1ec543a0d6507cb27e15358341f;; +> Linux.i?86) system=i686-linux; hash=b2e5b62a66c6d1951fdd5e01109680592b498ef40f28bfc790341f5b986ba34d;; +> Linux.aarch64) system=aarch64-linux; hash=248be69c25f599ac214bad1e4f4003e27f1da83cb17f7cd762746bd2c215a0df;; +> Darwin.x86_64) system=x86_64-darwin; hash=ec6279bb6d628867d82a6e751dac2bcb64ccea3194d753756a309f75fd704d4c;; +33c33 +< url="https://nixos.org/releases/nix/nix-2.1.1/nix-2.1.1-$system.tar.bz2" +--- +> tarball="/home/$NEWUSERLOGIN/nix-2.0.4-$system.tar.bz2" +35,42c35 +< tarball="$tmpDir/$(basename "$tmpDir/nix-2.1.1-$system.tar.bz2")" +< +< require_util curl "download the binary tarball" +< require_util bzcat "decompress the binary tarball" +< require_util tar "unpack the binary tarball" +< +< echo "downloading Nix 2.1.1 binary tarball for $system from '$url' to '$tmpDir'..." +< curl -L "$url" -o "$tarball" || oops "failed to download '$url'" +--- +> echo "copying Nix 2.0.4 binary tarball for $system from $tarball to $tmpDir ..." +51c44 +< oops "cannot verify the SHA-256 hash of '$url'; you need one of 'shasum', 'sha256sum', or 'openssl'" +--- +> oops "cannot verify the SHA-256 hash of $tarball; you need one of 'shasum', 'sha256sum', or 'openssl'" +60c53 +< < "$tarball" bzcat | tar -xf - -C "$unpack" || oops "failed to unpack '$url'" +--- +> < "$tarball" bzcat | tar -xf - -C "$unpack" || oops "failed to unpack $tarball" From 4dc7d275e71052a687f5accf84ca495a9f6a3edf Mon Sep 17 00:00:00 2001 From: Ankur Agarwal Date: Thu, 6 Sep 2018 12:04:20 -0700 Subject: [PATCH 3/6] Separate out VM customization 1. Add AWS, Azure key set up and vagrant user renaming as the last step 2. Add a shell-local provisioner to revert the patch applied to install-nix-2.0.4 script --- c6x64/gui-dev-java.json | 28 ++++++------- c6x64/gui.json | 9 ++--- c6x64/kernel-ml-epel.json | 8 +--- c6x64/minimal.json | 10 +---- c6x64/renametonewuser.json | 40 +++++++++++++++++++ c6x64/setupuser.json | 44 +++++++++++++++++++++ build.sh => generic_build.sh | 3 ++ scripts/install_intellij.sh | 8 ++-- scripts/install_jdk.sh | 2 +- scripts/install_netbeans.sh | 10 ++--- scripts/install_vmtools.sh | 4 +- scripts/nix-chromium.sh | 13 ------ scripts/nixpatch | 2 +- scripts/rename_user.sh | 32 +++++++++++++++ scripts/{createuser.sh => setup_newuser.sh} | 31 ++++----------- user_build.sh | 6 +++ 16 files changed, 162 insertions(+), 88 deletions(-) create mode 100644 c6x64/renametonewuser.json create mode 100644 c6x64/setupuser.json rename build.sh => generic_build.sh (99%) delete mode 100644 scripts/nix-chromium.sh create mode 100644 scripts/rename_user.sh rename scripts/{createuser.sh => setup_newuser.sh} (53%) create mode 100755 user_build.sh diff --git a/c6x64/gui-dev-java.json b/c6x64/gui-dev-java.json index d467685..3b1cbe9 100644 --- a/c6x64/gui-dev-java.json +++ b/c6x64/gui-dev-java.json @@ -33,15 +33,18 @@ }, { "type": "shell", - "environment_vars": [ "NEWUSERLOGIN={{ user `NEWUSERLOGIN` }}" ], "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}", "scripts": [ "scripts/install-nix-2.0.4" ] }, +{ + "type": "shell-local", + "command": "patch -R scripts/install-nix-2.0.4 < scripts/nixpatch" +}, { "type": "shell", - "environment_vars": [ "NEWUSERLOGIN={{ user `NEWUSERLOGIN` }}", "JDK_FILENAME={{user `JDK_FILENAME`}}" ], + "environment_vars": [ "JDK_FILENAME={{user `JDK_FILENAME`}}" ], "execute_command": "chmod +x {{ .Path }}; sudo {{ .Vars }} {{ .Path }}", "scripts": [ "scripts/install_jdk.sh" @@ -49,7 +52,6 @@ }, { "type": "shell", - "environment_vars": [ "NEWUSERLOGIN={{ user `NEWUSERLOGIN` }}" ], "execute_command": "chmod +x {{ .Path }}; sudo {{ .Vars }} {{ .Path }}", "scripts": [ "scripts/install_vmtools.sh" @@ -57,7 +59,7 @@ }, { "type": "shell", - "environment_vars": [ "NEWUSERLOGIN={{ user `NEWUSERLOGIN` }}", "INTELLIJ_FILENAME={{ user `INTELLIJ_FILENAME` }}" ], + "environment_vars": [ "INTELLIJ_FILENAME={{ user `INTELLIJ_FILENAME` }}" ], "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}", "scripts": [ "scripts/install_intellij.sh" @@ -65,7 +67,7 @@ }, { "type": "shell", - "environment_vars": [ "NEWUSERLOGIN={{ user `NEWUSERLOGIN` }}", "NETBEANS_FILENAME={{ user `NETBEANS_FILENAME` }}" ], + "environment_vars": [ "NETBEANS_FILENAME={{ user `NETBEANS_FILENAME` }}" ], "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}", "scripts": [ "scripts/install_netbeans.sh" @@ -77,31 +79,23 @@ "type": "virtualbox-ovf", "source_path": "c6x64-gui.ova", "output_directory": "build/out", - "vm_name": "c6x64-final", + "vm_name": "c6x64-gui-dev-java", "boot_wait": "5s", "format": "ova", "guest_additions_mode": "disable", "http_directory": "http", - "ssh_username": "{{ user `NEWUSERLOGIN` }}", + "ssh_username": "vagrant", "ssh_password": "vagrant", "ssh_port": 22, "ssh_wait_timeout": "10000s", - "shutdown_command": "echo 'rm -f /etc/ssh/ssh_host*; rm -f /tmp/shutdown.sh; /sbin/halt -h -p' > /tmp/shutdown.sh; sudo sh /tmp/shutdown.sh", - "vboxmanage": [ - ["modifyvm", "{{.Name}}", "--memory","8192"], - ["modifyvm", "{{.Name}}", "--cpus", "3"] - ] + "shutdown_command": "echo 'rm -f /etc/ssh/ssh_host*; rm -f /tmp/shutdown.sh; /sbin/halt -h -p' > /tmp/shutdown.sh; sudo sh /tmp/shutdown.sh" } ], "post-processors": [ { "type": "shell-local", - "command": "mv build/out/c6x64-final.ova . ; rm -rf build/*" - }, - { - "type": "shell-local", - "command": "scripts/runovftool.sh c6x64-final.ova" + "command": "mv build/out/c6x64-gui-dev-java.ova . ; rm -rf build/*" } ] diff --git a/c6x64/gui.json b/c6x64/gui.json index af0f4c9..f7d6a3c 100644 --- a/c6x64/gui.json +++ b/c6x64/gui.json @@ -19,15 +19,12 @@ "format": "ova", "guest_additions_mode": "disable", "http_directory": "http", - "ssh_username": "{{ user `NEWUSERLOGIN` }}", + "ssh_username": "vagrant", "ssh_password": "vagrant", "ssh_port": 22, "ssh_wait_timeout": "10000s", - "shutdown_command": "echo 'rm -f /etc/ssh/ssh_host*; rm -f /tmp/shutdown.sh; /sbin/halt -h -p' > /tmp/shutdown.sh; sudo sh /tmp/shutdown.sh", - "vboxmanage": [ - ["modifyvm", "{{.Name}}", "--memory","8192"], - ["modifyvm", "{{.Name}}", "--cpus", "3"] - ] + "shutdown_command": "echo 'rm -f /etc/ssh/ssh_host*; rm -f /tmp/shutdown.sh; /sbin/halt -h -p' > /tmp/shutdown.sh; sudo sh /tmp/shutdown.sh" + } ], diff --git a/c6x64/kernel-ml-epel.json b/c6x64/kernel-ml-epel.json index 739cc33..784c66f 100644 --- a/c6x64/kernel-ml-epel.json +++ b/c6x64/kernel-ml-epel.json @@ -22,16 +22,12 @@ "format": "ova", "guest_additions_mode": "disable", "http_directory": "http", - "ssh_username": "{{ user `NEWUSERLOGIN` }}", + "ssh_username": "vagrant", "ssh_password": "vagrant", "ssh_port": 22, "ssh_wait_timeout": "10000s", "shutdown_command": "echo 'rm -f /etc/ssh/ssh_host*; rm -f /tmp/shutdown.sh; /sbin/halt -h -p' > /tmp/shutdown.sh; sudo sh /tmp/shutdown.sh", - "post_shutdown_delay" : "2m", - "vboxmanage": [ - ["modifyvm", "{{.Name}}", "--memory","8192"], - ["modifyvm", "{{.Name}}", "--cpus", "3"] - ] + "post_shutdown_delay" : "2m" } ], "post-processors": [{ diff --git a/c6x64/minimal.json b/c6x64/minimal.json index 895fa68..444f0a2 100644 --- a/c6x64/minimal.json +++ b/c6x64/minimal.json @@ -2,16 +2,8 @@ "provisioners": [ { "type": "shell", - "environment_vars": ["NEWUSERLOGIN={{ user `NEWUSERLOGIN` }}", - "NEWUSERFULLNAME={{ user `NEWUSERFULLNAME` }}", - "AWS_ACCESS_KEY_ID={{ user `AWS_ACCESS_KEY_ID`}}", - "AWS_SECRET_ACCESS_KEY={{user `AWS_SECRET_ACCESS_KEY`}}", - "AZURE_SECRET={{user `AZURE_SECRET`}}", - "SVN_SERVER_URL={{user `SVN_SERVER_URL`}}" - ], "execute_command": "chmod +x {{ .Path }}; sudo {{ .Vars }} {{ .Path }}", "scripts": [ - "scripts/createuser.sh", "scripts/install_svn.sh", "scripts/install_git.sh", "scripts/cleanup.sh" @@ -28,7 +20,7 @@ " text selinux=0 ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/centos6.ks" ], "boot_wait": "5s", - "disk_size": 51200, + "disk_size": 307200, "format": "ova", "guest_additions_mode": "disable", "guest_os_type": "RedHat_64", diff --git a/c6x64/renametonewuser.json b/c6x64/renametonewuser.json new file mode 100644 index 0000000..99e66c6 --- /dev/null +++ b/c6x64/renametonewuser.json @@ -0,0 +1,40 @@ +{ + "provisioners": [ + { + "type": "shell", + "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}", + "environment_vars": ["NEWUSERLOGIN={{ user `NEWUSERLOGIN` }}", + "NEWUSERFULLNAME={{ user `NEWUSERFULLNAME` }}", + "INTELLIJ_FILENAME={{ user `INTELLIJ_FILENAME` }}" + ], + "scripts": [ + "scripts/rename_user.sh" + ] + } + ], + "builders": [ + { + "type": "virtualbox-ovf", + "source_path": "c6x64-gui-dev-java.ova", + "output_directory": "build/out", + "vm_name": "c6x64-renameduser", + "boot_wait": "5s", + "format": "ova", + "guest_additions_mode": "disable", + "http_directory": "http", + "ssh_username": "root", + "ssh_password": "vagrant", + "ssh_port": 22, + "ssh_wait_timeout": "10000s", + "shutdown_command": "echo 'rm -f /etc/ssh/ssh_host*; rm -f /tmp/shutdown.sh; /sbin/halt -h -p' > /tmp/shutdown.sh; sudo sh /tmp/shutdown.sh" + + } +], + +"post-processors": [ + { + "type": "shell-local", + "command": "mv build/out/c6x64-renameduser.ova . ; rm -rf build/*" + } +] +} diff --git a/c6x64/setupuser.json b/c6x64/setupuser.json new file mode 100644 index 0000000..fd4e1a5 --- /dev/null +++ b/c6x64/setupuser.json @@ -0,0 +1,44 @@ +{ + "provisioners": [ + { + "type": "shell", + "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}", + "environment_vars": [ + "NEWUSERLOGIN={{ user `NEWUSERLOGIN` }}", + "NEWUSERFULLNAME={{ user `NEWUSERFULLNAME` }}", + "AWS_ACCESS_KEY_ID={{ user `AWS_ACCESS_KEY_ID` }}", + "AWS_SECRET_ACCESS_KEY={{user `AWS_SECRET_ACCESS_KEY` }}", + "AZURE_SECRET={{user `AZURE_SECRET` }}", + "SVN_SERVER_URL={{user `SVN_SERVER_URL` }}" + ], + "scripts": [ + "scripts/setup_newuser.sh" + ] + } + ], + "builders": [ + { + "type": "virtualbox-ovf", + "source_path": "c6x64-renameduser.ova", + "output_directory": "build/out", + "vm_name": "c6x64-newuser-final", + "boot_wait": "5s", + "format": "ova", + "guest_additions_mode": "disable", + "http_directory": "http", + "ssh_username": "{{ user `NEWUSERLOGIN` }}", + "ssh_password": "vagrant", + "ssh_port": 22, + "ssh_wait_timeout": "10000s", + "shutdown_command": "echo 'rm -f /etc/ssh/ssh_host*; rm -f /tmp/shutdown.sh; /sbin/halt -h -p' > /tmp/shutdown.sh; sudo sh /tmp/shutdown.sh" + + } +], + +"post-processors": [ + { + "type": "shell-local", + "command": "mv build/out/c6x64-newuser-final.ova . ; rm -rf build/*" + } +] +} diff --git a/build.sh b/generic_build.sh similarity index 99% rename from build.sh rename to generic_build.sh index ebbae37..f524349 100755 --- a/build.sh +++ b/generic_build.sh @@ -1,9 +1,12 @@ #!/bin/bash -x time PACKER_LOG=1 packer build -on-error=ask -var-file=c6x64/newuser.json c6x64/minimal.json + sleep 5 time PACKER_LOG=1 packer build -on-error=ask -var-file=c6x64/newuser.json c6x64/kernel-ml-epel.json + sleep 5 time PACKER_LOG=1 packer build -on-error=ask -var-file=c6x64/newuser.json c6x64/gui.json + sleep 5 time PACKER_LOG=1 packer build -on-error=ask -var-file=c6x64/newuser.json c6x64/gui-dev-java.json diff --git a/scripts/install_intellij.sh b/scripts/install_intellij.sh index 7945bb3..718cfe3 100644 --- a/scripts/install_intellij.sh +++ b/scripts/install_intellij.sh @@ -4,13 +4,13 @@ set -o errexit set -o nounset set -o pipefail -[ -f "/home/${NEWUSERLOGIN}/${INTELLIJ_FILENAME}" ] +[ -f "/home/vagrant/${INTELLIJ_FILENAME}" ] EXTRACTDIR="$(dirname $(tar -ztf "${INTELLIJ_FILENAME}" | head -n1))" -tar -zxf "/home/${NEWUSERLOGIN}/${INTELLIJ_FILENAME}" +tar -zxf "/home/vagrant/${INTELLIJ_FILENAME}" -[ -f "/home/${NEWUSERLOGIN}/${EXTRACTDIR}/bin/idea.sh" ] +[ -f "/home/vagrant/${EXTRACTDIR}/bin/idea.sh" ] # Desktop is not created until after graphical login -ln -s "/home/${NEWUSERLOGIN}/${EXTRACTDIR}/bin/idea.sh" "/home/${NEWUSERLOGIN}/IntelliJ_launcher" +ln -s "/home/vagrant/${EXTRACTDIR}/bin/idea.sh" "/home/vagrant/IntelliJ_launcher" diff --git a/scripts/install_jdk.sh b/scripts/install_jdk.sh index ccf7877..16f6fd0 100644 --- a/scripts/install_jdk.sh +++ b/scripts/install_jdk.sh @@ -4,6 +4,6 @@ set -o errexit set -o nounset set -o pipefail -rpm -qp "/home/${NEWUSERLOGIN}/${JDK_FILENAME}" -K +rpm -qp "/home/vagrant/${JDK_FILENAME}" -K sudo yum -y remove 'java-*-openj*' || /bin/true sudo yum -y install "${JDK_FILENAME}" diff --git a/scripts/install_netbeans.sh b/scripts/install_netbeans.sh index 60102c0..df6a64b 100644 --- a/scripts/install_netbeans.sh +++ b/scripts/install_netbeans.sh @@ -6,13 +6,13 @@ set -o pipefail -[ -f "/home/${NEWUSERLOGIN}/${NETBEANS_FILENAME}" ] +[ -f "/home/vagrant/${NETBEANS_FILENAME}" ] -/home/${NEWUSERLOGIN}/${NETBEANS_FILENAME} --silent +/home/vagrant/${NETBEANS_FILENAME} --silent -[ -f "/home/${NEWUSERLOGIN}/netbeans-8.2/etc/netbeans.conf" ] +[ -f "/home/vagrant/netbeans-8.2/etc/netbeans.conf" ] -sed -i 's|^netbeans_jdkhome=.*|netbeans_jdkhome="/usr/java/latest"|' "/home/${NEWUSERLOGIN}/netbeans-8.2/etc/netbeans.conf" +sed -i 's|^netbeans_jdkhome=.*|netbeans_jdkhome="/usr/java/latest"|' "/home/vagrant/netbeans-8.2/etc/netbeans.conf" # Desktop is not created until after graphical login -ln -s "/home/${NEWUSERLOGIN}/netbeans-8.2/bin/netbeans" "/home/${NEWUSERLOGIN}/netbeans8.2_launcher" +ln -s "/home/vagrant/netbeans-8.2/bin/netbeans" "/home/vagrant/netbeans8.2_launcher" diff --git a/scripts/install_vmtools.sh b/scripts/install_vmtools.sh index bf46367..c35b7d3 100644 --- a/scripts/install_vmtools.sh +++ b/scripts/install_vmtools.sh @@ -4,8 +4,8 @@ set -o errexit set -o nounset set -o pipefail -tar -xzvf /home/$NEWUSERLOGIN/VMwareTools-10.0.6-3595377.tar.gz +tar -xzvf /home/vagrant/VMwareTools-10.0.6-3595377.tar.gz sync sleep 5 sync -/home/$NEWUSERLOGIN/vmware-tools-distrib/vmware-install.pl -d +/home/vagrant/vmware-tools-distrib/vmware-install.pl -d diff --git a/scripts/nix-chromium.sh b/scripts/nix-chromium.sh deleted file mode 100644 index 1edf7b9..0000000 --- a/scripts/nix-chromium.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -x - -set -o errexit -set -o nounset -set -o pipefail - - -#which nix-env &> /dev/null -nix-env -i chromium - -umask 0022 -mkdir -p ${HOME}/.local/share/applications -DESKTOP_SHORTCUT="$(nix-env -q chromium --out-path | awk '{print $2}')/share/applications/chromium.desktop" diff --git a/scripts/nixpatch b/scripts/nixpatch index b4d43ab..aebccc2 100644 --- a/scripts/nixpatch +++ b/scripts/nixpatch @@ -11,7 +11,7 @@ 33c33 < url="https://nixos.org/releases/nix/nix-2.1.1/nix-2.1.1-$system.tar.bz2" --- -> tarball="/home/$NEWUSERLOGIN/nix-2.0.4-$system.tar.bz2" +> tarball="/home/vagrant/nix-2.0.4-$system.tar.bz2" 35,42c35 < tarball="$tmpDir/$(basename "$tmpDir/nix-2.1.1-$system.tar.bz2")" < diff --git a/scripts/rename_user.sh b/scripts/rename_user.sh new file mode 100644 index 0000000..40fb7a3 --- /dev/null +++ b/scripts/rename_user.sh @@ -0,0 +1,32 @@ +echo "Running: groupadd $NEWUSERLOGIN" +groupadd "$NEWUSERLOGIN" +echo "Done.." + +sleep 2 + +echo "Running: usermod -d /home/$NEWUSERLOGIN -m -l $NEWUSERLOGIN -g $NEWUSERLOGIN -c $NEWUSERFULLNAME vagrant" +usermod -d /home/"$NEWUSERLOGIN" -m -l "$NEWUSERLOGIN" -g "$NEWUSERLOGIN" -c "$NEWUSERFULLNAME" vagrant +echo "Done.." + +sleep 3 + +echo "Setting up passwordless sudo for $NEWUSERLOGIN" +echo "$NEWUSERLOGIN ALL=(ALL) NOPASSWD: ALL" | tee "/etc/sudoers.d/$NEWUSERLOGIN" &>/dev/null +echo "Done.." + +sleep 3 + +# fix symlink for IntelliJ +echo "Fixing Intellij launcher symlink" +EXTRACTDIR="$(dirname $(tar -ztf "/home/${NEWUSERLOGIN}/${INTELLIJ_FILENAME}" | head -n1))" +ln -sf "/home/${NEWUSERLOGIN}/${EXTRACTDIR}/bin/idea.sh" "/home/${NEWUSERLOGIN}/IntelliJ_launcher" +echo "Done" + +sleep 3 + +# fix symlink for netbeans +echo "Fixing Netbeans launcher symlink" +ln -sf "/home/${NEWUSERLOGIN}/netbeans-8.2/bin/netbeans" "/home/${NEWUSERLOGIN}/netbeans8.2_launcher" +echo "Done" + +echo "Renamed vagrant to $NEWUSERLOGIN" diff --git a/scripts/createuser.sh b/scripts/setup_newuser.sh similarity index 53% rename from scripts/createuser.sh rename to scripts/setup_newuser.sh index f60b807..a945fc1 100644 --- a/scripts/createuser.sh +++ b/scripts/setup_newuser.sh @@ -1,21 +1,5 @@ #!/bin/bash -x -echo "Running: useradd -m -d /home/$NEWUSERLOGIN -c $NEWUSERFULLNAME -s /bin/bash -r -U $NEWUSERLOGIN" -useradd -m -d /home/$NEWUSERLOGIN -c "$NEWUSERFULLNAME" -s /bin/bash -U $NEWUSERLOGIN -echo "Done.." - -echo "Running: usermod -g $NEWUSERLOGIN $NEWUSERLOGIN" -usermod -g $NEWUSERLOGIN $NEWUSERLOGIN -echo "Done.." - -echo "Setting up passwordless sudo for $NEWUSERLOGIN" -echo "$NEWUSERLOGIN ALL=(ALL) NOPASSWD: ALL" | sudo tee "/etc/sudoers.d/$NEWUSERLOGIN" &>/dev/null -echo "Done.." - -echo "Setting password for $NEWUSERLOGIN" -echo "$NEWUSERLOGIN:vagrant" | chpasswd -echo "Done.." - echo "Doing echo $AWS_ACCESS_KEY_ID > /home/$NEWUSERLOGIN/.awssecret" echo $AWS_ACCESS_KEY_ID > /home/$NEWUSERLOGIN/.awssecret echo "Done.." @@ -32,25 +16,24 @@ echo "Doing chmod 600 /home/$NEWUSERLOGIN/.azuresecret" chmod 600 /home/$NEWUSERLOGIN/.azuresecret echo "Done.." -echo "Doing chown $NEWUSERLOGIN:$NEWUSERLOGIN /home/$NEWUSERLOGIN/.azuresecret" -chown $NEWUSERLOGIN:$NEWUSERLOGIN /home/$NEWUSERLOGIN/.azuresecret -echo "Done.." - -echo "Doing chown $NEWUSERLOGIN:$NEWUSERLOGIN /home/$NEWUSERLOGIN/.awssecret" -chown $NEWUSERLOGIN:$NEWUSERLOGIN /home/$NEWUSERLOGIN/.awssecret +echo "Doing rm -rf /home/$NEWUSERLOGIN/.ssh/*" +rm -rf /home/$NEWUSERLOGIN/.ssh/* echo "Done.." echo "Creating ssh keys for $NEWUSERLOGIN" -su -l $NEWUSERLOGIN -c 'ssh-keygen -f ~/.ssh/id_rsa -N ""' +ssh-keygen -f /home/$NEWUSERLOGIN/.ssh/id_rsa -N "" echo "Done.." echo "Setting up ~/.ssh/config for $NEWUSERLOGIN" echo -e "\nHost $SVN_SERVER_URL svn1 svn\n User=$NEWUSERLOGIN" >> /home/$NEWUSERLOGIN/.ssh/config echo "Done.." +echo "Doing chmod 600 /home/$NEWUSERLOGIN/.ssh/config" +chmod 600 /home/$NEWUSERLOGIN/.ssh/config +echo "Done.." + echo "Set up Publickey based ssh login to self" cat /home/$NEWUSERLOGIN/.ssh/id_rsa.pub >> /home/$NEWUSERLOGIN/.ssh/authorized_keys echo "Done.." - echo "User \"$NEWUSERLOGIN\" with full name \"$NEWUSERFULLNAME\" created successfully" diff --git a/user_build.sh b/user_build.sh new file mode 100755 index 0000000..4784e4a --- /dev/null +++ b/user_build.sh @@ -0,0 +1,6 @@ +#!/bin/bash -x + +time PACKER_LOG=1 packer build -on-error=ask -var-file=c6x64/newuser.json c6x64/renametonewuser.json + +sleep 5 +time PACKER_LOG=1 packer build -on-error=ask -var-file=c6x64/newuser.json c6x64/setupuser.json From 05fe7f6b7320cf5d9b0c7ae81ab7d66f7c82ce60 Mon Sep 17 00:00:00 2001 From: Ankur Agarwal Date: Tue, 11 Sep 2018 11:39:29 -0700 Subject: [PATCH 4/6] File naming for source and destination files in null.json --- c6x64/null.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/c6x64/null.json b/c6x64/null.json index 9ce1c1d..828639f 100644 --- a/c6x64/null.json +++ b/c6x64/null.json @@ -17,8 +17,8 @@ }, { "type": "file", - "source": "cache/nix-2.0.2-x86_64-linuxaaaaaa.tar.bz2", - "destination": "nix-2.0.2-x86_64-linuxaaaaaa.tar.bz2" + "source": "cache/nix-2.0.2-x86_64-linux.tar.bz2", + "destination": "nix-2.0.2-x86_64-linux.tar.bz2" } ], From ebfea1f9efda6db6b4bc6a25062774b8e8c05657 Mon Sep 17 00:00:00 2001 From: Ankur Agarwal Date: Tue, 11 Sep 2018 20:50:41 -0700 Subject: [PATCH 5/6] Makefile changes and binary version upgrades Upgrade jdk, nix, IntelliJ version Use java only netbeans installer Parameterize file names in c6x64/gui-dev-java.json --- Makefile.cache | 23 ++++++------ RPM-GPG-KEY-oracle-ol6 | 19 ++++++++++ c6x64/gui-dev-java.json | 35 ++++++++++++------- c6x64/newuser.json | 11 +++--- generic_build.sh | 6 ++-- .../{install-nix-2.0.4 => install-nix-2.1.1} | 0 scripts/install_jdk.sh | 5 +++ scripts/nixpatch | 22 +++++------- user_build.sh | 2 ++ 9 files changed, 78 insertions(+), 45 deletions(-) create mode 100644 RPM-GPG-KEY-oracle-ol6 rename scripts/{install-nix-2.0.4 => install-nix-2.1.1} (100%) diff --git a/Makefile.cache b/Makefile.cache index b706214..e2b4e44 100644 --- a/Makefile.cache +++ b/Makefile.cache @@ -1,23 +1,24 @@ CURL=curl -L all: \ - cache/nix-2.0.2-x86_64-linux.tar.bz2 \ - cache/jdk-8u144-linux-x64.rpm \ + cache/nix-2.1.1-x86_64-linux.tar.bz2 \ + cache/jdk-8u172-linux-x64.rpm \ cache/netbeans-8.2-javase-linux.sh \ - cache/ideaIC-2018.1.3.tar.gz + cache/ideaIC-2018.2.2.tar.gz -cache/nix-2.0.2-x86_64-linux.tar.bz2: | cache - ${CURL} https://nixos.org/releases/nix/nix-2.0.2/nix-2.0.2-x86_64-linux.tar.bz2 > $@ +cache/nix-2.1.1-x86_64-linux.tar.bz2: | cache + ${CURL} 'https://nixos.org/releases/nix/nix-2.1.1/nix-2.1.1-x86_64-linux.tar.bz2' > $@ -cache/jdk-8u144-linux-x64.rpm: | cache - ${CURL} -H 'Cookie: oraclelicense=accept-securebackup-cookie' \ - http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.rpm > $@ + +cache/jdk-8u172-linux-x64.rpm: | cache + ${CURL} -H "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" \ + 'http://download.oracle.com/otn-pub/java/jdk/8u172-b11/a58eab1ec242421181065cdc37240b08/jdk-8u172-linux-x64.rpm' > $@ cache/netbeans-8.2-javase-linux.sh: | cache - ${CURL} http://download.netbeans.org/netbeans/8.2/final/bundles/netbeans-8.2-javase-linux.sh > $@ + ${CURL} 'http://download.netbeans.org/netbeans/8.2/final/bundles/netbeans-8.2-javase-linux.sh' > $@ -cache/ideaIC-2018.1.3.tar.gz: | cache - ${CURL} https://download.jetbrains.com/idea/ideaIC-2018.1.3.tar.gz > $@ +cache/ideaIC-2018.2.2.tar.gz: | cache + ${CURL} 'https://download.jetbrains.com/idea/ideaIC-2018.2.2.tar.gz' > $@ cache: mkdir cache diff --git a/RPM-GPG-KEY-oracle-ol6 b/RPM-GPG-KEY-oracle-ol6 new file mode 100644 index 0000000..0da1c10 --- /dev/null +++ b/RPM-GPG-KEY-oracle-ol6 @@ -0,0 +1,19 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: GnuPG v1.4.5 (GNU/Linux) + +mQENBEwtJWoBCACpiY2rGA6T0ceBi92X88/QclytVBjtDRohOVzs3pmIPh3ULqsW +G323nmyKbKQBBSjh9OnuO9Y09VG8mzr/w9YV0Ix4cI9/HDTERZ2+TR5u+VNn5J5h +yvwQSN/FEK6oH2+mz7O0yUNleN7UltR4MOEkHIoAhIvv+1AQQKN3OM8oalz+3gv/ +zz9rAoQczQzT7QWOtBrsRMZgBrKXY/TpJrpVSO3Hx8CnbhKGtLxCCrxZ5v7hh1ht +3CRAr2+h5bDA9KP6vBZWKEs7NgcvtZFDY6EJc7AoApr3phX9hHE2+snTxe82DkFT +uA69C8wLyjPCoSy+tcaCqJKOZelNy9RN/WKRABEBAAG0RE9yYWNsZSBPU1MgZ3Jv +dXAgKE9wZW4gU291cmNlIFNvZnR3YXJlIGdyb3VwKSA8YnVpbGRAb3NzLm9yYWNs +ZS5jb20+iQE8BBMBAgAmBQJMLSVqAhsDBQkWjmoABgsJCAcDAgQVAggDBBYCAwEC +HgECF4AACgkQcvl7dOxVHwMiNAf/cD8R74fCBeQsAYid5slIz7CG8xEOBUTDNEJT +p/owtzr7m7Ydp1txNBOkVeVkUP8czX5EldcmoxA4kCCyHhnxmpJnOt52Fy5ZRnYh +Ll5gYdpJpXGVScB7fnlh3rJAaesSTacVFC5MKIYPZBiTo9soSXMLNcG8WqHPasdd +AblC4t5BTDNYlX1RiPeP6m5egHnnxyAXsis8fqIZY0RC9hERxWQ6hdDAX0tJXY8F +88HDUozvo8jqTlg/5GZcfqcbUjjMUJQ5cBtH3adCthMycdPpPXWJQBuzMIdFJ03u +YuQ3XrKxBkOLips+OZuWNVZzrPOHsenb49aX4yQsLVc2E2fhKQ== +=M8XY +-----END PGP PUBLIC KEY BLOCK----- diff --git a/c6x64/gui-dev-java.json b/c6x64/gui-dev-java.json index 3b1cbe9..a9461c6 100644 --- a/c6x64/gui-dev-java.json +++ b/c6x64/gui-dev-java.json @@ -2,45 +2,54 @@ "provisioners": [ { "type": "file", - "source": "cache/nix-2.0.4-x86_64-linux.tar.bz2", - "destination": "nix-2.0.4-x86_64-linux.tar.bz2" + "source": "cache/{{user `NIX_FILENAME`}}", + "destination": "{{user `NIX_FILENAME`}}" }, { "type": "file", - "source": "cache/jdk-8u144-linux-x64.rpm", - "destination": "jdk-8u144-linux-x64.rpm" + "source": "RPM-GPG-KEY-oracle-ol6", + "destination": "RPM-GPG-KEY-oracle-ol6" + }, + { + "type": "file", + "source": "cache/{{user `JDK_FILENAME`}}", + "destination": "{{user `JDK_FILENAME`}}" }, { "type": "file", - "source": "cache/VMwareTools-10.0.6-3595377.tar.gz", - "destination": "VMwareTools-10.0.6-3595377.tar.gz" + "source": "cache/{{ user `VMWARE_TOOLS_FILENAME` }}", + "destination": "{{ user `VMWARE_TOOLS_FILENAME` }}" }, { "type": "file", - "source": "cache/ideaIC-2018.1.6.tar.gz", - "destination": "ideaIC-2018.1.6.tar.gz" + "source": "cache/{{ user `INTELLIJ_FILENAME` }}", + "destination": "{{ user `INTELLIJ_FILENAME` }}" + }, + { + "type": "shell-local", + "command": "chmod 777 cache/netbeans-8.2-javase-linux.sh" }, { "type": "file", - "source": "cache/netbeans-8.2-linux.sh", - "destination": "netbeans-8.2-linux.sh" + "source": "cache/{{ user `NETBEANS_FILENAME` }}", + "destination": "{{ user `NETBEANS_FILENAME` }}" }, { "type": "shell-local", - "command": "patch scripts/install-nix-2.0.4 < scripts/nixpatch" + "command": "patch scripts/install-nix-2.1.1 < scripts/nixpatch" }, { "type": "shell", "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}", "scripts": [ - "scripts/install-nix-2.0.4" + "scripts/install-nix-2.1.1" ] }, { "type": "shell-local", - "command": "patch -R scripts/install-nix-2.0.4 < scripts/nixpatch" + "command": "patch -R scripts/install-nix-2.1.1 < scripts/nixpatch" }, { "type": "shell", diff --git a/c6x64/newuser.json b/c6x64/newuser.json index 3de996c..9d875fb 100644 --- a/c6x64/newuser.json +++ b/c6x64/newuser.json @@ -4,8 +4,11 @@ "AWS_ACCESS_KEY_ID": "AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY": "AWS_SECRET_ACCESS_KEY", "AZURE_SECRET" : "AZURE_SECRET\\nAZURE_SECRET2\\nAZURE_SECRET3", - "SVN_SERVER_URL": "SVN_SERVER_URL", - "JDK_FILENAME": "jdk-8u144-linux-x64.rpm", - "INTELLIJ_FILENAME": "ideaIC-2018.1.6.tar.gz", - "NETBEANS_FILENAME": "netbeans-8.2-linux.sh" + "SVN_SERVER_URL": "svn.int.snowflakecomputing.com", + "JDK_FILENAME": "jdk-8u172-linux-x64.rpm", + "INTELLIJ_FILENAME": "ideaIC-2018.2.2.tar.gz", + "NETBEANS_FILENAME": "netbeans-8.2-javase-linux.sh", + "VMWARE_TOOLS_FILENAME": "VMwareTools-10.0.6-3595377.tar.gz", + "NIX_FILENAME": "nix-2.1.1-x86_64-linux.tar.bz2" + } diff --git a/generic_build.sh b/generic_build.sh index f524349..eb59175 100755 --- a/generic_build.sh +++ b/generic_build.sh @@ -1,12 +1,12 @@ #!/bin/bash -x time PACKER_LOG=1 packer build -on-error=ask -var-file=c6x64/newuser.json c6x64/minimal.json - +[ "$?" -ne "0" ] && exit 1 sleep 5 time PACKER_LOG=1 packer build -on-error=ask -var-file=c6x64/newuser.json c6x64/kernel-ml-epel.json - +[ "$?" -ne "0" ] && exit 1 sleep 5 time PACKER_LOG=1 packer build -on-error=ask -var-file=c6x64/newuser.json c6x64/gui.json - +[ "$?" -ne "0" ] && exit 1 sleep 5 time PACKER_LOG=1 packer build -on-error=ask -var-file=c6x64/newuser.json c6x64/gui-dev-java.json diff --git a/scripts/install-nix-2.0.4 b/scripts/install-nix-2.1.1 similarity index 100% rename from scripts/install-nix-2.0.4 rename to scripts/install-nix-2.1.1 diff --git a/scripts/install_jdk.sh b/scripts/install_jdk.sh index 16f6fd0..9140c1b 100644 --- a/scripts/install_jdk.sh +++ b/scripts/install_jdk.sh @@ -1,9 +1,14 @@ #!/bin/bash -x + set -o errexit set -o nounset set -o pipefail +# RPM GPG keys can be downloaded from http://yum.oracle.com/RPM-GPG-KEY-oracle-ol6 +# see https://yum.oracle.com/faq.html +[ -f /home/vagrant/RPM-GPG-KEY-oracle-ol6 ] +sudo rpm --import /home/vagrant/RPM-GPG-KEY-oracle-ol6 rpm -qp "/home/vagrant/${JDK_FILENAME}" -K sudo yum -y remove 'java-*-openj*' || /bin/true sudo yum -y install "${JDK_FILENAME}" diff --git a/scripts/nixpatch b/scripts/nixpatch index aebccc2..711616d 100644 --- a/scripts/nixpatch +++ b/scripts/nixpatch @@ -1,17 +1,7 @@ -26,29c26,29 -< Linux.x86_64) system=x86_64-linux; hash=ad10b4da69035a585fe89d7330037c4a5d867a372bb0e52a1542ab95aec67999;; -< Linux.i?86) system=i686-linux; hash=14b3b0c34971fb29f279164de83cae323ad443eb62529c368be38d5376bcb306;; -< Linux.aarch64) system=aarch64-linux; hash=96c37fcb852d1bea19df29d49268d2b2878a73fef8f61801eec1434b7adc8d5a;; -< Darwin.x86_64) system=x86_64-darwin; hash=938b2ab25fa344491eae51d8db7712028cc393b36a12250af7c5e87849631e0d;; ---- -> Linux.x86_64) system=x86_64-linux; hash=d6db178007014ed47ad5460c1bd5b2cb9403b1ec543a0d6507cb27e15358341f;; -> Linux.i?86) system=i686-linux; hash=b2e5b62a66c6d1951fdd5e01109680592b498ef40f28bfc790341f5b986ba34d;; -> Linux.aarch64) system=aarch64-linux; hash=248be69c25f599ac214bad1e4f4003e27f1da83cb17f7cd762746bd2c215a0df;; -> Darwin.x86_64) system=x86_64-darwin; hash=ec6279bb6d628867d82a6e751dac2bcb64ccea3194d753756a309f75fd704d4c;; 33c33 < url="https://nixos.org/releases/nix/nix-2.1.1/nix-2.1.1-$system.tar.bz2" --- -> tarball="/home/vagrant/nix-2.0.4-$system.tar.bz2" +> tarball="/home/vagrant/nix-2.1.1-$system.tar.bz2" 35,42c35 < tarball="$tmpDir/$(basename "$tmpDir/nix-2.1.1-$system.tar.bz2")" < @@ -22,12 +12,16 @@ < echo "downloading Nix 2.1.1 binary tarball for $system from '$url' to '$tmpDir'..." < curl -L "$url" -o "$tarball" || oops "failed to download '$url'" --- -> echo "copying Nix 2.0.4 binary tarball for $system from $tarball to $tmpDir ..." +> echo "copying Nix 2.1.1 binary tarball for $system from $tarball to $tmpDir ..." 51c44 < oops "cannot verify the SHA-256 hash of '$url'; you need one of 'shasum', 'sha256sum', or 'openssl'" --- -> oops "cannot verify the SHA-256 hash of $tarball; you need one of 'shasum', 'sha256sum', or 'openssl'" +> oops "cannot verify the SHA-256 hash of '$tarball'; you need one of 'shasum', 'sha256sum', or 'openssl'" +55c48 +< oops "SHA-256 hash mismatch in '$url'; expected $hash, got $hash2" +--- +> oops "SHA-256 hash mismatch in '$tarball'; expected $hash, got $hash2" 60c53 < < "$tarball" bzcat | tar -xf - -C "$unpack" || oops "failed to unpack '$url'" --- -> < "$tarball" bzcat | tar -xf - -C "$unpack" || oops "failed to unpack $tarball" +> < "$tarball" bzcat | tar -xf - -C "$unpack" || oops "failed to unpack '$tarball'" diff --git a/user_build.sh b/user_build.sh index 4784e4a..f2039db 100755 --- a/user_build.sh +++ b/user_build.sh @@ -2,5 +2,7 @@ time PACKER_LOG=1 packer build -on-error=ask -var-file=c6x64/newuser.json c6x64/renametonewuser.json +[ "$?" -ne "0" ] && exit 1 + sleep 5 time PACKER_LOG=1 packer build -on-error=ask -var-file=c6x64/newuser.json c6x64/setupuser.json From 730eae5b62936bcafecc630e33efe1d0ba8fd1de Mon Sep 17 00:00:00 2001 From: Ankur Agarwal Date: Wed, 12 Sep 2018 23:06:21 -0700 Subject: [PATCH 6/6] Add Clion to VM Version CLion-2018.2.3.tar.gz --- Makefile.cache | 6 +++++- c6x64/gui-dev-java.json | 17 ++++++++++++++++- c6x64/newuser.json | 1 + scripts/install_clion.sh | 16 ++++++++++++++++ 4 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 scripts/install_clion.sh diff --git a/Makefile.cache b/Makefile.cache index e2b4e44..4966907 100644 --- a/Makefile.cache +++ b/Makefile.cache @@ -4,7 +4,8 @@ all: \ cache/nix-2.1.1-x86_64-linux.tar.bz2 \ cache/jdk-8u172-linux-x64.rpm \ cache/netbeans-8.2-javase-linux.sh \ - cache/ideaIC-2018.2.2.tar.gz + cache/ideaIC-2018.2.2.tar.gz \ + cache/CLion-2018.2.3.tar.gz cache/nix-2.1.1-x86_64-linux.tar.bz2: | cache ${CURL} 'https://nixos.org/releases/nix/nix-2.1.1/nix-2.1.1-x86_64-linux.tar.bz2' > $@ @@ -20,6 +21,9 @@ cache/netbeans-8.2-javase-linux.sh: | cache cache/ideaIC-2018.2.2.tar.gz: | cache ${CURL} 'https://download.jetbrains.com/idea/ideaIC-2018.2.2.tar.gz' > $@ +cache/CLion-2018.2.3.tar.gz: | cache + ${CURL} 'https://download.jetbrains.com/cpp/CLion-2018.2.3.tar.gz' > $@ + cache: mkdir cache diff --git a/c6x64/gui-dev-java.json b/c6x64/gui-dev-java.json index a9461c6..514b79b 100644 --- a/c6x64/gui-dev-java.json +++ b/c6x64/gui-dev-java.json @@ -27,9 +27,16 @@ "source": "cache/{{ user `INTELLIJ_FILENAME` }}", "destination": "{{ user `INTELLIJ_FILENAME` }}" }, + + { + "type": "file", + "source": "cache/{{ user `CLION_FILENAME` }}", + "destination": "{{ user `CLION_FILENAME` }}" + }, + { "type": "shell-local", - "command": "chmod 777 cache/netbeans-8.2-javase-linux.sh" + "command": "chmod 777 cache/{{ user `NETBEANS_FILENAME` }}" }, { "type": "file", @@ -74,6 +81,14 @@ "scripts/install_intellij.sh" ] }, +{ + "type": "shell", + "environment_vars": [ "CLION_FILENAME={{ user `CLION_FILENAME` }}" ], + "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}", + "scripts": [ + "scripts/install_clion.sh" + ] +}, { "type": "shell", "environment_vars": [ "NETBEANS_FILENAME={{ user `NETBEANS_FILENAME` }}" ], diff --git a/c6x64/newuser.json b/c6x64/newuser.json index 9d875fb..c4b9a25 100644 --- a/c6x64/newuser.json +++ b/c6x64/newuser.json @@ -7,6 +7,7 @@ "SVN_SERVER_URL": "svn.int.snowflakecomputing.com", "JDK_FILENAME": "jdk-8u172-linux-x64.rpm", "INTELLIJ_FILENAME": "ideaIC-2018.2.2.tar.gz", + "CLION_FILENAME": "CLion-2018.2.3.tar.gz", "NETBEANS_FILENAME": "netbeans-8.2-javase-linux.sh", "VMWARE_TOOLS_FILENAME": "VMwareTools-10.0.6-3595377.tar.gz", "NIX_FILENAME": "nix-2.1.1-x86_64-linux.tar.bz2" diff --git a/scripts/install_clion.sh b/scripts/install_clion.sh new file mode 100644 index 0000000..ba94542 --- /dev/null +++ b/scripts/install_clion.sh @@ -0,0 +1,16 @@ +#!/bin/bash -x + +set -o errexit +set -o nounset +set -o pipefail + +[ -f "/home/vagrant/${CLION_FILENAME}" ] + +EXTRACTDIR="clion-2018.2.3" + +tar -zxf "/home/vagrant/${CLION_FILENAME}" + +[ -f "/home/vagrant/${EXTRACTDIR}/bin/clion.sh" ] + +# Desktop is not created until after graphical login +ln -s "/home/vagrant/${EXTRACTDIR}/bin/clion.sh" "/home/vagrant/CLion_launcher"