-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.bash
136 lines (122 loc) · 3.14 KB
/
install.bash
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/bin/bash
############################
# install.sh
# This script creates symlinks from the home directory to any desired dotfiles in ~/dotfiles
############################
# Variables
dir=~/.dotfiles # dotfiles directory
olddir=~/.dotfiles_old # old dotfiles backup directory
# default list of files
files=".bashrc .bash_profile .bash_aliases .vimrc"
# optional files to add
docker="y"
docker_wsl="y"
ez="y"
git="y"
tmux="y"
wordpress="y"
dreamhost="y"
zsh="y"
option=""
while [[ ! $option =~ ^[0-1]+$ ]]; do
echo "Installation Options:"
echo "[0] Full"
echo "[1] Custom"
read option
done
# docker configuration
if [[ $option -eq 1 ]];
then
read -p "Install Docker Aliases: {y/n}? " docker
fi
case "$docker" in
y|Y ) files=$files" .docker_aliases";;
esac
# docker wsl configuration
if [[ $option -eq 1 ]];
then
read -p "Install Docker WSL Configuration: {y/n}? " docker_wsl
fi
case "$docker_wsl" in
y|Y )
echo -e "export DOCKER_HOST=tcp://localhost:2375" >> $dir/.docker_aliases
read -p "Docker WSL Mount Letter (Optional): " docker_mount_path;;
esac
if [[ ! -z $docker_mount_path ]];
then
if [[ ! -d "/mnt/$docker_mount_path" ]];
then
mkdir -p /mnt/$docker_mount_path
mount -t drvfs ${docker_mount_path^^}: /mnt/$docker_mount_path
mkdir -p /$docker_mount_path
mount --bind /mnt/$docker_mount_path /$docker_mount_path
echo -e "mount --bind /mnt/$docker_mount_path /$docker_mount_path" >> $dir/.bashrc
else
echo "Error: Path could not be found or already exists: /mnt/$docker_mount_path";
fi
fi
# ez configuration
if [[ $option -eq 1 ]];
then
read -p "Install eZ Aliases: {y/n}? " ez
fi
case "$ez" in
y|Y ) files=$files" .ez_aliases";;
esac
# git configuration
if [[ $option -eq 1 ]];
then
read -p "Install Git Preferences: {y/n}? " git
fi
case "$git" in
y|Y ) files=$files" .gitconfig .gitignore_global .git_aliases";;
esac
# tmux configuration
if [[ $option -eq 1 ]];
then
read -p "Install Tmux Aliases: {y/n}? " tmux
fi
case "$tmux" in
y|Y ) files=$files" .tmux.conf";;
esac
# wordpress configuration
if [[ $option -eq 1 ]];
then
read -p "Install WordPress Aliases: {y/n}? " wordpress
fi
case "$wordpress" in
y|Y ) files=$files" .wordpress_aliases";;
esac
# dreamhost configuration
if [[ $option -eq 1 ]];
then
read -p "Install Dreamhost Aliases: {y/n}? " dreamhost
fi
case "$dreamhost" in
y|Y ) files=$files" .dreamhost_profile";;
esac
# zsh configuration
if [[ $option -eq 1 ]];
then
read -p "Install ZSH Config: {y/n}? " zsh
fi
case "$zsh" in
y|Y ) files=$files" .zshrc";;
esac
# create dotfiles_old in homedir
echo "Creating $olddir for backup of any existing dotfiles in ~"
mkdir -p $olddir
echo "...done"
# change to the dotfiles directory
echo "Changing to the $dir directory"
cd $dir
echo "...done"
# move any existing dotfiles in homedir to dotfiles_old directory,
# then create symlinks
for file in $files; do
echo "Moving any existing dotfiles from ~ to $olddir"
mv ~/$file $olddir/$file
echo "Creating symlink to $file in home directory."
ln -s $dir/$file ~/$file
echo "$file ...done"
done