-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
145 lines (118 loc) · 4.15 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
#!/usr/bin/env bash
set -euo pipefail; [[ -z ${TRACE:-} ]] || set -x
cry() { echo -e "$*" >&2; }
die() { cry "$@"; exit 1; }
enter() { cry "==> $1"; cry ""; builtin pushd "$1" >/dev/null; }
exe() { /usr/bin/env bash "$@"; }
leave() { builtin popd >/dev/null; }
notice() { builtin read -rp "S* " _ >&2; }
run() { cry "--> $1"; exe "$1.sh" || cry "!!! $(readlink -f "$1")"; cry ""; }
container() { dockerized || [[ $(systemd-detect-virt -c) != none ]]; }
dockerized() { [[ -e /.dockerenv ]]; }
graphical() { [[ -n ${DISPLAY:-} ]]; }
physical() { ! dockerized && [[ $(systemd-detect-virt) == none ]]; }
virtual() { ! physical; }
[[ ${EUID:-} -eq 0 ]] || die "You must be root."
BRANCH=${1:-}
GITHUB=${2:-https://github.com/roktas}
logfile="${TMPDIR:-/tmp}"/"${0##*/}"-"$(date --iso-8601=seconds)".log
exec > >(tee "$logfile") 2>&1
cry "... Preparing provisioning"
codename=$(. /etc/os-release && echo "$VERSION_CODENAME") && cat >/etc/apt/sources.list <<-EOF
deb http://ftp.tr.debian.org/debian/ $codename main non-free-firmware
deb http://security.debian.org/debian-security $codename-security main non-free-firmware
deb http://ftp.tr.debian.org/debian/ $codename-updates main non-free-firmware
EOF
export DEBIAN_FRONTEND=noninteractive && apt-get -y update && apt-get -y install --no-install-recommends \
curl \
git \
jq \
libarchive-tools \
lsb-release \
unzip \
xz-utils \
zstd \
#
if [[ -t 0 ]]; then
if [[ -n ${BASH_SOURCE[0]:-} ]]; then
workdir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && echo "$PWD")
cd "$workdir"
fi
[[ -d foundation ]] || die "Is this the $GITHUB/debian local copy?"
else
workdir=$(mktemp -p "${TMPDIR:-/tmp}" -d "${0##*/}.XXXXXXXX") || exit
trap 'err=$? && rm -rf "$workdir" || exit $err' EXIT HUP INT QUIT TERM
cd "$workdir"
GIT_CONFIG_NOSYSTEM=1 git clone --filter=blob:none "$GITHUB"/debian ${BRANCH:+--branch="$BRANCH"}
cd debian
fi
cry "... Provisioning system"
enter foundation
run foundation
run standard
run locale
run timezone
run tweak
leave
enter terminal
run terminal
run git
run fish
run nvim
run vifm
run bat
run direnv
run fd
run fzf
run ripgrep
run slides
run sudo
run ttyd
run zoxide
graphical || run tmux
leave
enter runtime
run runtime
run go
run javascript
run lua
run markdown
run ruby
run python
run shell
run tex
leave
! graphical || {
enter desktop
run desktop
run chrome
run dropbox
run dropignore
run fonts
run graphics
run laptop
run obsidian
run printer
run vpn
run vscode
run wezterm
leave
}
enter virtualization
run docker
container || run virtualbox
virtual || run hashicorp
leave
enter foundation
run clean
leave
if [[ -z ${NO_DOTFILES:-} ]]; then
cry "... Installing dotfiles"
sudo -u '#1000' bash -s -- "$GITHUB" "$BRANCH" <<-'EOF'
xdg_data_home="${XDG_DATA_HOME:-$HOME/.local/share}"
mkdir -p "$xdg_data_home" && cd "$xdg_data_home"
GIT_CONFIG_NOSYSTEM=1 git clone --filter=blob:none ${1}/dotfiles ${2:+--branch="$2"} && cd dotfiles
bash install.sh
EOF
fi
exec &>"$(tty)"