forked from cowboy/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 1
/
20_ubuntu_apt.sh
73 lines (64 loc) · 1.98 KB
/
20_ubuntu_apt.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
# Ubuntu-only stuff. Abort if not Ubuntu.
is_ubuntu || return 1
# If the old files isn't removed, the duplicate APT alias will break sudo!
sudoers_old="/etc/sudoers.d/sudoers-cowboy"; [[ -e "$sudoers_old" ]] && sudo rm "$sudoers_old"
# Installing this sudoers file makes life easier.
sudoers_file="sudoers-dotfiles"
sudoers_src=$DOTFILES/conf/ubuntu/$sudoers_file
sudoers_dest="/etc/sudoers.d/$sudoers_file"
if [[ ! -e "$sudoers_dest" || "$sudoers_dest" -ot "$sudoers_src" ]]; then
cat <<EOF
The sudoers file can be updated to allow "sudo apt-get" to be executed
without asking for a password. You can verify that this worked correctly by
running "sudo -k apt-get". If it doesn't ask for a password, and the output
looks normal, it worked.
THIS SHOULD ONLY BE ATTEMPTED IF YOU ARE LOGGED IN AS ROOT IN ANOTHER SHELL.
This will be skipped if "Y" isn't pressed within the next $prompt_delay seconds.
EOF
read -N 1 -t $prompt_delay -p "Update sudoers file? [y/N] " update_sudoers; echo
if [[ "$update_sudoers" =~ [Yy] ]]; then
e_header "Updating sudoers"
visudo -cf "$sudoers_src" &&
sudo cp "$sudoers_src" "$sudoers_dest" &&
sudo chmod 0440 "$sudoers_dest" &&
echo "File $sudoers_dest updated." ||
echo "Error updating $sudoers_dest file."
else
echo "Skipping."
fi
fi
# Update APT.
e_header "Updating APT"
sudo apt-get -qq update
sudo apt-get -qq dist-upgrade
# Install APT packages.
packages=(
ansible
build-essential
cowsay
git-core
htop
id3tool
libssl-dev
mercurial
nmap
silversearcher-ag
sl
telnet
tree
)
packages=($(setdiff "${packages[*]}" "$(dpkg --get-selections | grep -v deinstall | awk '{print $1}')"))
if (( ${#packages[@]} > 0 )); then
e_header "Installing APT packages: ${packages[*]}"
for package in "${packages[@]}"; do
sudo apt-get -qq install "$package"
done
fi
# Install Git Extras
if [[ ! "$(type -P git-extras)" ]]; then
e_header "Installing Git Extras"
(
cd $DOTFILES/vendor/git-extras &&
sudo make install
)
fi