-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
365 lines (327 loc) · 10.7 KB
/
Makefile
File metadata and controls
365 lines (327 loc) · 10.7 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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
.DEFAULT_GOAL := help
include data/*.mk
# The default distribution is Arch Linux.
# To override it:
# make <target> DST=<distribution>
DST = arch
ifeq ($(DST), arch)
INSTALL_PKG = sudo pacman -S
UPDATE_PKG = sudo pacman -Syu
REMOVE_PKG = sudo pacman -R
PACKAGES += pacman-contrib
else ifeq ($(DST), ubuntu)
INSTALL_PKG = sudo apt-get -y install
UPDATE_PKG = sudo apt-get -y update
ADD_REPOSITORY = sudo apt-add-repository ppa:
REMOVE_PKG = sudo apt-get -y remove
PACKAGES += todotxt-cli
else
INSTALL_PKG = sudo pacman -S
UPDATE_PKG = sudo pacman -Syu
REMOVE_PKG = sudo pacman -R
endif
## help: Show this message
.PHONY: help
help:
@grep --no-filename --perl-regexp "^## [a-zA-Z_-]+: .[^\n]*$$" $(MAKEFILE_LIST) \
| awk 'BEGIN {FS = "^## |: "}; {printf "\033[36m%-20s\033[0m %s\n", $$2, $$3}'
## all: Run install and initialize
.PHONY: all
all: install initialize
## basic: Run a minimal install and initialization
.PHONY: basic
basic: install_basic initialize_basic
## link: Create symlinks from this repo into $HOME
.PHONY: link
link:
scripts/link.sh
## initialize: Initialize settings for installed software
.PHONY: initialize
initialize: initialize_basic \
init_curl \
init_docker \
init_grub \
init_mirrorlist \
init_pacman
## initialize_basic: Initialize a minimal set of settings
.PHONY: initialize_basic
initialize_basic: \
init_bash \
init_git \
init_putty \
init_timezone
## install: Install everything
.PHONY: install
install: install_basic \
i_dropbox \
i_go \
i_rbenv \
i_rust \
i_vpn \
install_packages \
install_aur_packages \
install_go_packages
## install_basic: Run a minimal install
.PHONY: install_basic
install_basic: \
i_paru \
install_basic_packages \
i_deno \
i_fish \
i_fisher \
i_skk_dictionaries \
i_tpm \
i_vim \
## init_bash: Set umask and source the user's bashrc
.PHONY: init_bash
init_bash:
cat config.d/bash.bashrc/defaults.sh | sudo tee --append /etc/bash.bashrc
## init_curl: Set up cURL
.PHONY: init_curl
init_curl:
mkdir --parents $$XDG_CONFIG_HOME/curl
cat .config/curlrc.template | envsubst > $$XDG_CONFIG_HOME/curlrc
## init_docker: Set up Docker
.PHONY: init_docker
init_docker:
sudo systemctl enable docker.service
sudo systemctl restart docker.service
sudo groupadd docker || :
sudo gpasswd -a $$USER docker
## init_git: Initialize settings for Git
.PHONY: init_git
init_git:
mkdir -p $$HOME/.ssh
ssh-keygen -t rsa -f $$HOME/.ssh/ni57721
cat config.d/ssh/github.conf >> $$HOME/.ssh/config
xdg-open https://github.com/settings/ssh
## init_grub: Hide the grub menu
.PHONY: init_grub
init_grub:
sudo install --mode=0644 config.d/grub/defaults.sh /etc/default/grub
sudo grub-mkconfig -o /boot/grub/grub.cfg
## init_mirrorlist: Sort pacman's mirrorlist
.PHONY: init_mirrorlist
init_mirrorlist:
sudo cp /etc/pacman.d/mirrorlist{,.bak}
sudo sed --in-place /etc/pacman.d/mirrorlist.bak \
--regexp-extended --expression 's/^[[:space:]]*#[[:space:]]*(Server)[[:space:]]*/\1 /'
rankmirrors -n 0 /etc/pacman.d/mirrorlist.bak | sudo tee /etc/pacman.d/mirrorlist
## init_pacman: Enable some pacman options
.PHONY: init_pacman
init_pacman:
sudo sed --in-place /etc/pacman.conf \
--regexp-extended --expression \
's/^[[:space:]]*#[[:space:]]*(Color)[[:space:]]*$$/\1\nILoveCandy/' \
--regexp-extended --expression \
's/^[[:space:]]*#[[:space:]]*(VerbosePkgLists)[[:space:]]*$$/\1/' \
--regexp-extended --expression \
's/^[[:space:]]*#[[:space:]]*(ParallelDownloads)[[:space:]]*=.*/\1 = 5/'
## init_putty: Create an XDG config directory for PuTTY
.PHONY: init_putty
init_putty:
mkdir $$XDG_CONFIG_HOME/putty
## init_timezone: Initialize settings for timezones
.PHONY: init_timezone
init_timezone:
sudo install -D --mode=0644 config.d/systemd/network/25-wireless.network \
/etc/systemd/network/25-wireless.network
sudo timedatectl set-timezone Asia/Tokyo
sudo timedatectl set-ntp true
sudo systemctl restart systemd-networkd
sudo systemctl restart systemd-timesyncd
## install_basic_packages: Install basic packages
.PHONY: install_basic_packages
install_basic_packages:
$(UPDATE_PKG)
$(INSTALL_PKG) $(BASIC_PACKAGES) $(BASIC_AUR_PACKAGES)
## install_packages: Install packages
.PHONY: install_packages
install_packages: install_basic_packages
$(UPDATE_PKG)
$(INSTALL_PKG) $(PACKAGES)
## install_aur_packages: Install AUR packages
.PHONY: install_aur_packages
install_aur_packages: i_paru
paru -S $(AUR_PACKAGES)
## install_go_packages: Install go packages
.PHONY: install_go_packages
install_go_packages:
for go_package in $(GO_PACKAGES); do \
go install $$go_package; \
done;
## i_deno: Install deno
.PHONY: i_deno
i_deno:
scripts/peeping.sh "https://deno.land/x/install/install.sh" | \
DENO_INSTALL=$$XDG_DATA_HOME/deno sh
## i_dropbox: Install Dropbox CLI tool
.PHONY: i_dropbox
i_dropbox:
curl -L https://www.dropbox.com/download\?plat=lnx.x86_64 | \
tar -xzf -
## i_fish: Install fish shell
.PHONY: i_fish
i_fish:
if [ "$(DST)" = ubuntu ]; then \
$(ADD_REPOSITORY)fish-shell/release-3; \
fi
$(UPDATE_PKG)
$(INSTALL_PKG) fish
echo /bin/fish | sudo tee --append /etc/shells
homectl update --shell=/bin/fish $$USER
## i_fisher: Install fisher
.PHONY: i_fisher
i_fisher: # i_fish
scripts/peeping.sh \
"https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish" | \
fish && \
fish -c "fisher install jorgebucaran/fisher"
## i_go: Install go
.PHONY: i_go
i_go:
scripts/update_go.sh
## i_paru: Install paru
.PHONY: i_paru
i_paru:
mkdir -p $$XDG_DATA_HOME/paru
cd $$XDG_DATA_HOME/paru; \
if [ "$$(git rev-parse --is-inside-work-tree 2> /dev/null)" = true ]; then \
git pull; \
else \
git clone https://aur.archlinux.org/paru.git $$XDG_DATA_HOME/paru; \
fi
cd $$XDG_DATA_HOME/paru && makepkg -si
## i_rbenv: Install rbenv
.PHONY: i_rbenv
i_rbenv:
sudo pacman -Rsc ruby
git clone https://github.com/rbenv/rbenv.git $$RBENV_ROOT
mkdir -p $$RBENV_ROOT/plugins
git clone https://github.com/rbenv/ruby-build.git $$RBENV_ROOT/plugins/ruby-build
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/main/bin/rbenv-doctor | bash
## i_rust: Install rust
.PHONY: i_rust
i_rust:
scripts/peeping.sh "https://sh.rustup.rs" | bash
## i_skk_dictionaries: Install dictionary files for skk
.PHONY: i_skk_dictionaries
i_skk_dictionaries:
mkdir -p $$XDG_DATA_HOME/skk
curl --remote-name-all --output-dir $$XDG_DATA_HOME/skk \
https://skk-dev.github.io/dict/SKK-JISYO.L.gz \
https://skk-dev.github.io/dict/SKK-JISYO.jinmei.gz \
https://skk-dev.github.io/dict/SKK-JISYO.geo.gz \
https://skk-dev.github.io/dict/SKK-JISYO.station.gz \
https://skk-dev.github.io/dict/SKK-JISYO.propernoun.gz \
https://skk-dev.github.io/dict/zipcode.tar.gz \
https://raw.githubusercontent.com/uasi/skk-emoji-jisyo/master/SKK-JISYO.emoji.utf8 \
https://skk-dev.github.io/dict/SKK-JISYO.edict.tar.gz
find $$XDG_DATA_HOME/skk -name "*.gz" | xargs -I{} gzip -d {}
tar -xf $$XDG_DATA_HOME/skk/zipcode.tar -C $$XDG_DATA_HOME/skk && \
rm $$XDG_DATA_HOME/skk/zipcode.tar
tar -xf $$XDG_DATA_HOME/skk/SKK-JISYO.edict.tar -C $$XDG_DATA_HOME/skk && \
rm $$XDG_DATA_HOME/skk/SKK-JISYO.edict.tar
git clone https://github.com/tokuhirom/jawiki-kana-kanji-dict \
$$XDG_DATA_HOME/skk/jawiki-kana-kanji-dict
## i_tpm: Install tpm
.PHONY: i_tpm
i_tpm:
git clone https://github.com/tmux-plugins/tpm $$XDG_CONFIG_HOME/tmux/plugins/tpm
bash $$XDG_CONFIG_HOME/tmux/plugins/tpm/bin/install_plugins
## i_vim: Build vim HEAD
.PHONY: i_vim
i_vim:
$(UPDATE_PKG)
$(INSTALL_PKG) autoconf automake gettext luajit
scripts/update_vim.sh
## i_vpn: Install VPN settings
.PHONY: i_vpn
i_vpn:
sudo mv /etc/swanctl/swanctl.conf{,.bak}
echo -e "\
connections {\n\
vpn {\n\
version = 2\n\
proposals = aes192gcm16-aes128gcm16-prfsha256-ecp256-ecp521,aes192-sha256-modp3072,default\n\
rekey_time = 0s\n\
fragmentation = yes\n\
dpd_delay = 300s\n\
local_addrs = %defaultroute\n\
remote_addrs = <Your VPN Server URL>\n\
vips=0.0.0.0,::\n\
local {\n\
auth = eap-mschapv2\n\
eap_id = \"<Your ID>\"\n\
}\n\
remote {\n\
auth = pubkey\n\
id = %any\n\
}\n\
children {\n\
vpn {\n\
remote_ts = 0.0.0.0/0,::/0\n\
rekey_time = 0s\n\
dpd_action = clear\n\
esp_proposals = aes192gcm16-aes128gcm16-prfsha256-ecp256-modp3072,aes192-sha256-ecp256-modp3072,default\n\
}\n\
}\n\
}\n\
}\n\
\n\
secrets {\n\
eap-vpn {\n\
id = \"<Your ID>\"\n\
secret = \"<Your Password>\"\n\
}\n\
}\n\
" | \
sudo tee /etc/swanctl/swanctl.conf
sudo rvim /etc/swanctl/swanctl.conf
sudo rmdir /etc/ipsec.d/cacerts
sudo ln -s /etc/ssl/certs /etc/ipsec.d/cacerts
## i_vpn_with_ppp: Install VPN settings with ppp
.PHONY: i_vpn_with_ppp
i_vpn_with_ppp:
curl https://www.interlink.or.jp/support/vpn/myip/myiptools/myiptools.tar.gz > /tmp/myiptools.tar.gz
sudo tar xvzf /tmp/myiptools.tar.gz -C /etc
rm /tmp/myiptools.tar.gz
echo -e "\
MYIP_SERVER=\"myip*.interlink.or.jp\"\n\
ID=\"mi*\"\n\
PASSWORD=\"****\"\n\
IPADDR=\"***.***.***.***\"\n\
DNS1=\"203.141.128.35\"\n\
DNS2=\"203.141.128.33\"\n\
CLIENT_GLOBALIP=\"AUTO\"\n\
" | \
sudo tee /etc/myip/myip.conf
sudo vim -u NONE -N /etc/myip/myip.conf
sudo /etc/myip/myip-setup
sudo sed "2q; d" /etc/myip/myip.conf | sed "s/.*\"\(.*\)\"/\1/" | \
xargs -I{} sudo cat /etc/ppp/peers/myip_{}
sudo cat /etc/ppp/chap-secrets
## create_arch_linux_installer: Create an Arch Linux installer USB (BIOS/UEFI)
.PHONY: create_arch_linux_installer
create_arch_linux_installer:
@echo -e "Download the ISO if needed"
mkdir -p $$XDG_CACHE_HOME/arch-installation
curl https://archlinux.org/iso/latest/archlinux-x86_64.iso.sig \
> $$XDG_CACHE_HOME/arch-installation/archlinux.sig.tmp
if [ ! -f $$XDG_CACHE_HOME/arch-installation/archlinux.sig ] || \
[ -n "$$(cmp $$XDG_CACHE_HOME/arch-installation/archlinux.sig{,.tmp})" ]; then \
curl https://ftp.jaist.ac.jp/pub/Linux/ArchLinux/iso/latest/archlinux-x86_64.iso \
> $$XDG_CACHE_HOME/arch-installation/archlinux.iso.tmp; \
mv $$XDG_CACHE_HOME/arch-installation/archlinux.iso{.tmp,}; \
fi
mv $$XDG_CACHE_HOME/arch-installation/archlinux.sig{.tmp,}
@echo -e "\nCheck the PGP signature"
pacman-key -v $$XDG_CACHE_HOME/arch-installation/archlinux{.sig,.iso}
@echo -e "\nCheck the name of a USB drive"
ls -l /dev/disk/by-id/usb-*
@read -p "OK? [y/n]" ans; if [ $$ans != y ]; then exit 1; fi;
@echo -e "\nEnsure that the USB drive is not mounted"
lsblk
@read -p "OK? [y/n]" ans; if [ $$ans != y ]; then exit 1; fi;
@read -p "Enter the USB drive without suffix (e.g. /dev/sdb): " usb; \
sudo cp $$XDG_CACHE_HOME/arch-installation/archlinux.iso $$usb