-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup
More file actions
executable file
·209 lines (176 loc) · 8.5 KB
/
setup
File metadata and controls
executable file
·209 lines (176 loc) · 8.5 KB
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#!/usr/bin/env bash
set -e
conf_dir="$HOME/configuration"
app_dir="$conf_dir/packages"
sys_dir="$conf_dir/system"
dot_dir="$conf_dir/dotfiles"
pacman_native='pacmanNative.txt'
pacman_foreign='pacmanForeign.txt'
composer='composer.txt'
pip='pip.txt'
gem='gem.txt'
npm='npm.txt'
typeset -A args
args=(
["save"]="# saves certain dotfiles and system files"
["install"]="# creates username if needed, restores personal files, gets and sets the dotfiles, restores packages"
["links"]="# links git dotfiles to the home directory"
["fonts"]="# retrieves some fonts and installs them"
)
main() (
if [[ $# -lt 1 || -z "${args[$1]}" ]]; then
error
fi
"$1" "${@:2}"
)
save () (
mkdir -p "$app_dir"
mkdir -p "$sys_dir"
pacman -Qqen > "$app_dir/$pacman_native"
pacman -Qqem > "$app_dir/$pacman_foreign"
pip list --user --format=freeze | awk -F "==" '{print $1}' > "$app_dir/$pip"
composer global show --direct | awk '{print $1}' > "$app_dir/$composer"
gem list --local --no-details --no-versions -q > "$app_dir/$gem"
ls "$(npm root -g)" > "$app_dir/$npm"
sysFiles=(
'/etc/default/tlp'
'/etc/iptables/iptables.rules' '/etc/iptables/ip6tables.rules'
'/etc/iptables/iptables_torrent.rules' '/etc/iptables/ip6tables_torrent.rules'
'/etc/unbound/unbound.conf' '/etc/unbound/adservers' '/etc/tor/torrc'
'/etc/dhcpcd.conf' '/etc/hostname' '/etc/host.conf' '/etc/hosts'
'/etc/dhclient.conf' '/etc/resolvconf.conf'
'/etc/systemd/logind.conf' '/etc/systemd/timesyncd.conf'
'/etc/systemd/coredump.conf' '/etc/systemd/journald.conf'
'/etc/modprobe.d/' '/etc/modules-load.d' '/etc/udev/rules.d' '/etc/mkinitcpio.conf'
'/etc/fstab' '/etc/sysctl.d' '/etc/conf.d/wireless-regdom' '/etc/lvm/lvm.conf'
'/etc/security/pam_mount.conf.xml' '/etc/pam.d/system-auth'
'/etc/openal' '/etc/libao.conf' '/etc/asound.conf' '/etc/pulse'
'/etc/locale.conf' '/etc/locale.gen' '/etc/vconsole.conf' '/etc/inputrc' '/etc/localtime'
'/etc/X11/xinit/xinitrc.d' '/etc/X11/xorg.conf.d'
'/etc/pacman.conf' '/etc/makepkg.conf'
'/etc/security/limits.conf'
'/etc/colorgcc/colorgccrc'
'/etc/group'
'/etc/NetworkManager/NetworkManager.conf'
)
cp --parents -a "${sysFiles[@]}" "$sys_dir"
chmod 644 "$sys_dir/etc/unbound/unbound.conf"
)
install() (
########## 1 - If logged in as root ask for target user ##########
if [[ "$EUID" -eq 0 ]]; then
echo 'install files for user with username...'
read user
if [[ -z "$(getent passwd $user)" ]]; then
groupadd "$user"
useradd -m -g "$user" -G wheel,uucp,rfkill,games,users,vboxusers,wireshark,"$user",networkmanager -s /bin/zsh "$user"
home="/home/$user"
mkdir -p "$home"
chown -R "$user:$user $home"
fi
su --login "$user"
fi
########## End of 1 ##########
########## 2 - Get private keys, data and other personal stuff ##########
echo 'Getting personal files'
private_storage_uuid='ffbc86b7-419d-4c71-a094-3670693e65de'
private_storage="$(mount | grep $(readlink -f "/dev/disk/by-uuid/$private_storage_uuid") | awk '{print $3}')"
if [[ -z "$private_storage" ]]; then
1>&2 echo 'Private storage not mounted'
exit 1
fi
backups="$private_storage/borgBackups"
backup="$(borg list "$backups" | tail -n 1 | awk '{print $1}')"
backup_home="home/$USER"
data_to_extract=("$backup_home/.gnupg" "$backup_home/.weechat" "$backup_home/.config/tox")
cd /
borg extract "$backups::$backup" "${data_to_extract[@]}"
########## End of 2 ##########
########## 3 - Configuration files ##########
if [[ ! -d "$conf_dir/.git" ]]; then
git clone git@bitbucket.org:hugdru/archlinuxconfiguration.git "$conf_dir"
fi
echo 'Setting up symbolic links'
setUpSymbolicLinks "$dot_dir"
########## End of 3 ##########
########## 4 - Packages ##########
# Composer
composer global require $(<"$app_dir/$composer")
# Pip
pip install --user $(<"$app_dir/$pip")
# npm
npm install -g $(<"$app_dir/$npm")
# gem
gem install $(<"$app_dir/$gem")
# pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs pip install --user --upgrade
#
# missing picard settings
# missing pcmanfm settings
# missing qbittorrent settings
# missing elixir vim
########## End of 4 ##########
########## 5 - nvim configuration ##########
curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
nvim -c ':PlugUpdate | :qa'
"$HOME/.config/nvim/plugged/YouCompleteMe/install.py" --all
########## End of 5 ##########
########## 6 - zsh setup ##########
curl -sL https://raw.githubusercontent.com/zplug/installer/master/installer.zsh | zsh
########## End of 6 ##########
#
########## 7 - fonts ##########
fonts
########## End of 7 ##########
)
fonts() (
fonts_dir="$HOME/.local/share/fonts/"
rm -rf "$fonts_dir"
mkdir -p "$fonts_dir"
tmp_dir="/tmp/awesome-terminal-fonts-$$"
git clone https://github.com/gabrielelana/awesome-terminal-fonts.git "$tmp_dir"
cp $tmp_dir/build/*.ttf "$fonts_dir"
rm -rf "$tmp_dir"
cd "$fonts_dir"
curl -fLo "Sauce Code Pro Black Nerd Font Complete Mono.ttf" 'https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/SourceCodePro/Black/complete/Sauce%20Code%20Pro%20Black%20Nerd%20Font%20Complete%20Mono.ttf'
curl -fLo "Sauce Code Pro Bold Nerd Font Complete Mono.ttf" 'https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/SourceCodePro/Bold/complete/Sauce%20Code%20Pro%20Bold%20Nerd%20Font%20Complete%20Mono.ttf'
curl -fLo "Sauce Code Pro ExtraLight Nerd Font Complete Mono.ttf" 'https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/SourceCodePro/Extra-Light/complete/Sauce%20Code%20Pro%20ExtraLight%20Nerd%20Font%20Complete%20Mono.ttf'
curl -fLo "Sauce Code Pro Light Nerd Font Complete Mono.ttf" 'https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/SourceCodePro/Light/complete/Sauce%20Code%20Pro%20Light%20Nerd%20Font%20Complete%20Mono.ttf'
curl -fLo "Sauce Code Pro Medium Nerd Font Complete Mono.ttf" 'https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/SourceCodePro/Medium/complete/Sauce%20Code%20Pro%20Medium%20Nerd%20Font%20Complete%20Mono.ttf'
curl -fLo "Sauce Code Pro Nerd Font Complete Mono.ttf" 'https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/SourceCodePro/Regular/complete/Sauce%20Code%20Pro%20Nerd%20Font%20Complete%20Mono.ttf'
curl -fLo "Sauce Code Pro Semibold Nerd Font Complete Mono.ttf" 'https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/SourceCodePro/Semibold/complete/Sauce%20Code%20Pro%20Semibold%20Nerd%20Font%20Complete%20Mono.ttf'
curl -fLo "DejaVu Sans Mono Bold Oblique for Powerline Nerd Font Complete Mono.ttf" 'https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/DejaVuSansMono/Bold-Italic/complete/DejaVu%20Sans%20Mono%20Bold%20Oblique%20for%20Powerline%20Nerd%20Font%20Complete%20Mono.ttf'
curl -fLo "DejaVu Sans Mono Bold for Powerline Nerd Font Complete Mono.ttf" 'https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/DejaVuSansMono/Bold/complete/DejaVu%20Sans%20Mono%20Bold%20for%20Powerline%20Nerd%20Font%20Complete%20Mono.ttf'
curl -fLo "DejaVu Sans Mono Oblique for Powerline Nerd Font Complete Mono.ttf" 'https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/DejaVuSansMono/Italic/complete/DejaVu%20Sans%20Mono%20Oblique%20for%20Powerline%20Nerd%20Font%20Complete%20Mono.ttf'
curl -fLo "DejaVu Sans Mono for Powerline Nerd Font Complete Mono.ttf" 'https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/DejaVuSansMono/Regular/complete/DejaVu%20Sans%20Mono%20for%20Powerline%20Nerd%20Font%20Complete%20Mono.ttf'
fc-cache -fv "$fonts_dir"
)
links() (
setUpSymbolicLinks "$dot_dir"
)
setUpSymbolicLinks() (
if [[ $# -ne 1 || ! -d "$1" ]]; then
1>2 echo "$funcstack[1] expects a path to a directory"
fi
echo 'Symbolic Links will override any existing files! You might lose your configuration files! YyY to continue'
read response
if [[ "$response" != "YyY" ]]; then
return
fi
find "$1" \( -type f -o -type l \) -a -not -path '*/.git/*' -printf '%P\0' | while read -d $'\0' file
do
dir="${file%/*}"
if [[ -d "$1/$dir" ]]; then
mkdir -p "$HOME/$dir"
fi
echo "$(readlink -f "$1/$file")" "$HOME/$file"
ln -f -s "$(readlink -f "$1/$file")" "$HOME/$file"
done
)
error() {
for key in "${!args[@]}"; do
1>&2 echo -e "$key ${args[$key]}"
done
exit 1
}
main "$@"