Compare commits
No commits in common. "af796e700613643f1bfeef96bf5ad24369439dfe" and "4a5327ca0a4961b066c37f2e199458f21e373400" have entirely different histories.
af796e7006
...
4a5327ca0a
9 changed files with 10 additions and 48 deletions
28
README.md
28
README.md
|
@ -51,12 +51,8 @@ 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
|
||||||
|
@ -81,30 +77,14 @@ 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 will need it to allocate
|
after `argv[1]`, or `argv[1]` if it is free. You can compile it and add
|
||||||
ports to protocols like SPICE in your launching scripts (example in
|
it to your `PATH` if you need to allocate ports to protocols like SPICE in
|
||||||
`qemu/bin/*-spice`).
|
your launching scripts (example in `qemu/bin/*-spice`). Its source is in
|
||||||
|
`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}/launchers"
|
bin="${HOME}/bin"
|
||||||
images="${HOME}/images"
|
images="${HOME}/images"
|
||||||
PATH="${bin}:${HOME}/bin:${PATH}"
|
PATH="${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,8 +47,6 @@ ${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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,6 +76,10 @@ 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"
|
||||||
}
|
}
|
||||||
|
@ -120,24 +122,6 @@ 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
|
||||||
|
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
printf '%s/%s.qcow2\n' ~/images "$1"
|
|
Loading…
Reference in a new issue