mirror of
https://github.com/0xbbjubjub/miniguest.git
synced 2024-10-26 16:04:08 +03:00
Add create command
This commit is contained in:
parent
fbc8b279a6
commit
4aaef75fa7
36
miniguest/create.bash
Normal file
36
miniguest/create.bash
Normal file
@ -0,0 +1,36 @@
|
||||
source create_arg.bash
|
||||
|
||||
name="$_arg_guest_name"
|
||||
|
||||
set_color_red=$'\e[1m\e[31m'
|
||||
reset_color=$'\e(B\e[m'
|
||||
|
||||
case "${_arg_hypervisor:?}" in
|
||||
libvirt)
|
||||
cat <<EOF
|
||||
# Create $name using:
|
||||
virt-install \\
|
||||
--connect qemu:///system \\
|
||||
-n $name --os-variant nixos-unstable \\
|
||||
--memory 1536 \\
|
||||
--disk none \\
|
||||
--import \\
|
||||
--boot kernel=/etc/miniguests/$name/kernel,initrd=$guests_dir/$name/initrd \\
|
||||
--filesystem /nix/store,nix-store,readonly=yes,accessmode=squash \\
|
||||
--filesystem /etc/miniguests/$name/boot,boot,readonly=yes,accessmode=squash \\
|
||||
|
||||
EOF
|
||||
;;
|
||||
lxc)
|
||||
cat <<EOF
|
||||
#$set_color_red WARNING: make sure root is uid-mapped, otherwise you might experience store corruption in the host!$reset_color
|
||||
# Create $name using:
|
||||
lxc-create $name \\
|
||||
-f extra-config \\
|
||||
-t local -- \\
|
||||
-m @lxc_template@/meta.tar.xz \\
|
||||
-f @lxc_template@/rootfs.tar.xz \\
|
||||
|
||||
EOF
|
||||
;;
|
||||
esac
|
5
miniguest/create_arg.bash
Normal file
5
miniguest/create_arg.bash
Normal file
@ -0,0 +1,5 @@
|
||||
# ARG_POSITIONAL_SINGLE(guest-name, name of guest to create)
|
||||
# ARG_HELP(assist in creatig the guest by configuring the hypervisor)
|
||||
# ARG_OPTIONAL_SINGLE(hypervisor, t, hypervisor to configure, libvirt)
|
||||
# ARG_TYPE_GROUP_SET(hypervisors, HYPERVISOR, hypervisor, [libvirt,lxc])
|
||||
# ARGBASH_GO
|
@ -25,14 +25,18 @@ nix="$_arg_nix"
|
||||
|
||||
source functions.bash
|
||||
|
||||
set -- "${_arg_leftovers[@]}" # reset parameters to subcommand arguments
|
||||
case "${_arg_command:?}" in
|
||||
install)
|
||||
source install.bash "${_arg_leftovers[@]}"
|
||||
source install.bash
|
||||
;;
|
||||
upgrade)
|
||||
source upgrade.bash "${_arg_leftovers[@]}"
|
||||
source upgrade.bash
|
||||
;;
|
||||
remove)
|
||||
source remove.bash "${_arg_leftovers[@]}"
|
||||
source remove.bash
|
||||
;;
|
||||
create)
|
||||
source create.bash
|
||||
;;
|
||||
esac
|
||||
|
@ -16,7 +16,7 @@
|
||||
# along with Miniguest. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# ARG_POSITIONAL_SINGLE(command, subcommand to run)
|
||||
# ARG_TYPE_GROUP_SET(commands, COMMAND, command, [install,upgrade,remove,help])
|
||||
# ARG_TYPE_GROUP_SET(commands, COMMAND, command, [install,upgrade,remove,create,help])
|
||||
# ARG_OPTIONAL_SINGLE(guests-dir, , directory containing guests profiles, /etc/miniguests)
|
||||
# ARG_OPTIONAL_SINGLE(nix, , path to the nix binary, @nixFlakes@/bin/nix)
|
||||
# ARG_LEFTOVERS(subcommand arguments)
|
||||
|
@ -17,7 +17,8 @@
|
||||
stdenvNoCC.mkDerivation {
|
||||
name = "miniguest";
|
||||
src = ./.;
|
||||
inherit bash miniguest-lxc-template nixFlakes;
|
||||
inherit bash nixFlakes;
|
||||
lxc_template = miniguest-lxc-template;
|
||||
|
||||
nativeBuildInputs = [ argbash makeWrapper ];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user