-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall.sh
executable file
·155 lines (124 loc) · 4.64 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
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#!/bin/bash
###
# Installer for Serubin's Dotfiles
# @Serubin
# MIT License
###
echo "-------- Setting up Serubin's Dotfiles --------"
source ${HOME}/.dotfiles.info
export flag_help=0
export flag_update=0
export flag_list=0
export flag_install=""
export installed=""
export installed_len+=0
# process arguments
set -- $(getopt "huli:" "$@")
while [ $# -gt 0 ]; do
case "$1" in
(-h) flag_help=1 ;;
(-u) flag_update=1 ;;
(-l) flag_list=1 ;;
(-i) flag_install="$flag_install $2"; shift ;;
(--) shift; break ;;
(*) break ;;
esac
shift
done
# Help options
if [[ ${flag_help} == "1" ]]; then
echo "usage: ./install -huli:<install>"
echo " -h Usage"
echo " -u Update all currently installed packages"
echo " -l List all currently installed packages"
echo " -i <package,package2> Installs given packages"
exit
fi
# Update flag
if [[ ${flag_update} == "1" ]]; then
export installed=(${DOTFILES_INSTALLED})
export installed_len=${DOTFILES_INSTALLED_LEN}
fi
# List flag
if [[ ${flag_list} == "1" ]]; then
echo "Not yet implemented"
exit
fi
# Install flag
if [[ ${flag_install} != "" ]]; then
echo "Not yet implemented"
exit
fi
# Get current dir (so run this script from anywhere)
export DOTFILES_DIR="$( \cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
mkdir -p ${HOME}/.dotfiles-bak 2> /dev/null
if [ ! -r "${HOME}/.dotfiles.info" ]; then
echo "-------- Git Author Info --------"
echo "Please enter your git author information. (name and email)."
echo "If you want to change this later you can edit '~/dotfiles.info'"
cp ${DOTFILES_DIR}/util/dotfiles.info-template ${HOME}/.dotfiles.info
read -p "Name: " git_name
export git_name
perl -p -i -e 's/git_name=".*"/git_name="$ENV{git_name}"/g;' ${HOME}/.dotfiles.info
read -p "Email: " git_email
git_email=$(echo ${git_email} | sed -e 's/[@&]/\\&/g') # escapes @ sign
export git_email
perl -p -i -e 's/git_email=".*"/git_email="$ENV{git_email}"/g;' ${HOME}/.dotfiles.info
echo "---------------------------------"
fi
# saves dotfile location
sed -i -e 's#%location%#'${DOTFILES_DIR}'#g' ${HOME}/.dotfiles.info
# Source install functions
source ${DOTFILES_DIR}/util/inputFunc.sh
source ${DOTFILES_DIR}/packages/install_package.sh
# Get *nix distro
source ${DOTFILES_DIR}/util/detectos.sh
# Update dotfiles itself first -
echo "Fetching latest from git:"
[ -d "${DOTFILES_DIR}/.git" ] && git --work-tree="${DOTFILES_DIR}" --git-dir="${DOTFILES_DIR}/.git" pull --recurse-submodules=yes origin master && git submodule init && git submodule update
# Get sudo up to avoid typing it in mid script
echo ""
echo "------------ Sudo/Root Required ------------"
echo "Root or sudo is required to install most packages. Please sudo up:"
sudo echo 'Running in sudo mode'
echo ""
# Give Arch users a chance to abort
if [[ ${DISTRO} == "Arch" ]]; then
echo "====> WARNING <===="
echo "This script will perform a full system upgrade"
if [ `getInputBoolean "Do you wish to continue?"` == "0" ]; then
return;
fi
fi
ln -sfv "${DOTFILES_DIR}/common/dircolors-solarized/dircolors.256dark" ~/.dir_colors
# package installations
if [[ ${flag_update} != "1" ]]; then # if update, don't prompt
registerPackage "cli" "required" # required packages
echo "Which shell would you like to use? It's recommend to select ONE."
registerPackage "shell" "bash"
registerPackage "shell" "zsh"
registerPackage "cli" "git"
registerPackage "cli" "nvim"
registerPackage "cli" "tmux"
registerPackage "cli" "htop"
registerPackage "cli" "vhdl"
# Prompt for desktop
if [[ `getInputBoolean "Would you like to install desktop packages?"` == "1" ]]; then
registerPackage "desktop" "i3"
registerPackage "desktop" "latex"
fi
# dotfiles.info replacement
export installed
perl -p -i -e 's/DOTFILES_INSTALLED=".*"/DOTFILES_INSTALLED="$ENV{installed}"/g;' ${HOME}/.dotfiles.info
perl -p -i -e 's/DOTFILES_INSTALLED_LEN=".*"/DOTFILES_INSTALLED_LEN="'${installed_len}'"/g;' ${HOME}/.dotfiles.info
echo "------------ Installing "
installPackage "" ""
fi
# package updates
if [[ ${flag_update} == "1" ]]; then # if update, don't prompt
echo "------------ Updating "
installPackage ${installed_len} ${installed[@]}
fi
cd $DOTFILES_DIR
# Removing variables
unset flag_update flag_install flag_list flag_help installed git_name git_email DOTFILES_DIR