added autoenv

This commit is contained in:
Leon van Kammen 2024-12-13 14:31:33 +01:00
parent 9442cde73e
commit 99c9256e89
15 changed files with 66 additions and 29 deletions

View File

@ -15,6 +15,14 @@ filesystem overlay, and scripts necessary to build our distribution.
## Running ISO via qemu
first enable the vga console:
```bash
echo "console::respawn:-/bin/sh # vga console" >> rootfs/etc/inittab
```
then run qemu:
```
qemu-system-i386 -cdrom dist/v86-linux.iso
```
@ -220,3 +228,5 @@ CONFIG_VIRTIO_PCI=y
Now run `make`
When it finishes, the built image is in `./output/images`.
> to debug (gdb access) uncomment the debug-section in `buildroot_v86/configs/v86_defconfig`, run `make` and then `./run.sh`

View File

@ -26,8 +26,8 @@
::sysinit:/etc/init.d/rcS
# Put a getty on the serial port
#console::respawn:/sbin/getty -L console 0 vt100 # GENERIC_SERIAL
console::respawn:-/bin/sh # vga console
console::respawn:/sbin/getty -L console 0 vt100 # GENERIC_SERIAL
#console::respawn:-/bin/sh # vga console
# Auto-login as root on ttyS0
::respawn:/sbin/getty ttyS0 38400 xterm -n -l /bin/sh

View File

@ -22,24 +22,16 @@ alert(){
confirm(){
test -z "$1" && { echo "usage: confirm <question>"; return 0; }
if test -n "$BROWSER"; then
jsh confirm "$1"
else
read -p "$(printf "\033[0m")[?] $1 [y/n] $(printf "\033[0m")" y
fi
test $y = y && echo true && return 0
test $y = y || echo false
read -p "$(printf "\033[0m")[?] $1 [y/n] $(printf "\033[0m")" y
test $y = "y" && echo true && return 0
test $y = "y" || echo false
hook confirm $1 $y
}
prompt(){
test -z "$1" && { echo "usage: prompt <question> [answer_default]"; return 0; }
test -n "$2" && answer="[$2] " && answer_fallback="$2"
if test -n "$BROWSER"; then
jsh prompt "$1" "$answer_fallback"
else
read -p "$(printf "\033[0m")[?] $1: $answer $(printf "\033[0m")" answer
fi
read -p "$(printf "\033[0m")[?] $1: $answer $(printf "\033[0m")" answer
test -z "$answer" && answer="$answer_fallback"
echo "$answer"
hook prompt $1 $answer

View File

@ -51,8 +51,8 @@ test -d /dev/browser || {
}
setup_listen_homedir(){
sleep 4 # wait for inode of /mnt/root to become live (due to move_root_to_9pfs)
/mnt/root/bin/watchfs &
sleep 4
/root/bin/watchfs &
}
setup_mounts(){
@ -67,8 +67,7 @@ test -d /dev/browser || {
setup_links
setup_network
setup_overlayfs
setup_listen_homedir &
setup_incoming_cmds &
setup_listen_homedir
setup_mounts
cat /etc/motd
}

View File

@ -0,0 +1 @@
echo "$(pwd): the project root-directory"

View File

@ -8,14 +8,19 @@ alias curl="wget -q -O - "
alias make="mim"
# minimalist autoenv version [https://github.com/hyperupcall/autoenv]
#cd(){
# test -f $(pwd)/.env.leave && source $(pwd)/.env.leave # cleanup environment
# command cd ${1:+"$@"} && {
# hook cd "$@"
# test -f $(pwd)/.env && source $(pwd)/.env # setup environment / run scripts e.g.
# ls # list directories
# }
#}
cd(){
test -f $(pwd)/.env.leave && source $(pwd)/.env.leave # cleanup environment
command cd ${1:+"$@"} && {
hook cd "$@"
test -f $(pwd)/.env && { # setup environment / run scripts e.g.
test "$(cat ~/.config/autoenv/prompt_cd)" = 1 && {
if "$(confirm ".env detected, execute?")" = false; then return 0; fi
}
source $(pwd)/.env
}
ls # list directories
}
}
# start index.js if /dev/browser/js filesize is not great than 0
if [ ! -s /dev/browser/js ]; then

View File

@ -0,0 +1 @@
echo "$(pwd): projectspecific cli utilities"

View File

@ -0,0 +1,3 @@
#!/bin/sh
# simple directory annotator [via autoenv]
echo "echo \"$(pwd): $*\"" >> .env

View File

@ -0,0 +1 @@
echo "$(pwd): 'fusescript' filesystems https://codeberg.org/coderofsalvation/fusescript"

View File

@ -0,0 +1,2 @@
echo "$(pwd): polyglot hooks https://xrsh.isvery.ninja/#Unixy%20event%20hooks"

View File

@ -9,8 +9,8 @@ mkdir -p "/root/$dir"
cd "/root/$dir"
unzip "$file"
test -x .env && {
test -f .env && test "$(cat ~/.config/autoenv/package)" = 1 && {
logger "$0: detected $(pwd)/.env [autoenv]"
logger "$0: running $(pwd)/.env"
source .env
sh .env
}

View File

@ -0,0 +1,11 @@
#!/bin/sh
# this detects when a zip-url is copy/pasted to the clipboard
# and forwards it the zip mimetype hook
test -f /etc/profile.sh && source /etc/profile.sh
file="$1"
grep -E '^http.*\.zip$' "$file" &>/dev/null && {
file="$(cat $file)"
zip="${file/.*\/\//}"
wget "$zip" && hook clipboard $(pwd)/$(basename "$zip") application/zip
}

View File

@ -111,7 +111,17 @@ It can be loaded in various ways into [your own instance of] https://xrsh.isvery
The package follows the popular `autoenv`-paradigm (a file called `.env` is automatically executed).
Currently, '.env' links to 'bin/app.sh', but there are also other scriptinglanguages it could link to as well (see bin-folder).
> see example package at https://xrsh.isvery.ninja/package.zip
> see example package at https://xrsh.isvery.ninja/package.zip, and an filesystem overlay-zip
> at https://xrsh.isvery.ninja/package.overlayfs.zip
# Autoenv (.env)
When a directory contains an .env-file, it is automatically sourced.
* run echo 0 > ~/.config/autoenv/package to disable auto-execution of zip-packages
* run echo 1 > ~/.config/autoenv/prompt_cd to trigger a confirmation when cd-ing into a directory.
> TIP: check out `~/bin/annotate` to annotate directories using the power of autoenv
# Hooks