-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.sh
More file actions
executable file
·22 lines (17 loc) · 874 Bytes
/
init.sh
File metadata and controls
executable file
·22 lines (17 loc) · 874 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env bash
# this script should only be used on first install
ghrepo=git@github.com:thomassmyth/dotfiles.git
hn=$(echo $(basename $HOSTNAME) | cut -d"." -f1)
if [ ! -f $HOME/.ssh/${hn}_key ]; then # check SSH exists for current host, creating of necessary
echo "Creating SSH keys, enter email used with Github"
read gitemail
mkdir -p $HOME/.ssh # create ssh dir
ssh-keygen -N '' -t rsa -b 4096 -C "$gitemail" -f $HOME/.ssh/${HOSTNAME}_key
echo "Host github.com" >> $HOME/.ssh/config
echo "IdentityFile $HOME/.ssh/${HOSTNAME}_key" >> $HOME/.ssh/config
echo "Add key to github before proceeding"
return 0
fi
if [ ! -d $HOME/git/dotfiles ]; then
git clone $ghrepo $HOME/git/dotfiles # clone dotfiles repo if it does not exist
fi