Compare commits
6 commits
4a5327ca0a
...
af796e7006
Author | SHA1 | Date | |
---|---|---|---|
af796e7006 | |||
57f211a41b | |||
829cbbc98e | |||
a9bc223f98 | |||
49cc450c34 | |||
00b9c552ca |
9 changed files with 48 additions and 10 deletions
28
README.md
28
README.md
|
@ -51,8 +51,12 @@ need it
|
||||||
- `screen` - for process supervision
|
- `screen` - for process supervision
|
||||||
- `source-highlight` - for syntax highlighting when displaying launching
|
- `source-highlight` - for syntax highlighting when displaying launching
|
||||||
scripts
|
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
|
- 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
|
## Installation instructions
|
||||||
|
|
||||||
### QEMU user and group
|
### QEMU user and group
|
||||||
|
@ -77,14 +81,30 @@ 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
|
Recommended: copy the script in `/usr/local/bin` to make it effortlessly
|
||||||
system wide.
|
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`
|
### Extra: add `first-free-port` in `PATH`
|
||||||
|
|
||||||
`first-free-port` is a small C program designed accordingly to the Unix
|
`first-free-port` is a small C program designed accordingly to the Unix
|
||||||
philosophy to show in `stdout` the first free (not listening) TCP port
|
philosophy to show in `stdout` the first free (not listening) TCP port
|
||||||
after `argv[1]`, or `argv[1]` if it is free. You can compile it and add
|
after `argv[1]`, or `argv[1]` if it is free. You will need it to allocate
|
||||||
it to your `PATH` if you need to allocate ports to protocols like SPICE in
|
ports to protocols like SPICE in your launching scripts (example in
|
||||||
your launching scripts (example in `qemu/bin/*-spice`). Its source is in
|
`qemu/bin/*-spice`).
|
||||||
`src` folder of this repository.
|
|
||||||
|
Example `qemush` command to add the program to a local `qemu` `bin` folder
|
||||||
|
:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
qemush do 'mkdir ~/bin && cc -o "${_}/first-free-port" src/first-free-port.c'
|
||||||
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
|
28
bin/qemush
28
bin/qemush
|
@ -12,9 +12,9 @@ exec_as() {
|
||||||
|
|
||||||
exec_as qemu "$@"
|
exec_as qemu "$@"
|
||||||
|
|
||||||
bin="${HOME}/bin"
|
bin="${HOME}/launchers"
|
||||||
images="${HOME}/images"
|
images="${HOME}/images"
|
||||||
PATH="${bin}:${PATH}"
|
PATH="${bin}:${HOME}/bin:${PATH}"
|
||||||
EDITOR="${EDITOR:-nvim}"
|
EDITOR="${EDITOR:-nvim}"
|
||||||
alias ls='ls --color=auto'
|
alias ls='ls --color=auto'
|
||||||
alias exec='exec '
|
alias exec='exec '
|
||||||
|
@ -47,6 +47,8 @@ ${name}: usage:
|
||||||
${name} shell - start a shell as user qemu
|
${name} shell - start a shell as user qemu
|
||||||
${name} help - show this help
|
${name} help - show this help
|
||||||
${name} add <path to script> [<VM name>] - add a launching script
|
${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
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,10 +78,6 @@ public_ls() {
|
||||||
exec ls "$bin"
|
exec ls "$bin"
|
||||||
}
|
}
|
||||||
|
|
||||||
diskpath() {
|
|
||||||
printf "%s.qcow2" "${images}/${1}"
|
|
||||||
}
|
|
||||||
|
|
||||||
public_diskadd() {
|
public_diskadd() {
|
||||||
exec qemu-img create -f qcow2 "$(diskpath "$1")" "$2"
|
exec qemu-img create -f qcow2 "$(diskpath "$1")" "$2"
|
||||||
}
|
}
|
||||||
|
@ -122,6 +120,24 @@ public_add() {
|
||||||
trap - EXIT
|
trap - EXIT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public_run() {
|
||||||
|
exec sh -c "$*"
|
||||||
|
}
|
||||||
|
|
||||||
|
bold_print() {
|
||||||
|
printf '\033['"${1}m${2}"'\033[0m: %s\n' "$3"
|
||||||
|
}
|
||||||
|
|
||||||
|
public_depcheck() {
|
||||||
|
for i in diskpath screen diskpath source-highlight ls rm cp chmod cat; 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"
|
function="$1"
|
||||||
shift
|
shift
|
||||||
|
|
||||||
|
|
2
qemu/bin/diskpath
Executable file
2
qemu/bin/diskpath
Executable file
|
@ -0,0 +1,2 @@
|
||||||
|
#!/bin/sh
|
||||||
|
printf '%s/%s.qcow2\n' ~/images "$1"
|
Loading…
Reference in a new issue