Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Software installed with user-script isn't available after boot #53

Closed
damacus opened this issue Apr 14, 2020 · 5 comments
Closed

Software installed with user-script isn't available after boot #53

damacus opened this issue Apr 14, 2020 · 5 comments

Comments

@damacus
Copy link

damacus commented Apr 14, 2020

Hey!

thanks for creating this, it's been pretty awesome so far.

I'm using:

  • Parallels
  • An install-tools.sh script (which is executable) to install homebrew and Chef

I'm checking the software is available using command -v brew and it succeeds. However, when doing a vagrant up of the machine, brew isn't actually on the machine 🤔

@bacongravy
Copy link
Owner

Hi @damacus ! Could you attach your script so I can see what it is doing?

@damacus
Copy link
Author

damacus commented Apr 15, 2020

Hey! thanks for the response:

Here's the script:

# Install homebrew
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh  | sudo bash

# Install chef-client
curl -L https://omnitruck.chef.io/install.sh | sudo bash -s -- -c current -P chef

command -v chef
command -v brew

chef --version

@bacongravy
Copy link
Owner

Ah ha! The issue here is that the install script runs in the context of the host computer, not the target box. The commands you are running are installing homebrew and chef on the host computer, not into the box.

The location of the box file system is provided as the first argument to the user script. But you still need to figure out how to tell the homebrew and chef installers to install to a non-running system, which they may not support.

If you review the Homebrew site you can find manual installation instructions. If you adapt those in your user script, with all of the paths prefixed with “${1}/“, that might work better.

I can try to put together a Homebrew example later this week if that would help. See #24 in the meantime for an example user-script that uses ${1}.

@bacongravy
Copy link
Owner

@damacus I looked at the content of the install.sh script for Homebrew. I don't know how to replicate the part of the install.sh script that installs the command-line developer tools in a macinbox user script, but here is how I think you would install Homebrew, at least:

#!/bin/sh

cd "${1}/usr/local"
mkdir Homebrew
curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C Homebrew
ln -sf /usr/local/Homebrew/bin/brew "${1}/usr/local/bin/brew"

You would still need to run brew update --force in the box after booting it to complete the installation.

I think the best use of a user script is to copy new files to the box and modify existing files. Executing installers is not really going to work, unless you can tell the installers which system volume to target.

I have been searching for a good automated way to install Xcode or the command-line tools into a vagrant box for a very long time, and the best I've come up with is to install Xcode.app onto the host computer and then ditto it into the box using a user script.

For your use case, you might want to consider putting the Homebrew and Chef installation into a vagrant provisioning step. That way the commands will run in the context of the box instead of the host. If your provider supports it (VMware and VirtualBox do, I think) you could then use the vagrant package command to repackage the running machine into a new box.

@damacus
Copy link
Author

damacus commented Apr 16, 2020

Ah!

I thought the script would be copied to the box and run. My mistake when reading the docs!

Yep, back to Vagrant package to get this one done. Thanks for your time! I'll report back if parallels works with this. VritualBox was being weirdly buggy with MacOS

@damacus damacus closed this as completed Apr 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants