-
Notifications
You must be signed in to change notification settings - Fork 1
/
20_ubuntu_apt.sh
81 lines (68 loc) · 2.36 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
74
75
76
77
78
79
80
81
#!/bin/sh
# 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="20-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 upgrade
# Install APT packages.
packages=(
fish
git-core
htop
mc
mosh
nmap
screen
snap
tree
vim
)
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 snaps
e_header "Installing Snaps"
snap install slack --classic
snap install starship --classic
snap install sublime-text --classic
# Nerd Font for Fish
if [[ ! -f "~/.local/share/fonts/Meslo LG S Regular Nerd Font Complete.ttf" ]]; then
e_header "Installing Meslo Nerd Font"
mkdir -p ~/.local/share/fonts
cd ~/.local/share/fonts && curl -fLo "Meslo LG S Regular Nerd Font Complete.ttf" https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/Meslo/S/Regular/complete/Meslo%20LG%20S%20Regular%20Nerd%20Font%20Complete.ttf
fc-cache -fv
fi
# set Fish as default shell
chsh -s `which fish`