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

Add hooks to source scripts before and after setup #244

Closed
wants to merge 1 commit into from

Conversation

mdelillo
Copy link

We would like to use this repo without forking it, so this PR adds hooks so that we can execute scripts before and after running the setup. If $HOME/.pivotal-workstation-pre-setup and/or $HOME/.pivotal-workstation-post-setup, scripts in them will be executed before and after the bulk of setup.sh.

Also, fixes git status alias.

* Fix git status alias

Signed-off-by: Mark DeLillo <[email protected]>
@professor
Copy link
Contributor

Hi @mdelillo -- what a few teams do is have a readme that says

  1. run workstation-setup
  2. run a team script that makes additional modifications

In this situation, there's no need to fork this repo.

I'd like to hear from others if they would see value in baking in pre, post hooks.

@mdelillo
Copy link
Author

A small win for us is that we can combine those two steps into just running our team script, which means we can run a single command and walk away for awhile when setting up a new workstation.

The specific problem we were encountering with separate scripts is that we want to run things that require sudo before and after running the setup.sh script. We couldn't find a solution that didn't require typing in the sudo password more than once without introducing these hooks.

@professor
Copy link
Contributor

@nertzy and I discussed this PR. Normally we would expect a team to run a team script after workstation setup to finish any team specific customizations. As such, it would be fine for that team script to call the workstation setup script. In this case, there is no need for any pre or post hooks.

#!/usr/bin/env bash
team setup stuff
pushd workstation-setup
./setup.sh
popd
more team setup stuff

If other teams are wanting the feature described in this PR, let us know. Thanks for understanding @mdelillo

@mdelillo
Copy link
Author

@professor @nertzy that's fair, and that is how we are using it for the most part.

Taking a step back, the original problem we are trying to solve is that we had to type the sudo password multiple times when running setup.sh. The script takes long enough to run that the password gets uncached. We have a script we run before setup.sh that extends the timeout in /etc/sudoers, but that itself needs the password to be cached. It is later reset here, requiring it to be typed again.

Another way we could go about solving this would be to only prompt for the password if it isn't cached. Something along the lines of this could work:

if ! sudo -nv 2>/dev/null; then
  sudo -K
  sudo true
fi

If you are open to something like that (or even modifying the sudoers file itself, but I'm not sure that's a great solution), I'd be happy to update this PR or make a new one.

Thanks!

@joemoore
Copy link
Contributor

joemoore commented Sep 8, 2021

We are declaring PR bankruptcy as per #295.

Please review recent changes and direction and resubmit if needed.

Thank you!

@joemoore joemoore closed this Sep 8, 2021
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

Successfully merging this pull request may close these issues.

3 participants