-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_once_before_20-install-devcontainer-cli-tools.sh.tmpl
More file actions
63 lines (55 loc) · 2.64 KB
/
run_once_before_20-install-devcontainer-cli-tools.sh.tmpl
File metadata and controls
63 lines (55 loc) · 2.64 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
{{- if (get . "devcontainer") }}
{{- $needs1passwordRepo := false -}}
{{- $needsEzaRepo := false -}}
{{- $aptPackages := list -}}
{{- range $name := keys .packages | sortAlpha -}}
{{- $pkg := get $.packages $name -}}
{{- if and (has "devcontainer" (get $pkg "profiles")) (not (eq $name "mise")) (not (eq $name "starship")) -}}
{{- $aptPackages = append $aptPackages (or (get $pkg "apt") $name) -}}
{{- end -}}
{{- if and (has "devcontainer" (get $pkg "profiles")) (eq (get $pkg "aptRepo") "1password") -}}
{{- $needs1passwordRepo = true -}}
{{- end -}}
{{- if and (has "devcontainer" (get $pkg "profiles")) (eq (get $pkg "aptRepo") "eza") -}}
{{- $needsEzaRepo = true -}}
{{- end -}}
{{- end }}
#!/bin/sh
set -eu
{{ template "devcontainer-apt-bootstrap.sh" . }}
{{- if $needs1passwordRepo }}
printf 'Adding 1Password apt repository...\n'
$SUDO install -d -m 0755 /etc/apt/keyrings
curl -fsSL https://downloads.1password.com/linux/keys/1password.asc | gpg --dearmor | $SUDO tee /etc/apt/keyrings/1password.gpg >/dev/null
$SUDO chmod go+r /etc/apt/keyrings/1password.gpg
printf 'deb [arch=%s signed-by=/etc/apt/keyrings/1password.gpg] https://downloads.1password.com/linux/debian/%s stable main\n' "$(dpkg --print-architecture)" "$(dpkg --print-architecture)" | $SUDO tee /etc/apt/sources.list.d/1password.list >/dev/null
{{- end }}
{{- if $needsEzaRepo }}
printf 'Adding eza apt repository...\n'
$SUDO install -d -m 0755 /etc/apt/keyrings
curl -fsSL https://raw.githubusercontent.com/eza-community/eza/main/deb.asc | gpg --dearmor | $SUDO tee /etc/apt/keyrings/gierens.gpg >/dev/null
$SUDO chmod go+r /etc/apt/keyrings/gierens.gpg
printf 'deb [signed-by=/etc/apt/keyrings/gierens.gpg] http://deb.gierens.de stable main\n' | $SUDO tee /etc/apt/sources.list.d/gierens.list >/dev/null
{{- end }}
printf 'Installing devcontainer CLI packages...\n'
$SUDO apt-get update
$SUDO apt-get install -y {{ join " " $aptPackages }}
if command -v batcat >/dev/null 2>&1 && ! command -v bat >/dev/null 2>&1; then
printf 'Linking batcat as bat...\n'
$SUDO install -d -m 0755 /usr/local/bin
$SUDO ln -sf "$(command -v batcat)" /usr/local/bin/bat
fi
if command -v fdfind >/dev/null 2>&1 && ! command -v fd >/dev/null 2>&1; then
printf 'Linking fdfind as fd...\n'
$SUDO install -d -m 0755 /usr/local/bin
$SUDO ln -sf "$(command -v fdfind)" /usr/local/bin/fd
fi
if ! command -v mise >/dev/null 2>&1; then
printf 'Installing mise...\n'
curl -fsSL https://mise.run | $SUDO env MISE_INSTALL_PATH=/usr/local/bin/mise sh
fi
if ! command -v starship >/dev/null 2>&1; then
printf 'Installing starship...\n'
curl -fsSL https://starship.rs/install.sh | $SUDO sh -s -- -y -b /usr/local/bin
fi
{{- end }}