-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsetup-system.sh
executable file
·149 lines (132 loc) · 4.91 KB
/
setup-system.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
set -e
# Update apt only if the list is more than an hour old
function update_apt() {
now=$(date +%s)
an_hour_ago=$(expr ${now} - 3600)
apt_last_updated=$(stat -c '%Y' /var/lib/apt/lists)
if [ ${an_hour_ago} -gt ${apt_last_updated} ]; then
echo "~ Updating apt"
sudo apt update
fi
}
# Add a new apt config setting
# to make it always install package dependencies
# without prompting "are you sure?"
function apt_always_yes() {
if [ -d /etc/apt/apt.conf.d ] && [ ! -e /etc/apt/apt.conf.d/97always-yes ]; then
echo "~ Creating /etc/apt/apt.conf.d/97always-yes"
echo 'APT::Get::Assume-Yes "true";' | sudo tee /etc/apt/apt.conf.d/97always-yes
fi
}
# Download and install Google Chrome, as best we know how
function install_chrome() {
echo "~ Installing Google Chrome's dependencies"
update_apt # Update apt first
sudo apt install libxss1 libappindicator1 libindicator7
echo "~ Downloading google chrome .deb package"
sudo wget -P /tmp https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
echo "~ Installing downloaded package"
sudo dpkg -i /tmp/google-chrome-stable_current_amd64.deb
}
# Download and install sublime as best we know how
function install_sublime_3() {
echo "~ Downloading sublime 3 deb package"
sudo wget -P /tmp http://c758482.r82.cf2.rackcdn.com/sublime-text_build-3065_amd64.deb
echo "~ Installing downloaded package"
sudo dpkg -i /tmp/sublime-text_build-3065_amd64.deb
}
# Download and install atom as best we know how
function install_atom() {
echo "~ Downloading atom deb package"
wget -O /tmp/atom.deb https://atom.io/download/deb
echo "~ Installing downloaded package"
sudo dpkg -i /tmp/atom.deb
}
# Download and install oh my zsh
function install_oh_my_zsh() {
echo "~ Installing zsh package"
sudo apt install zsh
echo "~ Downloading and install oh my zsh"
sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
}
# Install apt packages in the list
# Prompting each time
function install_apt_packages() {
possible_packages="git python-pip vim byobu ack-grep bzr curl"
packages_to_install=""
echo "~ Choose which packages to install:"
for package in ${possible_packages}; do
while true; do
read -p "Install "${package}"? [Y/n] " install
case $install in
[Nn]* ) break;;
* ) packages_to_install=${packages_to_install}" "${package}; break;;
esac
done
done
if [ -n "${packages_to_install}" ]; then
echo "~ Installing chosen packages: "${packages_to_install}
update_apt # update apt first
sudo apt install ${packages_to_install}
fi
}
# Hub is a great way to manage git with github
function install_github_hub() {
while true; do
read -p "Install rake (required)? [Y/n] " install
case $install in
[Nn]* ) exit;;
* ) update_apt;
sudo apt install rake;
break;;
esac
done
echo "~ Cloning git://github.com/github/hub.git"
sudo git clone git://github.com/github/hub.git -b 1.12-stable /tmp/hub
echo "~ Installing hub"
cd /tmp/hub
sudo rake install PREFIX=/usr/local
cd -
}
# Generate a new SSH key, to be copied into Github (at the very least)
function setup_ssh_key() {
if [ ! -f ${HOME}/.ssh/id_rsa.pub ]; then
ssh-keygen
fi
if [ -f ${HOME}/.ssh/id_rsa.pub ]; then
echo -e "Here is your public key:\n"
cat ${HOME}/.ssh/id_rsa.pub
echo -e "\nPlease copy it into:"
echo -e "- Github (https://github.com/settings/ssh)"
echo -e "- Launchpad (e.g.: https://launchpad.net/~nottrobin/+editsshkeys)"
fi
}
# Run our setup-config script to setup the user's shell config
function setup_user_config() {
if [ -f setup-user-config ]; then
./setup-user-config.sh
elif [ -d ${HOME}/system-setup ]; then
${HOME}/system-setup/setup-user-config.sh;
else
while true; do
read -p "Clone the system setup repository into ~/system-setup ? [Y/n] " clone_it
case $clone_it in
[Nn]* ) break;;
* ) git clone [email protected]:nottrobin/system-setup.git ${HOME}/system-setup \
|| git clone https://github.com/nottrobin/system-setup.git ${HOME}/system-setup;
${HOME}/system-setup/setup-user-config.sh;
break;;
esac
done
fi
}
run_functions="apt_always_yes install_chrome install_sublime_3 install_atom install_apt_packages install_github_hub setup_ssh_key setup_user_config install_oh_my_zsh"
for function_name in ${run_functions}; do
while true; do
read -p "Run "${function_name}"? [Y/n] " run_it
case $run_it in
[Nn]* ) break;;
* ) eval ${function_name}; break;;
esac
done
done