Skip to content

Create template.sh #6

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions template.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/sh

wait_for_enter() {
printf "Press Enter to continue: "
read -r dummy
}

create_ssh_keypair() {
username="$1"
printf "Run:\n"
printf " ssh-keygen -t rsa -f ~/%s\n" "$username"
wait_for_enter
}

git_commit() {
username="$1"
printf "Copy ~/new_key.pub into the 'user_keys' Git repository, then run:\n"
printf " git commit %s\n" "$username"
printf " git push\n"
wait_for_enter
}

wait_for_build() {
build_url="http://example.com/builds/user_keys"
printf "Wait for the build job at %s to finish\n" "$build_url"
wait_for_enter
}

retrieve_user_email() {
username="$1"
dir_url="http://example.com/directory"
printf "Go to %s\n" "$dir_url"
printf "Find the email address for user '%s'\n" "$username"
printf "Paste the email address and press enter: "
read -r email
printf "%s" "$email"
}

send_private_key() {
email="$1"
printf "Go to 1Password\n"
printf "Paste the contents of ~/new_key into a new document\n"
printf "Share the document with %s\n" "$email"
wait_for_enter
}

# Check if username argument is provided
if [ $# -ne 1 ]; then
printf "Usage: %s USERNAME\n" "$0" >&2
exit 1
fi

username="$1"
create_ssh_keypair "$username"
git_commit "$username"
wait_for_build
email=$(retrieve_user_email "$username")
send_private_key "$email"
printf "Done.\n"