-
Notifications
You must be signed in to change notification settings - Fork 2
accepting location as an input parameter #4
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,37 @@ | ||
#!/bin/bash | ||
# Boot up github shell access for Windows WSL/Ubuntu. | ||
|
||
#!/bin/bash | ||
if [ "$#" -lt 1 ] | ||
then | ||
echo "Please insert at least one argument" | ||
exit | ||
fi | ||
|
||
private_key_location=~/.ssh/github_rsa # Change this location to where your file is located. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't remove this yet, we can have a fallback. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you want to keep both ways ie manually editing and optionally passing parameters? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. As mentioned above, the location parameter is optional. |
||
myArray=( "$@" ) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. needs a better name. |
||
private_key_location=${myArray[0]} | ||
verbose=${myArray[1]} | ||
|
||
verbose=$1 | ||
if [ ! -e $private_key_location ]; then | ||
echo "key $private_key_location not found" | ||
exit | ||
fi | ||
|
||
echo 'Starting...' | ||
|
||
if [ "$1" = "-v" ]; then | ||
if [ "$verbose" = "-v" ]; then | ||
echo 'Booting up ssh-agent...' | ||
fi | ||
|
||
eval `ssh-agent -s` | ||
# ssh_agent_running=$(ssh-agent -s) | ||
ssh_agent_running=$(ssh-agent -s) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you test this once? I reckon that this might not work. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes the variable is storing the command output. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, but the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
if [ "$1" = "-v" ]; then | ||
if [ "$verbose" = "-v" ]; then | ||
echo 'ssh-agent started with output:' $ssh_agent_running | ||
echo 'Adding private key to ssh-agent...' | ||
fi | ||
|
||
ssh_add_result=$(ssh-add $private_key_location) | ||
|
||
if [ "$1" = "-v" ]; then | ||
echo 'ssh-agent started with output:' $ssh_agent_running | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The status messages are a part of the 'verbosity' 😅 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same msg is already there in previous if block. so I removed from here |
||
echo 'Adding private key to ssh-agent...' | ||
if [ "$verbose" = "-v" ]; then | ||
echo 'Command result: '$ssh_add_result | ||
fi | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ajaygtm71 , we want to make the location parameter optional here, and not mandatory. Probably behind a flag such as
-l <location>
or--location <location>
.