-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathkenobi
More file actions
executable file
·323 lines (304 loc) · 14.7 KB
/
Copy pathkenobi
File metadata and controls
executable file
·323 lines (304 loc) · 14.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
#!/bin/bash
# Puny-Wan Kenobi - Updater, Installer & Permissions Editor
# Puny BuildTools, (c) 2026 Stefan Vogt
#
# version 2.0
echo "Puny-Wan Kenobi 2.0 - the update is strong with this one"
echo -e "Puny BuildTools, (c) 2026 Stefan Vogt\n"
if ! [ -d ~/FictionTools ]; then
echo -e "'FictionTools' folder not found in home directory. Aborting program.\n"
exit 1
fi
while getopts ':puhci' opts
do
case $opts in
u) # update
echo -e "initiating Puny BuildTools update [...]\n"
workingDir=$(pwd)
cd ~/FictionTools
git pull
cd "${workingDir}"
echo
exit 0
;;
c) # check permissions
echo -e "checking component permissions [...]\n"
workingDir=$(pwd)
cd ~/FictionTools
printf "puny CLI -> "
[ -x puny ] && printf "okay... executable bit is set\n" || printf "error... not executable\n"
printf "pi6 -> "
[ -x pi6 ] && printf "okay... executable bit is set\n" || printf "error... not executable\n"
printf "bundle.sh -> "
[ -x Templates/Resources/bundle.sh ] && printf "okay... executable bit is set\n" || printf "error... not executable\n"
printf "ifftool.sh -> "
[ -x ifftool.sh ] && printf "okay... executable bit is set\n" || printf "error... not executable\n"
printf "cpcscr.sh -> "
[ -x cpcscr.sh ] && printf "okay... executable bit is set\n" || printf "error... not executable\n"
printf "degaspi1.sh -> "
[ -x degaspi1.sh ] && printf "okay... executable bit is set\n" || printf "error... not executable\n"
printf "makescr.sh -> "
[ -x scrload/makescr.sh ] && printf "okay... executable bit is set\n" || printf "error... not executable\n"
echo -e "\nchecking a few module permissions [...]\n"
printf "dos.sh -> "
[ -x Templates/dos.sh ] && printf "okay... executable bit is set\n" || printf "error... not executable\n"
printf "amiga.sh -> "
[ -x Templates/amiga.sh ] && printf "okay... executable bit is set\n" || printf "error... not executable\n"
printf "all.sh -> "
[ -x Templates/Resources/all.sh ] && printf "okay... executable bit is set\n" || printf "error... not executable\n"
echo -e "\nShould you notice errors here or encounter issues regarding permissions"
echo -e "when working with the Puny BuildTools, run 'kenobi -p' to fix them."
cd "${workingDir}"
echo
exit 0
;;
p) # set permissions
echo -e "setting permissions may take a while [...]\n"
workingDir=$(pwd)
cd ~/FictionTools
echo "-> applying permissions to directories..."
find . -type d -exec chmod 0755 {} \;
echo "-> applying permissions to binaries and scripts..."
find . -type f -exec chmod 0755 {} \;
echo "-> applying permissions to files..."
find . -name "LICENSE" -exec chmod 0644 {} \;
find . -name "README" -exec chmod 0644 {} \;
find . -name "*.txt" -exec chmod 0644 {} \;
find . -name "*.md" -exec chmod 0644 {} \;
find . -name "*.c" -exec chmod 0644 {} \;
find . -name "*.h" -exec chmod 0644 {} \;
find . -name "*.asm" -exec chmod 0644 {} \;
find . -name "*.fnt" -exec chmod 0644 {} \;
find . -name "*.bin" -exec chmod 0644 {} \;
find . -name "*.dsk" -exec chmod 0644 {} \;
find . -name "*.DSK" -exec chmod 0644 {} \;
find . -name "*.cpm" -exec chmod 0644 {} \;
find . -name "*.adf" -exec chmod 0644 {} \;
find . -name "*.d64" -exec chmod 0644 {} \;
find . -name "*.d71" -exec chmod 0644 {} \;
find . -name "*.d81" -exec chmod 0644 {} \;
find . -name "*.EXE" -exec chmod 0644 {} \;
find . -name "*.exe" -exec chmod 0644 {} \;
find . -name "*.BAS" -exec chmod 0644 {} \;
find . -name "*.bas" -exec chmod 0644 {} \;
find . -name "*.CFG" -exec chmod 0644 {} \;
find . -name "*.BIN" -exec chmod 0644 {} \;
find . -name "*.BAT" -exec chmod 0644 {} \;
find . -name "*.bat" -exec chmod 0644 {} \;
find . -name "*.def" -exec chmod 0644 {} \;
find . -name "z3-*" -exec chmod 0644 {} \;
find . -name "*.png" -exec chmod 0644 {} \;
find . -name "*.dot" -exec chmod 0644 {} \;
find . -name "*.pdf" -exec chmod 0644 {} \;
find . -name "*.z3" -exec chmod 0644 {} \;
find . -name "*.z5" -exec chmod 0644 {} \;
find . -name "*.inf" -exec chmod 0644 {} \;
find . -name "*.info" -exec chmod 0644 {} \;
find . -name "*.zasm" -exec chmod 0644 {} \;
find . -name "*.rec" -exec chmod 0644 {} \;
find . -name "*.gif" -exec chmod 0644 {} \;
find . -name "*.out*" -exec chmod 0644 {} \;
find . -name "*.inc" -exec chmod 0644 {} \;
find . -name "*.yaml" -exec chmod 0644 {} \;
find . -name "*.yml" -exec chmod 0644 {} \;
find . -name "*.man" -exec chmod 0644 {} \;
find . -name "*.html" -exec chmod 0644 {} \;
find . -name "*.l" -exec chmod 0644 {} \;
find . -name "*.pu" -exec chmod 0644 {} \;
find . -name "*.lst" -exec chmod 0644 {} \;
find . -name "makefile" -exec chmod 0644 {} \;
find . -name "Makefile" -exec chmod 0644 {} \;
find . -name "*.dsp" -exec chmod 0644 {} \;
find . -name "*.svg" -exec chmod 0644 {} \;
find . -name "*.cpp" -exec chmod 0644 {} \;
find . -name "*.cmd" -exec chmod 0644 {} \;
find . -name "*.mingw" -exec chmod 0644 {} \;
find . -name "*.ans" -exec chmod 0644 {} \;
find . -name "*.bak" -exec chmod 0644 {} \;
find . -name "*.tmp" -exec chmod 0644 {} \;
find . -name "*.COM" -exec chmod 0644 {} \;
find . -name "*.com" -exec chmod 0644 {} \;
find . -name "*.old" -exec chmod 0644 {} \;
find . -name "*.OLD" -exec chmod 0644 {} \;
find . -name "*.vdk" -exec chmod 0644 {} \;
find . -name "dragondos_header" -exec chmod 0644 {} \;
find . -name "dragon_bytefill" -exec chmod 0644 {} \;
find . -name "*.prg" -exec chmod 0644 {} \;
find . -name "*.PRG" -exec chmod 0644 {} \;
find . -name "*.16" -exec chmod 0644 {} \;
find . -name "*.256" -exec chmod 0644 {} \;
find . -name "*.seq" -exec chmod 0644 {} \;
find . -name "*.APP" -exec chmod 0644 {} \;
find . -name "Makefile*" -exec chmod 0644 {} \;
chmod 644 .punyrc
chmod 644 .punywsl
chmod 644 .gitignore
chmod 644 Templates/Resources/config.sh
echo -e "-> done.\n"
cd "${workingDir}"
exit 0
;;
i) # install
echo -e "preparing the Puny BuildTools installation [...]\n"
# the Puny BuildTools must live in ~/FictionTools, since kenobi
# resides inside the repository it cannot relocate itself.
scriptDir="$(cd "$(dirname "$0")" && pwd)"
if [ "$scriptDir" != "$HOME/FictionTools" ]; then
echo -e "The Puny BuildTools must reside in '~/FictionTools'."
echo -e "Please clone the repository into '~/FictionTools' and run the"
echo -e "installer from there. Aborting program.\n"
exit 1
fi
cd "$HOME/FictionTools"
# --- 1. dependencies ------------------------------------------------
echo -e "The following packages will be installed via apt:\n"
echo -e " frotz cpmtools dosfstools mtools git ruby imagemagick zip"
echo -e " libsdl1.2debian libsdl2-2.0-0 python-is-python3 libgl1\n"
read -r -p "Install these dependencies now? [y/N] " reply
if [[ "$reply" =~ ^[Yy]$ ]]; then
sudo apt update && sudo apt install -y frotz cpmtools dosfstools mtools git ruby imagemagick zip libsdl1.2debian libsdl2-2.0-0 python-is-python3 libgl1
if [ $? -ne 0 ]; then
echo -e "\nerror: the dependencies could not be installed. Aborting program.\n"
exit 1
fi
else
echo -e "\nThe dependencies are required to proceed. Aborting program.\n"
exit 1
fi
# --- 2. shell environment (.bashrc) ---------------------------------
echo -e "\nconfiguring your shell environment [...]"
echo -e "(auto-detecting your host system: Linux, macOS/OrbStack or WSL2)\n"
bashrc="$HOME/.bashrc"
addSource () {
if grep -qxF "$1" "$bashrc" 2>/dev/null; then
echo "-> already present: $1"
else
echo "$1" >> "$bashrc"
echo "-> added: $1"
fi
}
addSource "source ~/FictionTools/.punyrc"
kernel="$(uname -r)"
if echo "$kernel" | grep -qi "orbstack"; then
echo "-> detected macOS host (OrbStack)"
addSource "source ~/FictionTools/.punyorb"
elif echo "$kernel" | grep -qi "microsoft"; then
echo "-> detected Windows host (WSL2)"
addSource "source ~/FictionTools/.punywsl"
else
echo "-> detected native Linux host"
fi
# --- 3. cpmtools diskdefs (SAM Coupe / DEC Rainbow) -----------------
echo -e "\nteaching cpmtools about SAM Coupe and DEC Rainbow disks [...]\n"
diskdefs="/etc/cpmtools/diskdefs"
if sudo grep -q "diskdef prodos" "$diskdefs" 2>/dev/null; then
echo "-> diskdefs already configured, skipping"
else
read -r -p "Append the required diskdefs to $diskdefs (requires sudo)? [y/N] " reply
if [[ "$reply" =~ ^[Yy]$ ]]; then
sudo tee -a "$diskdefs" > /dev/null <<'EOF'
diskdef prodos
seclen 512
tracks 160
sectrk 9
maxdir 256
blocksize 2048
boottrk 1
skew 0
os 2.2
end
# DEC2 DEC Rainbow - SSDD 96 tpi 5.25" - 512 x 10
diskdef dec2
seclen 512
tracks 80
sectrk 10
blocksize 2048
maxdir 128
skew 2
boottrk 2
os 2.2
end
EOF
if [ $? -ne 0 ]; then
echo -e "\nerror: could not write to $diskdefs. Aborting program.\n"
exit 1
fi
echo "-> diskdefs configured"
else
echo -e "\nThe diskdefs are required to proceed. Aborting program.\n"
exit 1
fi
fi
# --- 4. PunyInform path (.pi6rc) -----------------------------------
echo -e "\nconfiguring the path to your PunyInform library [...]\n"
pi6rc="$HOME/FictionTools/.pi6rc"
current="$(grep -E '^lib=' "$pi6rc" 2>/dev/null | head -1 | cut -d'=' -f2-)"
if [ -n "$current" ]; then
echo -e "A PunyInform path is already set:\n $current\n"
read -r -p "Press Enter to keep it, or type a new path to replace it: " newpath
else
read -r -p "Enter the path to your PunyInform 'lib' directory (trailing slash required): " newpath
fi
if [ -n "$newpath" ]; then
expanded="${newpath/#\~/$HOME}"
if [ ! -d "$expanded" ]; then
echo -e "warning: '$newpath' does not exist as a directory."
read -r -p "Use it anyway? [y/N] " reply
[[ "$reply" =~ ^[Yy]$ ]] || { echo -e "Aborting program.\n"; exit 1; }
fi
if grep -qE '^lib=' "$pi6rc" 2>/dev/null; then
sed -i "s|^lib=.*|lib=$newpath|" "$pi6rc"
else
echo "lib=$newpath" >> "$pi6rc"
fi
echo "-> PunyInform path set to: $newpath"
elif [ -z "$current" ]; then
echo -e "error: no PunyInform path provided. Aborting program.\n"
exit 1
else
echo "-> keeping existing PunyInform path"
fi
# --- 5. permission self-check --------------------------------------
echo -e "\nverifying component permissions [...]\n"
permIssues=0
for f in puny pi6 Templates/Resources/bundle.sh ifftool.sh cpcscr.sh \
degaspi1.sh scrload/makescr.sh Templates/dos.sh \
Templates/amiga.sh Templates/Resources/all.sh; do
if [ ! -x "$f" ]; then
echo " not executable: $f"
permIssues=$((permIssues + 1))
fi
done
if [ "$permIssues" -eq 0 ]; then
echo "-> permissions check passed, all components are go."
else
echo -e "-> $permIssues component(s) need attention."
echo -e " run 'kenobi -p' to fix them, then 'kenobi -i' again."
fi
# --- done ----------------------------------------------------------
echo -e "\nThe installation is complete."
echo -e "Please close this terminal and open a new one so your shell"
echo -e "changes take effect.\n"
exit 0
;;
h)
echo -e "Provides updates via Git and uses the force to install \nthe Puny Buildtools and edit permissions.\n"
echo -e "Switches:"
echo -e " [kenobi -u] -> initate update"
echo -e " fetches the latest changes from the Puny BuildTools repository\n"
echo -e " [kenobi -c] -> check permissions"
echo -e " checks if the bundled applications have the right permissions\n"
echo -e " [kenobi -p] -> edit permissions"
echo -e " sets and fixes permissions for all bundled applications\n"
echo -e " [kenobi -i] -> install the Puny BuildTools"
echo -e " guides you through the full installation on a fresh system\n"
echo -e " [kenobi -h] -> show this help menu\n"
;;
*)
echo -e "Wrong argument passed.\nType: $(basename $0) [-h] for help.\n"
exit 0
;;
esac
done
if [ $OPTIND -eq 1 ]; then echo -e "Nothing to be done. No options passed. Use [-h] for help.\n"; fi
shift "$(($OPTIND -1))"