-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.sh
executable file
·168 lines (137 loc) · 5.8 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
156
157
158
159
160
161
162
163
164
165
166
167
168
#!/bin/sh
### OPTIONS AND VARIABLES ###
printhelp() {
# `cat << EOF` means that cat should stop reading when EOF is detected.
cat << EOF
Optional arguments for custom use:
-h Display this message.
-p Dependencies and programs csv (local file).
-l Specify to also install language servers.
EOF
# Exit once we have printed the help message.
exit 1
}
while getopts ":hp:l" opt; do
case $opt in
h) printhelp ;;
p) progsfile=${OPTARG} ;;
l) lsp=true ;;
esac
done
[ -z "$progsfile" ] && progsfile="progs.csv"
[ -z "$dotfilesrepo" ] && dotfilesrepo="https://github.com/yannickperrenet/dotfiles.git"
### FUNCTIONS ###
installpkg() {
sudo apt install -y $1 > /dev/null 2>&1
}
maininstall() {
echo "Installing \`$1\` ($n of $total). $1 $2"
installpkg "$1"
}
pipinstall() {
echo "Installing the Python package \`$1\` ($n of $total). $1 $2"
# Install the Python package without prompting the user for
# confirmation.
yes | pipx install "$1"
}
pipxinject() {
echo "Installing the Python package \`$1\` ($n of $total). $1 $2"
# Install the Python package without prompting the user for
# confirmation.
yes | pipx inject "$2" "$1"
}
progsinstallation() {
# Get the progsfile and delete the header.
[ -f "$progsfile" ] && cat "$progsfile" | sed '/^#/d' > /tmp/progs.csv
total=$(wc -l < /tmp/progs.csv)
# Use , as the delimeter.
while IFS=, read -r tag program comment; do
# Indication of how many programs we have installed so far.
n=$((n+1))
# Remove the "" from the comment.
comment="$(echo "$comment" | sed "s/\(^\"\|\"$\)//g")"
case "$tag" in
"P") pipinstall "$program" "$comment" ;;
"PI") pipxinject "$program" "$comment" ;;
*) maininstall "$program" "$comment" ;;
esac
done < /tmp/progs.csv
}
putgitrepo() { # Downloads a gitrepo $1 and places the files in $2 only overwriting conflicts
# Create a temporary directory and the destination directory, and
# make sure they are owned by the current user.
dir=$(mktemp -d)
[ ! -d "$2" ] && mkdir -p "$2"
chown -R "$USER":"$USER" "$dir" "$2"
sudo -u "$USER" git clone --recursive --recurse-submodules "$1" "$dir" > /dev/null 2>&1
sudo -u "$USER" cp -rfT "$dir" "$2" >/dev/null 2>&1
}
### THE ACTUAL SCRIPT ###
# Build dependencies.
for x in curl git zsh; do
echo "Installing \`$x\` which is required to install and configure other programs."
installpkg "$x"
done
# Install the programs from the progsfile.
progsinstallation
# Install programming languages that are needed later.
curl https://sh.rustup.rs -sSf | sh -s -- -y
rustup default stable
# Install the dotfiles in the user's home directory.
echo "Installing dotfiles..."
# putgitrepo "$dotfilesrepo" "/home/$USER"
# Setup a bare git repository to manage the dotfiles
git clone --bare --config status.showUntrackedFiles=no "$dotfilesrepo" "/home/$USER/.local/share/dotfiles"
alias dfg="/usr/bin/git --git-dir=/home/$USER/.local/share/dotfiles --work-tree=/home/$USER"
# Setup all the files.
dfg checkout -f
# Initialize the submodules, which has to be done like this in order for
# the bare repository to be able to manage them.
dfg submodule update --init --recursive
# Delete files, but make git ignore the deletion. The files can simply
# be restored with e.g. `dfg checkout README.md`.
rm -f "/home/$USER/README.md" "/home/$USER/LICENSE"
dfg update-index --assume-unchanged "/home/$USER/README.md" "/home/$USER/LICENSE"
# Make zsh the default shell for the user.
sudo chsh -s /bin/zsh "$USER" > /dev/null 2>&1
sudo -u "$USER" mkdir -p "/home/$USER/.cache/zsh/"
# If specified, then install language servers.
[ "$lsp" ] && sh language_servers.sh
# ----- Manual configuration
# Disable connectivity pings
sudo cp /home/$USER/.local/share/NetworkManager/disable-check.conf /etc/NetworkManager/conf.d/
sudo service NetworkManager restart
# Custom names for my SSDs
sudo cp /home/sven/.local/share/udev/10-mydrives.rules /etc/udev/rules.d/
# ----- Application specific installation
# See: https://github.com/jonls/redshift/issues/850
sudo rm /etc/apparmor.d/local/usr.bin.redshift /etc/apparmor.d/usr.bin.redshift
sudo systemctl reload apparmor.service
# Remove Gnome Display Manager and start on a tty instead
sudo apt-get remove -y gdm3
# Set up crontabs from dotfiles repo
crontab /home/$USER/.local/share/crontab/crontabs
# Get dptfxtract to set up thermald config. However, don't decide for
# the user and don't execute it. The increased performance will
# generate more heat and thus make the fan spin harder.
wget --directory-prefix /home/$USER/.local/bin -q https://github.com/intel/dptfxtract/raw/master/dptfxtract
chmod +x /home/$USER/.local/bin/dptfxtract
# Nvim
wget --directory-prefix /home/$USER/Downloads -q https://github.com/neovim/neovim/releases/download/v0.10.1/nvim-linux64.tar.gz
tar xzvf /home/$USER/Downloads/nvim-linux64.tar.gz -C /home/$USER/.local/ --strip-components 1
# Dunst.
sudo apt-get install -y libdbus-1-dev libx11-dev libxinerama-dev libxrandr-dev libxss-dev libglib2.0-dev libpango1.0-dev libgtk-3-dev libxdg-basedir-dev
cd /home/$USER/.opt/dunst # path exists in dotfiles repo
make
sudo make install
# Alacritty.
sudo apt-get install -y apt-get install cmake pkg-config libfreetype6-dev libfontconfig1-dev libxcb-xfixes0-dev libxkbcommon-dev
cd /home/$USER/.opt/alacritty # path exists in dotfiles repo
cargo build --release
sudo tic -xe alacritty,alacritty-direct extra/alacritty.info
sudo cp target/release/alacritty /home/$USER/.local/bin
# Zotero: https://www.zotero.org/support/installation
# mkdir /home/$USER/.opt/zotero && cd /home/$USER/.opt/zotero
# tar xjvf Zotero-7.0.11_linux-x86_64.tar.bz2 -C ~/.opt/zotero --strip-components 1
# ./set_launcher_icon
# ln -s /home/$USER/.opt/zotero/zotero.desktop ~/.local/share/applications/zotero.desktop