qemush : ajout fonction depcheck et documentation, ajout module diskpath

This commit is contained in:
Ahurac 2023-12-08 11:23:41 +01:00
parent 49cc450c34
commit a9bc223f98
3 changed files with 31 additions and 0 deletions

View file

@ -51,8 +51,12 @@ need it
- `screen` - for process supervision
- `source-highlight` - for syntax highlighting when displaying launching
scripts
- `diskpath` - see [Installation instructions](#installation-instructions)
[Add `qemush` modules in `~qemu/bin`](#add-qemush-modules-in-qemubin)
- any text editor - used for builtin function to edit launching scripts
You can run `qemush depcheck` to check if all dependencies are met.
## Installation instructions
### QEMU user and group
@ -77,6 +81,16 @@ Use your preferred way to add the `qemush` script to a folder of `PATH`.
Recommended: copy the script in `/usr/local/bin` to make it effortlessly
system wide.
### Add `qemush` modules in `~qemu/bin`
`qemush` needs reusable script modules like `diskpath` in its custom `bin`
folder located at `~qemu/bin`. You can add them directly via `qemush` from
this repo via the following command :
```sh
qemush run 'mkdir -p ~/bin && cp -v qemu/bin/*'
```
### Extra: add `first-free-port` in `PATH`
`first-free-port` is a small C program designed accordingly to the Unix

View file

@ -48,6 +48,7 @@ ${name}: usage:
${name} help - show this help
${name} add <path to script> [<VM name>] - add a launching script
${name} run <command> - run shell input as user qemu
${name} depcheck - check if script dependencies are met
EOF
}
@ -127,6 +128,20 @@ public_run() {
exec sh -c "$*"
}
bold_print() {
printf '\033['"${1}m${2}"'\033[0m: %s\n' "$3"
}
public_depcheck() {
for i in diskpath screen ls diskpath source-highlight; do
if command -v "$i" > /dev/null; then
bold_print '1;32' OK "$i"
else
bold_print '1;31' KO "$i"
fi
done
}
function="$1"
shift

2
qemu/bin/diskpath Executable file
View file

@ -0,0 +1,2 @@
#!/bin/sh
printf '%s/%s.qcow2\n' ~/images "$1"