forked from jontsai/bash-ftw
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·89 lines (73 loc) · 1.95 KB
/
install.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
#!/bin/bash
#
# bash-ftw installer
# author: Jonathan Tsai <[email protected]>
#
KERNEL=`uname -s`
##################################################
echo 'Installing bash-ftw...'
echo ''
##################################################
DIRECTORIES='bin code var tmp .ssh'
echo 'Creating directories...'
for DIR in $DIRECTORIES
do
echo $HOME/$DIR
mkdir -v -p $HOME/$DIR
done
echo ''
##################################################
echo "Installing scripts into $HOME/bin..."
cp -v bin/* $HOME/bin
echo ''
##################################################
echo "Setting up SSH..."
# Observe directory permissions for SSH carefully!
chmod 700 $HOME/.ssh
touch $HOME/.ssh/authorized_keys
chmod 600 $HOME/.ssh/authorized_keys
echo ''
##################################################
echo "Installing dotfiles (.bashrc*)..."
if [ $KERNEL == 'Darwin' ] && [ -f $HOME/.bash_profile ]
then
BASHRC_FILE=$HOME/.bash_profile
elif [ -f $HOME/.bash_aliases ]
then
BASHRC_FILE=$HOME/.bash_aliases
elif [ -f $HOME/.bashrc ]
then
BASHRC_FILE=$HOME/.bashrc
else
BASHRC_FILE=''
fi
if [[ $BASHRC_FILE ]]
then
cp -v dotfiles/.bashrc.ftw $HOME/
cp -v dotfiles/.git-completion.bash $HOME/
INCLUDE_BASHRC_SOURCE="[[ -s \"\$HOME/.bashrc.ftw\" ]] && source \$HOME/.bashrc.ftw"
ALREADY_EXISTS=`tail -n 1 $BASHRC_FILE`
if [ "$ALREADY_EXISTS" == "$INCLUDE_BASHRC_SOURCE" ]
then
echo "bash-ftw is already included in $BASHRC_FILE"
else
echo "Adding bash-ftw include to $BASHRC_FILE"
echo "$INCLUDE_BASHRC_SOURCE" >> $BASHRC_FILE
fi
if [ $KERNEL == 'Darwin' ]
then
echo .bash-ftw.mac
cp -v dotfiles/.bashrc.ftw.mac $HOME/
fi
if [ $KERNEL == 'Linux' ]
then
echo .bash-ftw.linux
cp -v dotfiles/.bashrc.ftw.linux $HOME/
fi
else
echo 'Not installing .bashrc.ftw'
fi
echo ''
##################################################
echo 'Finished installing bash-ftw!'
echo ''