-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathload.tcl
executable file
·237 lines (194 loc) · 5.29 KB
/
load.tcl
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
#! /usr/bin/env tclsh
###############################################################################
# load.tcl: setup environment after a fresh VoidLinux install
set USER b
set HOME /home/$USER
set STOW $HOME/cfg/stow.tcl
set UPDATE {xbps-install -Su}
set INSTALL {xbps-install -S}
set REMOVE {xbps-remove -R}
set CLEANUP {xbps-remove -Oo}
set GITHUB git@github.com:blobject
set GITHUBPUB https://github.com
set SUDO /usr/bin/sudo
###############################################################################
# helpers
proc read_file {f} {
set h [open $f r]
set c [read -nonewline $h]
close $h
return $c
}
proc title {t} {
set c :
set len [string length $t]
set limit 60
set one [expr [expr $limit - $len - 2] / 2]
set two [expr $limit - $one - 2 - $len]
return "\n[string repeat $c $one] $t [string repeat $c $two]\n"
}
###############################################################################
proc intro {done_preq done_user} {
global UPDATE
set preq_tag {}
set preq_ex { ------ curl, git, iwd, logging}
if {$done_preq} { set preq_tag {(done) }; set preq_ex {} }
set user_tag {}
set user_ex { ----------------- groups, git, ssh, ...}
if {$done_user} { set user_tag {(done) }; set user_ex {} }
set hostname [exec uname -n]
set kernel [exec uname -r]
set os [read_file /etc/os-release]
regsub {^.*ID="([^\"]*)".*$} $os {\1} os
set disk [exec df | grep {/$} | cut -f1 {-d }]
puts "ready to setup \"${hostname}\"
(${os} ${kernel}, root=${disk})
[title STEPS]
0. ${preq_tag}install PREREQUISITES${preq_ex}
1. ${user_tag}setup USER${user_ex}
2. update PACKAGE SYSTEM ------ ${UPDATE}
3. setup BOOT ----------------- fstab, refind
4. remove NEEDLESS ------------ grub, wpa_supplicant
5. setup BASIC SYSTEM --------- rc, timezone, tlp, ...
6. install/setup BASICS ------- firmware, stow, zip, ...
7. install/setup DESKTOP ------ xorg, xterm, wayland, ...
8. install/setup MISCELLANY --- vim, libs, pipewire, ...
9. stow
10. install/setup BULKIES ------ libreoffice, texlive, ...
11. populate OPT --------------- plugins, standalones, ...
12. update KERNEL --- oldconfig, modules, cp, dracut, sed
done
make sure:
- not chroot'd
- connected to internet
- stowable config at HOME/cfg
"
flush stdout
set input {}
while {$input ni {Y N n Q q}} {
puts -nonewline {begin? [Y/n] }
flush stdout
set input [gets stdin]
if {{y} eq $input} {
puts -nonewline {capital Y please; }
}
}
if {$input in {N n Q q}} {
puts quit
exit 0
}
}
proc outro {} {
puts "[title DONE]
left to do:
- install fonts
- configure firefox, restore bookmarks
- configure libreoffice
- login and configure all web apps
- check everything
- repopulate personal files (dev, ref, sec, ...)
"
flush stdout
}
###############################################################################
proc prerequisites {isdone} {
puts [title {0: install PREREQUISITES}]
if {$isdone} {
puts {already done; skipping}
flush stdout
return
}
puts done
}
proc user {name isdone} {
puts [title {1. setup USER}]
if {$isdone} {
puts {already done; skipping}
flush stdout
return
}
puts done
}
###############################################################################
proc package {} {
global UPDATE SUDO
puts [title {2. update PACKAGE SYSTEM}]
exec $SUDO {*}$UPDATE
puts done
}
proc boot {} {
}
proc needless {} {
}
###############################################################################
proc system {} {
global HOME GITHUB
exec mkdir bak got log mnt opt ref src
exec git clone $GITHUB/dotfiles.git cfg
}
###############################################################################
proc basics {} {
}
proc desktop {} {
global SUDO
#exec $SUDO mkdir -p /usr/share/xsessions
}
proc miscellany {} {
}
###############################################################################
proc stow {} {
global HOME
cd $HOME
}
proc bulkies {} {
}
proc opt {} {
global HOME GITHUBPUB
cd $HOME/opt
exec mkdir -p kak
cd kak
#exec git clone $GITHUBPUB/Bodhizafa/kak-rainbow
cd ..
}
###############################################################################
proc kernel {} {
}
###############################################################################
proc check_prerequisites {} {
# TODO: tie it into intro and self logic (why and which failed)
if {{link} ne [file type /var/service/socklog-unix]} { return false }
if {![file executable /usr/bin/curl]} { return false }
if {![file executable /usr/bin/git]} { return false }
if {{link} ne [file type /var/service/iwd]} { return false }
if {![file executable /usr/bin/iwctl]} { return false }
if {{link} ne [file type /var/service/socklog-unix]} { return false }
return true
}
proc check_user {name} {
global HOME
# TODO: tie it into intro and self logic (why and which failed)
if {![file isdirectory $HOME]} { return false }
if {![file exists .ssh/id_rsa]} { return false }
if {0 == [glob -nocomplain -directory .gnupg/private-keys-v1.d *.key]} {
return false
}
if {![file exists .gitconfig]} { return false }
return true
}
set done_preq [check_prerequisites]
set done_user [check_user $USER]
intro $done_preq $done_user
prerequisites $done_preq
user $USER $done_user
package
boot
needless
system
basics
desktop
miscellany
stow
bulkies
kernel
opt
outro