Editing
Main Page
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==== lxcreate script --> ==== <syntaxhighlight lang="bash" copy class="mw-collapsible mw-collapsed"> #!/bin/sh # Check if alias and ip are provided as arguments if [ -z "$2" ]; then echo "Usage: $0 <alias> <ip> <env> [mem=64] [swap=256] [image_uuid=0b7d45d9-be8c-439f-9a24-bd6223199c2b]" echo "NOTE: alias is used for docker image, by default alias:latest is used" echo "IE: docker run alias:latest" echo "ex: $0 mediawiki 192.168.3.123/24" echo "ex: $0 mediawiki 192.168.3.123/24 NODE_ENV=development" echo "ex: $0 mediawiki 192.168.3.123/24 NODE_ENV=development 128 256" exit 1 fi # Assign arguments to variables alias="$1" ip="$2" env="$3" mem="${4:-64}" # Default to 64 if mem not provided swap="${5:-256}" # Default to 256 if swap not provided #image_uuid=$(imgadm avail -H -o uuid name=~alpine type=~lx | tail -n1) # Default to latest alpine lx #image_uuid="${8:-$(imgadm avail -H -o uuid name=~alpine type=~lx | tail -n1)}" # Default to alpine 2025-01-20 image_uuid="${6:-0b7d45d9-be8c-439f-9a24-bd6223199c2b}" image=$(imgadm list -H -o uuid uuid=~0b7d45d9-be8c-439f-9a24-bd6223199c2b) if [ -z "$image" ]; then imgadm import $image_uuid fi # Basic IP CIDR validation (eg, 192.168.3.123/24) if ! echo "$ip" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/[0-9]+$'; then echo "Error: IP must be in CIDR format (e.g., 192.168.3.123/24) or 'dhcp'" exit 1 fi echo "Fetching $alias:latest..." if [ -z "$env" ]; then ssh apod "podman run -d --rm --name $alias $alias:latest" else ssh apod "podman run -d --rm --name $alias -e $env $alias:latest" fi dir=$(ssh apod "podman inspect $alias | jq -r '.[0].Config | .WorkingDir'") env=$(ssh apod "podman inspect $alias | jq -r '.[0].Config.Env'" | tr -s '\n' ' ' | sed 's/"/\\"/g') cmd=$(ssh apod "podman inspect $alias | jq -r '.[0].Config.Cmd'" | tr -s '\n' ' ' | sed 's/"/\\"/g') entry=$(ssh apod "podman inspect $alias | jq -r '.[0].Config.Entrypoint'" | tr -s '\n' ' ' | sed 's/"/\\"/g') vmadm create << EOF { "brand": "lx", "kernel_version": "5.15", "autoboot": true, "docker": true, "internal_metadata": { "docker:workingdir": "${dir}", "docker:env": "${env}", "docker:cmd": "${cmd}", "docker:entrypoint": "${entry}" }, "image_uuid": "${image_uuid}", "alias": "${alias}","hostname": "${alias}", "max_physical_memory": ${mem}, "max_swap": ${swap}, "resolvers": ["1.1.1.1"], "nics": [ { "nic_tag": "admin", "gateway": "192.168.3.1", "ips": ["${ip}"] } ] } EOF uuid=$(vmadm list -H -o uuid alias=$alias) rm -rf /zones/$uuid/root mkdir /zones/$uuid/root echo "Transferring image..." ssh -C apod "podman export $alias" | tar xpf - -C /zones/$uuid/root 2>/dev/null vmadm start $uuid && \ ssh apod "podman stop $alias" </syntaxhighlight>
Summary:
Please note that all contributions to pega.life may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Pega.life:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Main Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information