From a9bc223f985e63ca7acee2b16ca7911bbcdaad1a Mon Sep 17 00:00:00 2001 From: Ahurac Date: Fri, 8 Dec 2023 11:23:41 +0100 Subject: [PATCH] qemush : ajout fonction depcheck et documentation, ajout module diskpath --- README.md | 14 ++++++++++++++ bin/qemush | 15 +++++++++++++++ qemu/bin/diskpath | 2 ++ 3 files changed, 31 insertions(+) create mode 100755 qemu/bin/diskpath diff --git a/README.md b/README.md index 99904cc..147a7a6 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/bin/qemush b/bin/qemush index 3f0d10e..7745c30 100755 --- a/bin/qemush +++ b/bin/qemush @@ -48,6 +48,7 @@ ${name}: usage: ${name} help - show this help ${name} add [] - add a launching script ${name} run - 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 diff --git a/qemu/bin/diskpath b/qemu/bin/diskpath new file mode 100755 index 0000000..98e5dd7 --- /dev/null +++ b/qemu/bin/diskpath @@ -0,0 +1,2 @@ +#!/bin/sh +printf '%s/%s.qcow2\n' ~/images "$1"