Permalink
Browse files

bootstrap.sh: allow using SSH authentication

Signed-off-by: James Christopher Adduono <jc@adduono.com>
  • Loading branch information...
jcadduono committed Sep 2, 2017
1 parent 1785d30 commit 4d6d71bdb30af0732d8192ae39464d5336d1d7d1
Showing with 21 additions and 8 deletions.
  1. +21 −8 nethunter-installer/bootstrap.sh
@@ -1,11 +1,14 @@
#!/bin/sh

GIT_ACCOUNT=offensive-security
GIT_REPOSITORY=nethunter-devices

ABORT() {
[ "$1" ] && echo "Error: $*"
exit 1
}

cd "$(dirname "$0")"
cd "$(dirname "$0")" || ABORT "Failed to enter script directory!"

if [ ! "$(basename "$(pwd)")" = "nethunter-installer" ]; then
ABORT "You must run this script from the nethunter-installer directory!"
@@ -17,11 +20,11 @@ if [ -d devices ]; then
echo " D) Delete devices folder and start over"
echo " C) Cancel"
printf "Your choice? (U/d/c): "
read choice
read -r choice
case $choice in
U*|u*|"")
echo "Updating devices (fetch & rebase)..."
cd devices
cd devices || ABORT "Failed to enter devices directory!"
git fetch && git rebase || ABORT "Failed to update devices!"
exit 0
;;
@@ -36,22 +39,32 @@ fi
clonecmd="git clone"

printf "Would you like to use the experimental devices branch? (y/N): "
read choice
read -r choice
case $choice in
y*|Y*)
clonecmd="$clonecmd --branch experimental" ;;
*) ;;
clonebranch=experimental ;;
*)
clonebranch=master ;;
esac

printf "Would you like to grab the full history of devices? (y/N): "
read choice
read -r choice
case $choice in
y*|Y*) ;;
*)
clonecmd="$clonecmd --depth 1" ;;
esac

clonecmd="$clonecmd https://github.com/offensive-security/nethunter-devices.git devices"
printf "Would you like to use SSH authentication (faster, but requires a GitHub account with SSH keys)? (y/N): "
read -r choice
case $choice in
y*|Y*)
cloneurl="git@github.com:${GIT_ACCOUNT}/${GIT_REPOSITORY}" ;;
*)
cloneurl="https://github.com/${GIT_ACCOUNT}/${GIT_REPOSITORY}.git" ;;
esac

clonecmd="$clonecmd --branch $clonebranch $cloneurl devices"
echo "Running command: $clonecmd"

$clonecmd || ABORT "Failed to git clone devices!"

0 comments on commit 4d6d71b

Please sign in to comment.