-
Notifications
You must be signed in to change notification settings - Fork 0
/
privateboxen.sh
executable file
·97 lines (97 loc) · 3.13 KB
/
privateboxen.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/sh
#All in one script for private boxen
function sourcing {
if [[ -f ~/.bashrc ]]; then
found=$(grep "[ -f /opt/boxen/env.sh ] && source /opt/boxen/env.sh" ~/.bashrc)
if [[ $found = "[ -f /opt/boxen/env.sh ] && source /opt/boxen/env.sh" ]]; then
echo "already in your bashrc"
else
echo "[ -f /opt/boxen/env.sh ] && source /opt/boxen/env.sh" >> ~/.bashrc
/opt/boxen/repo/script/boxen --env
echo "Done"
fi
else
sudo touch ~/.bashrc && sudo chmod 777 ~/.bashrc && echo "[ -f /opt/boxen/env.sh ] && source /opt/boxen/env.sh" >> ~/.bashrc
echo "Done"
fi
}
function sourcing_zsh {
##enable boxen in zsh terminal
if [[ -f ~/.zshrc ]]; then
found=$(grep "[ -f /opt/boxen/env.sh ] && source /opt/boxen/env.sh" ~/.zshrc)
if [[ $found = "[ -f /opt/boxen/env.sh ] && source /opt/boxen/env.sh" ]]; then
echo "already in your .zshrc"
else
echo "[ -f /opt/boxen/env.sh ] && source /opt/boxen/env.sh" >> ~/.zshrc
/opt/boxen/repo/script/boxen --env
echo "Done, You can now also run boxen using zsh"
fi
read -p "Do you want zsh to be your default shell? [Y/N]" -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
chsh -s $(which zsh)
if [ $SHELL = "/bin/zsh" ]; then
echo "Restart your terminal to start using zsh!"
else
echo "Something went wrong, it's still on bash shell"
fi
else
echo "Ok, bye"
fi
else
echo "No zsh installed! Your boxen will only work on bash environment Otherwise install zsh and run boxen again \nNow you're Good to Go!"
fi
}
function sshkeyupload {
pubkey=$(cat ~/.ssh/id_rsa.pub)
curl --silent --user $bituser:$bitpass -X POST https://bitbucket.org/api/1.0/users/$bituser/ssh-keys --data-urlencode "key=$pubkey" --data-urlencode "label=$label" >/dev/null
if [ ! -n "$(grep "^bitbucket.org " ~/.ssh/known_hosts)" ]; then
ssh-keyscan bitbucket.org >> ~/.ssh/known_hosts 2>/dev/null;
fi
echo "\nPlease check your Bitbucket ssh-keys under Bitbucket settings"
}
######add user ssh-key
while :
do
label=$(hostname)
read -p "DevOps or Backend Build? [Y/N]" answer
case "$answer" in
y|Y )
read -p 'Bitbucket username: ' bituser
read -sp 'Password: ' bitpass
if [[ -f ~/.ssh/id_rsa.pub ]]; then
sshkeyupload
else
echo "Public key not found! \n Creating SSH key now....\n Please wait....."
cat /dev/zero | ssh-keygen -q -N "" > /dev/null
sshkeyupload
fi
echo "We will upload your Mac's ssh-keys to enable cloning from your bitbucket's repositories"
break
;;
n|N )
echo "Working into the next step....."
break
;;
* )
echo "invalid"
;;
esac
done
#######permission for our boxen to run casks###
echo "Sudo for some applications"
cd / && sudo chown -R $(whoami) /usr/local/bin
######warns user for xcode update
echo "Make sure your xcode is already installed and verified!"
#######update gems for dependencies
echo "Updating gems to make our boxen healthy"
cd /opt/boxen/repo && /opt/boxen/repo/script/bootstrap
read -p "Is your machine File Disk Encrypted? [Y/N]" fde
echo
if [[ $fde =~ ^[Yy]$ ]]; then
/opt/boxen/repo/script/boxen --debug
else
/opt/boxen/repo/script/boxen --no-fde --debug
fi
sourcing
sourcing_zsh