This repository has been archived by the owner on Sep 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.ksh
229 lines (199 loc) · 5.46 KB
/
setup.ksh
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
#!/bin/ksh
# Constants
USERHOME=$HOME
GITHUB="https://github.com"
SLEEPTIME=2
LOG_FILE="/tmp/setup.log";
# Set PATH explicitly
export PATH='/bin:/usr/bin:/sbin:/usr/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin:$HOME/bin';
# Log setup messages with timestamp
function exception {
error=$1
echo "Error: $error"
exit 1
}
function log {
message=$1
timestamp=$(date +"%Y%m%d%H%M%S")
echo "[$timestamp] $message"
echo "[$timestamp] $message" >> "$LOG_FILE" 2>&1 || exception "Could not write to $LOG_FILE"
}
# Clean unnecessary files
function clean {
log "Removing Cruft..."
rex remove_default_cruft
}
# Ensure Lisp environment is set up
function ensure_lisp {
log "Quicklisp Setup"
doas pkg_add -m sbcl rlwrap || exception "Could not install sbcl or rlwrap"
ftp -o /tmp/quicklisp.lisp "https://beta.quicklisp.org/quicklisp.lisp" || exception "Failed to download quicklisp.lisp"
ftp -o /tmp/quicklisp-setup.lisp "$GITHUB/izder456/dotfiles/raw/main/quicklisp-setup.lisp" || exception "Failed to download quicklisp-setup.lisp"
sbcl --load /tmp/quicklisp.lisp --script /tmp/quicklisp-setup.lisp || exception "Failed to run quicklisp setup"
}
# Install port dependencies
function ports_deps {
log "Installing port dependencies..."
doas pkg_add -m -l ~/.pkglist || exception "Failed to install port dependencies"
}
# Install cargo dependencies
function cargo_deps {
log "Installing cargo dependencies..."
doas pkg_add rust || exception "Failed to install Rust"
xargs cargo install < ~/.cargolist || exception "Failed to install cargo dependencies"
}
# Clone or update dotfiles repository and run setup scripts
function config_install {
log "Cloning/Installing Dotfiles..."
if [ -d "$USERHOME/.dotfiles" ]; then
cd $USERHOME/.dotfiles || exception "Failed to change directory to .dotfiles"
git pull --recurse-submodules --depth 1 || exception "Failed to pull dotfiles"
else
git clone --depth 1 --recurse-submodules $GITHUB/Izder456/dotfiles.git $USERHOME/.dotfiles || exception "Failed to clone dotfiles"
fi
rex configure_gtk
rex configure_icons
$USERHOME/.dotfiles/dfm/dfm install
doas cp ~/.dotfiles/doas.conf /etc/doas.conf
}
# Setup FiZSH shell
function setup_shell {
log "Setting up FiZSH..."
rex configure_default_shell
rex compile_afetch
}
# Setup URxvt
function setup_urxvt {
log "Setting up urxvt..."
rex configure_urxvt
}
# Setup background images
function setup_backgrounds {
log "Installing Backgrounds..."
rex install_backgrounds
}
# Setup Emacs
function setup_emacs {
log "Setting up Emacs..."
rex configure_emacs
}
# Setup Enhanced Motif WM
function setup_emwm {
log "Setting up Enhanced Motif WM..."
rex configure_emwm
}
# Setup StumpWM
function setup_stumpwm {
ensure_lisp
log "Setting up StumpWM..."
rex configure_stumpwm
}
# Miscellaneous setup tasks
function setup_misc {
setup_shell
log "Miscellaneous setup..."
rex compile_shuf
rex compile_slock
rex compile_st
rex compile_surf
rex compile_nxbelld
rex configure_apmd
rex install_backgrounds
rex update_xdg_user_dirs
}
# Setup XenoDM
function setup_xenodm {
log "Setting up XenoDM..."
rex configure_xenodm
}
# Check for internet connection
function is_internet_up {
log "Checking internet connection..."
nc -zw1 OpenBSD.org 443 || exception "You need internet for this dumdum!";
log "Internet connection is up!"
}
# Ensure necessary tools are installed
function ensure_needed {
log "Installing necessary tools: git and p5-Rex..."
doas pkg_add -m p5-Rex git || exception "Failed to install git and p5-Rex"
ftp -o $USERHOME/Rexfile $GITHUB/Izder456/dotfiles/raw/main/Rexfile || exception "Failed to download Rexfile"
}
# Ensure all prerequisites
function do_ensure {
is_internet_up
ensure_needed
}
do_ensure
# Menu header text
# Display menu and handle user input
function menu {
while true; do
clear
echo 'Srcerizder Dotfiles Setup'
echo 'Options:'
echo '--------------------------'
echo '1) Ports 4) StumpWM'
echo '2) Cargo 5) Emacs'
echo '3) Emwm 6) Xenodm'
echo '7) Config 8) Misc'
echo '9) Clean:'
echo
echo 'Other Options:'
echo '----------------'
echo 'a) All'
echo 'r) Reload Menu'
echo 'q) Quit'
echo
echo "Enter your selection: "
read selection # Move the input prompt to the same line
[ -z $selection ] && selection="r"
case $selection in
1)
echo "Selected Ports Deps..."; sleep $SLEEPTIME; ports_deps;
;;
2)
echo "Selected Cargo Deps..."; sleep $SLEEPTIME; cargo_deps;
;;
3)
echo "Selected Emwm Config..."; sleep $SLEEPTIME; setup_emwm;
;;
4)
echo "Selected StumpWM-Config..."; sleep $SLEEPTIME; setup_stupmwm;
;;
5)
echo "Selected Emacs-Config..."; sleep $SLEEPTIME; setup_emacs;
;;
6)
echo "Selected XenoDM-Config..."; sleep $SLEEPTIME; setup_emacs;
;;
7)
echo "Selected Install Configs..."; sleep $SLEEPTIME; config_install;
;;
8)
echo "Selected Misc Setup..."; sleep $SLEEPTIME; setup_misc;
;;
9)
echo "Selected Clean..."; sleep $SLEEPTIME; clean;
;;
"a")
echo "Running All...";
sleep $SLEEPTIME; clean;
config_install; ports_deps; cargo_deps;
setup_emwm; setup_stumpwm; setup_urxvt; setup_emacs; setup_xenodm;
setup_misc;
;;
"r")
continue;
;;
"q")
echo "";
exit;
;;
*)
echo "Invalid selection";
sleep $SLEEPTIME;
;;
esac
done
}
menu