Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
6b926dfbee
|
|||
|
d22df65e5b
|
|||
|
d4722daf43
|
|||
|
319ffef6c9
|
|||
|
9d0c2985ac
|
|||
|
f1a44a38f6
|
|||
| 33a0da5d29 | |||
| 629d7dae6d | |||
| 9ceeef156a | |||
| 48372cd663 | |||
| 7e674d4026 | |||
| f8390ab262 | |||
| 8d6f3e9a93 | |||
|
|
9cd07d3b4d |
@@ -1,7 +1,7 @@
|
|||||||
# Devtools
|
# Devtools
|
||||||
|
|
||||||

|

|
||||||
[](https://github.com/Dark-Alex-17/dtools/releases)
|
|
||||||
|
|
||||||
**Devtools (`dtools`)** is a comprehensive CLI utility that consolidates reusable development scripts, tools, and
|
**Devtools (`dtools`)** is a comprehensive CLI utility that consolidates reusable development scripts, tools, and
|
||||||
references into a single, easy-to-use interface. Built with the [Bashly](https://github.com/DannyBen/bashly) framework, it serves multiple purposes:
|
references into a single, easy-to-use interface. Built with the [Bashly](https://github.com/DannyBen/bashly) framework, it serves multiple purposes:
|
||||||
|
|||||||
@@ -38,42 +38,44 @@ if [[ $backup == 1 ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
login() {
|
login() {
|
||||||
ssoLoggedIn=$(find "$HOME/.aws/sso/cache" -type f ! -name "botocore*" -exec jq -r '.accessToken | select(. != null)' {} \; | wc -l)
|
sso_logged_in=$(find "$HOME/.aws/sso/cache" -type f ! -name "botocore*" -exec jq -r '.accessToken | select(. != null)' {} \; | wc -l)
|
||||||
if [[ $ssoLoggedIn == 0 || ! -f "$HOME"/.aws/config ]]; then
|
if [[ $sso_logged_in == 0 || ! -f "$HOME"/.aws/config ]]; then
|
||||||
yellow_bold "You must first be logged into AWS with at least one profile. Logging in now..."
|
yellow_bold "You must first be logged into AWS with at least one profile. Logging in now..."
|
||||||
|
red_bold "You will be required to finish the login process, so control will be returned to you after logging in with your browser"
|
||||||
[[ -f "$HOME"/.aws/config ]] || touch "$HOME"/.aws/config
|
[[ -f "$HOME"/.aws/config ]] || touch "$HOME"/.aws/config
|
||||||
|
|
||||||
export AWS_PROFILE=''
|
export AWS_PROFILE=''
|
||||||
export AWS_REGION=''
|
export AWS_REGION=''
|
||||||
/usr/bin/expect<<-EOF
|
export SSO_START_URL="$sso_start_url"
|
||||||
set force_conservative 1
|
export SSO_REGION="$sso_region"
|
||||||
|
/usr/bin/expect <(cat <<-'EOF'
|
||||||
set timeout 120
|
set timeout 120
|
||||||
match_max 100000
|
match_max 100000
|
||||||
spawn aws configure sso
|
|
||||||
expect "SSO session name (Recommended):"
|
set sso_start_url $env(SSO_START_URL)
|
||||||
|
set sso_region $env(SSO_REGION)
|
||||||
|
|
||||||
|
spawn env TERM=dumb aws configure sso
|
||||||
|
|
||||||
|
expect -re {SSO session name \(Recommended\):\s*$}
|
||||||
send -- "session\r"
|
send -- "session\r"
|
||||||
expect "SSO start URL"
|
|
||||||
send -- "$sso_start_url\\r"
|
expect -re {SSO start URL \[None\]:\s*$}
|
||||||
expect "SSO region"
|
send -- "$sso_start_url\r"
|
||||||
|
|
||||||
|
expect -re {SSO region \[None\]:\s*$}
|
||||||
send -- "$sso_region\r"
|
send -- "$sso_region\r"
|
||||||
expect {
|
|
||||||
"SSO registration scopes" {
|
expect -re {SSO registration scopes \[sso:account:access\]:\s*$}
|
||||||
send "sso:account:access\\r"
|
send -- "sso:account:access\r"
|
||||||
exp_continue
|
|
||||||
}
|
expect -re {.*accounts available to you\s*}
|
||||||
-re {(.*)accounts available to you(.*)} {
|
|
||||||
send "\\r"
|
interact
|
||||||
exp_continue
|
EOF
|
||||||
}
|
) 2>/dev/null
|
||||||
-re {(.*)roles available to you(.*)} {
|
|
||||||
send "\\r"
|
green "Logged in!"
|
||||||
exp_continue
|
|
||||||
}
|
|
||||||
"CLI default client Region"
|
|
||||||
}
|
|
||||||
send "\r\r\r\r"
|
|
||||||
expect eof
|
|
||||||
EOF
|
|
||||||
elif ! (aws sts get-caller-identity > /dev/null 2>&1); then
|
elif ! (aws sts get-caller-identity > /dev/null 2>&1); then
|
||||||
red_bold "You must be logged into AWS before running this script."
|
red_bold "You must be logged into AWS before running this script."
|
||||||
yellow "Logging in via SSO. Follow the steps in the opened browser to log in."
|
yellow "Logging in via SSO. Follow the steps in the opened browser to log in."
|
||||||
@@ -96,27 +98,29 @@ login() {
|
|||||||
|
|
||||||
login
|
login
|
||||||
|
|
||||||
if ! (aws sso list-accounts --profile "${profiles[0]}" --region "$aws_region" --access-token "$ACCESS_TOKEN" --output json > /dev/null 2>&1); then
|
if ! (aws sso list-accounts --profile "${profiles[0]}" --region "$sso_region" --access-token "$ACCESS_TOKEN" --output json > /dev/null 2>&1); then
|
||||||
red "Unable to use existing SSO access token. Wiping tokens and generating new tokens..."
|
red "Unable to use existing SSO access token. Wiping tokens and generating new tokens..."
|
||||||
rm "$HOME"/.aws/sso/cache/*.json
|
rm "$HOME"/.aws/sso/cache/*.json
|
||||||
login
|
login
|
||||||
fi
|
fi
|
||||||
|
|
||||||
aws sso list-accounts --profile "${profiles[0]}" --region "$aws_region" --access-token "$ACCESS_TOKEN" --output json | jq '.accountList[]' -rc | while read -r account; do
|
aws sso list-accounts --profile "${profiles[0]}" --region "$sso_region" --access-token "$ACCESS_TOKEN" --output json | jq '.accountList[]' -rc | while read -r account; do
|
||||||
declare accountId
|
declare account_id
|
||||||
declare accountName
|
declare account_name
|
||||||
accountId="$(echo "$account" | jq -rc '.accountId')"
|
account_id="$(echo "$account" | jq -rc '.accountId')"
|
||||||
accountName="$(echo "$account" | jq -rc '.accountName | ascii_downcase | gsub(" "; "-")')"
|
account_name="$(echo "$account" | jq -rc '.accountName | ascii_downcase | gsub(" "; "-")')"
|
||||||
|
|
||||||
aws sso list-account-roles --profile "${profiles[0]}" --region "$aws_region" --access-token "$ACCESS_TOKEN" --output json --account-id "$accountId" | jq '.roleList[].roleName' -rc | while read -r roleName; do
|
aws sso list-account-roles --profile "${profiles[0]}" --region "$sso_region" --access-token "$ACCESS_TOKEN" --output json --account-id "$account_id" |\
|
||||||
|
jq '.roleList[].roleName' -rc |\
|
||||||
|
while read -r role_name; do
|
||||||
declare profileName
|
declare profileName
|
||||||
profileName="$accountName-$roleName"
|
profileName="$account_name-$role_name"
|
||||||
|
|
||||||
if ! (grep -q "$profileName" ~/.aws/config); then
|
if ! (grep -q "$profileName" ~/.aws/config); then
|
||||||
blue "Creating profiles for account $accountName"
|
blue "Creating profiles for account $account_name"
|
||||||
write-profile-to-config "$accountName-$roleName" "$sso_start_url" "$sso_region" "$accountId" "$roleName" "$aws_region"
|
write-profile-to-config "$account_name-$role_name" "$sso_start_url" "$sso_region" "$account_id" "$role_name" "$aws_region"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
green_bold "Successfully generated profiles from AWS SSO!"
|
green_bold "Successfully generated profiles from AWS SSO!"
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ if (command -v snap > /dev/null 2>&1); then
|
|||||||
LANG=en_US.UTF-8 snap list --all |\
|
LANG=en_US.UTF-8 snap list --all |\
|
||||||
awk '/disabled/{print $1, $3}' |\
|
awk '/disabled/{print $1, $3}' |\
|
||||||
while read -r snapname revision; do
|
while read -r snapname revision; do
|
||||||
snap remove "$snapname" --revision="$revision"
|
sudo snap remove "$snapname" --revision="$revision"
|
||||||
done
|
done
|
||||||
blue_bold "Purging cached Snap versions..."
|
blue_bold "Purging cached Snap versions..."
|
||||||
sudo rm -rf /var/cache/snapd/*
|
sudo rm -rf /var/cache/snapd/*
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
# shellcheck disable=SC2154
|
||||||
|
declare host="${args[host]}"
|
||||||
|
declare port="${args[--port]}"
|
||||||
|
declare view_only="${args[--view-only]}"
|
||||||
|
declare output_dir="${args[--output-dir]}"
|
||||||
|
declare filename="${args[--filename]}"
|
||||||
|
|
||||||
|
if [[ "$view_only" == 1 ]]; then
|
||||||
|
openssl s_client -showcerts -connect "${host}:${port}"
|
||||||
|
else
|
||||||
|
openssl s_client -showcerts -connect "${host}:${port}" </dev/null | sed -n -e '/-.BEGIN/,/-.END/ p' | sudo tee "${output_dir}/${filename:-${host%%.*}}.pem"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if dpkg -s ca-certificates > /dev/null 2>&1; then
|
||||||
|
sudo update-ca-certificates
|
||||||
|
fi
|
||||||
@@ -288,3 +288,45 @@ commands:
|
|||||||
C-->D
|
C-->D
|
||||||
C-->F
|
C-->F
|
||||||
'
|
'
|
||||||
|
|
||||||
|
- name: get-server-tls-cert
|
||||||
|
help: |-
|
||||||
|
Retrieve the TLS certificate from a server and save it to a file.
|
||||||
|
If on a debian-based system and 'ca-certificates' is installed, the certificate will be installed into the system's trust store.
|
||||||
|
dependencies:
|
||||||
|
openssl: Install with either 'sudo apt install libssl-dev' or 'brew install openssl@3'
|
||||||
|
args:
|
||||||
|
- name: host
|
||||||
|
help: Domain name or IP address
|
||||||
|
required: true
|
||||||
|
flags:
|
||||||
|
- long: --port
|
||||||
|
short: -p
|
||||||
|
help: The port to connect to
|
||||||
|
arg: port
|
||||||
|
default: '443'
|
||||||
|
validate: port_number
|
||||||
|
- long: --view-only
|
||||||
|
short: -v
|
||||||
|
help: Only print the certificate(s) to stdout
|
||||||
|
conflicts: [--output-dir, --filename]
|
||||||
|
- long: --output-dir
|
||||||
|
short: -d
|
||||||
|
help: |-
|
||||||
|
Write the certificate to a file.
|
||||||
|
Defaults to `/usr/local/share/ca-certificates`.
|
||||||
|
arg: output
|
||||||
|
completions:
|
||||||
|
- <file>
|
||||||
|
conflicts: [--view-only]
|
||||||
|
default: /usr/local/share/ca-certificates
|
||||||
|
- long: --filename
|
||||||
|
short: -f
|
||||||
|
arg: filename
|
||||||
|
help: |-
|
||||||
|
The name of the '.pem' file to save the cert to.
|
||||||
|
By default, it is 'domain.pem'
|
||||||
|
conflicts: [--view-only]
|
||||||
|
examples:
|
||||||
|
- dtools network get-server-tls-cert google.com --port 443
|
||||||
|
- dtools network get-server-tls-cert example.com --output-dir . --filename example.com
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
navi
|
||||||
@@ -12,3 +12,8 @@ commands:
|
|||||||
help: Wikipedia TUI (wiki-tui)
|
help: Wikipedia TUI (wiki-tui)
|
||||||
dependencies:
|
dependencies:
|
||||||
wiki-tui: See 'https://wiki-tui.net/latest/'
|
wiki-tui: See 'https://wiki-tui.net/latest/'
|
||||||
|
|
||||||
|
- name: command-lookup
|
||||||
|
help: Interactive command cheatsheet so you don't have to google all your commands (navi)
|
||||||
|
dependencies:
|
||||||
|
navi: See 'https://github.com/denisidoro/navi'
|
||||||
|
|||||||
@@ -88,3 +88,8 @@ commands:
|
|||||||
help: Fast, remote-first, multi-host TUI log viewer with timeline histogram and no central server (nerdlog)
|
help: Fast, remote-first, multi-host TUI log viewer with timeline histogram and no central server (nerdlog)
|
||||||
dependencies:
|
dependencies:
|
||||||
nerdlog: See 'https://github.com/dimonomid/nerdlog'
|
nerdlog: See 'https://github.com/dimonomid/nerdlog'
|
||||||
|
|
||||||
|
- name: system-benchmark
|
||||||
|
help: Statistic benchmarking using your CLI with warmup rounds, outlier removal, and side-by-side comparison (hyperfine)
|
||||||
|
dependencies:
|
||||||
|
hyperfine: See 'https://github.com/sharkdp/hyperfine'
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
hyperfine
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
brew-explorer
|
||||||
@@ -105,3 +105,8 @@ commands:
|
|||||||
help: A TUI and CLI for managing *arr servers (managarr)
|
help: A TUI and CLI for managing *arr servers (managarr)
|
||||||
dependencies:
|
dependencies:
|
||||||
managarr: See 'https://github.com/Dark-Alex-17/managarr'
|
managarr: See 'https://github.com/Dark-Alex-17/managarr'
|
||||||
|
|
||||||
|
- name: brew-explorer
|
||||||
|
help: A beautiful terminal UI for exploring and managing your Homebrew packages with ease
|
||||||
|
dependencies:
|
||||||
|
brew-explorer: See 'https://github.com/cosmincatalin/brew-explorer'
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
ncdu
|
||||||
@@ -17,3 +17,8 @@ commands:
|
|||||||
help: Linux kernel manager and activity monitor (kmon)
|
help: Linux kernel manager and activity monitor (kmon)
|
||||||
dependencies:
|
dependencies:
|
||||||
kmon: See 'https://github.com/orhun/kmon'
|
kmon: See 'https://github.com/orhun/kmon'
|
||||||
|
|
||||||
|
- name: disk-monitor
|
||||||
|
help: Interactive disk usage navigator (ncdu)
|
||||||
|
dependencies:
|
||||||
|
ncdu: See 'https://dev.yorhel.nl/ncdu'
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
docker run -it browsh/browsh
|
brow6el
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
whosthere
|
||||||
@@ -44,6 +44,11 @@ commands:
|
|||||||
gping: See 'https://github.com/orf/gping'
|
gping: See 'https://github.com/orf/gping'
|
||||||
|
|
||||||
- name: full-browser
|
- name: full-browser
|
||||||
|
help: A full-featured web browser for the terminal using Chromium (CEF) and libsixel for graphics rendering (brow6el)
|
||||||
|
dependencies:
|
||||||
|
brow6el: See 'https://codeberg.org/janantos/brow6el'
|
||||||
|
|
||||||
|
- name: text-based-browser
|
||||||
help: Text based browser with images (browsh)
|
help: Text based browser with images (browsh)
|
||||||
dependencies:
|
dependencies:
|
||||||
browsh: See 'https://www.brow.sh/'
|
browsh: See 'https://www.brow.sh/'
|
||||||
@@ -82,3 +87,8 @@ commands:
|
|||||||
help: A simple API client (Postman-like) (atac)
|
help: A simple API client (Postman-like) (atac)
|
||||||
dependencies:
|
dependencies:
|
||||||
atac: See 'https://atac.julien-cpsn.com/'
|
atac: See 'https://atac.julien-cpsn.com/'
|
||||||
|
|
||||||
|
- name: lan-discovery
|
||||||
|
help: Local Area Network discovery tool with a modern Terminal User Interface (TUI) written in Go. Discover, explore, and understand your LAN in an intuitive way. Knock Knock.. who's there? (whosthere)
|
||||||
|
dependencies:
|
||||||
|
whosthere: See 'https://github.com/ramonvermeulen/whosthere'
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
docker run -it browsh/browsh
|
||||||
@@ -10,6 +10,17 @@ declare ram_size="${args[--ram-size]}"
|
|||||||
declare cpu_cores="${args[--cpu-cores]}"
|
declare cpu_cores="${args[--cpu-cores]}"
|
||||||
# shellcheck disable=SC2154
|
# shellcheck disable=SC2154
|
||||||
declare share_directory="${args[--share-directory]}"
|
declare share_directory="${args[--share-directory]}"
|
||||||
|
# shellcheck disable=SC2154
|
||||||
|
declare usb="${args[--usb]}"
|
||||||
|
declare -a flags=()
|
||||||
|
|
||||||
|
if [[ -n "$usb" ]]; then
|
||||||
|
vendor_id="$(udevadm info --query=all --name="$usb" | grep ID_VENDOR_ID | awk -F= '{print $2}')"
|
||||||
|
product_id="$(udevadm info --query=all --name="$usb" | grep ID_MODEL_ID | awk -F= '{print $2}')"
|
||||||
|
flags+=("--device=/dev/bus/usb")
|
||||||
|
flags+=("-e")
|
||||||
|
flags+=(ARGUMENTS="-device usb-host,vendorid=0x${vendor_id},productid=0x${product_id}")
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -n $dist ]]; then
|
if [[ -n $dist ]]; then
|
||||||
image=$dist
|
image=$dist
|
||||||
@@ -47,6 +58,7 @@ if [[ "${args[--no-gui]}" == 1 ]]; then
|
|||||||
-e "RAM_SIZE=${ram_size}G" \
|
-e "RAM_SIZE=${ram_size}G" \
|
||||||
-e "CPU_CORES=$cpu_cores" \
|
-e "CPU_CORES=$cpu_cores" \
|
||||||
-v "$share_directory:/shared" \
|
-v "$share_directory:/shared" \
|
||||||
|
"${flags[@]}" \
|
||||||
--cap-add NET_ADMIN \
|
--cap-add NET_ADMIN \
|
||||||
--stop-timeout 120 \
|
--stop-timeout 120 \
|
||||||
qemux/qemu
|
qemux/qemu
|
||||||
@@ -60,6 +72,7 @@ if [[ "${args[--no-gui]}" == 1 ]]; then
|
|||||||
-e "RAM_SIZE=${ram_size}G" \
|
-e "RAM_SIZE=${ram_size}G" \
|
||||||
-e "CPU_CORES=$cpu_cores" \
|
-e "CPU_CORES=$cpu_cores" \
|
||||||
-v "$share_directory:/shared" \
|
-v "$share_directory:/shared" \
|
||||||
|
"${flags[@]}" \
|
||||||
--cap-add NET_ADMIN \
|
--cap-add NET_ADMIN \
|
||||||
--stop-timeout 120 \
|
--stop-timeout 120 \
|
||||||
qemux/qemu
|
qemux/qemu
|
||||||
@@ -78,6 +91,7 @@ else
|
|||||||
-e "RAM_SIZE=${ram_size}G" \
|
-e "RAM_SIZE=${ram_size}G" \
|
||||||
-e "CPU_CORES=$cpu_cores" \
|
-e "CPU_CORES=$cpu_cores" \
|
||||||
-v "$share_directory:/shared" \
|
-v "$share_directory:/shared" \
|
||||||
|
"${flags[@]}" \
|
||||||
--cap-add NET_ADMIN \
|
--cap-add NET_ADMIN \
|
||||||
--stop-timeout 120 \
|
--stop-timeout 120 \
|
||||||
-d \
|
-d \
|
||||||
@@ -94,6 +108,7 @@ else
|
|||||||
-e "RAM_SIZE=${ram_size}G" \
|
-e "RAM_SIZE=${ram_size}G" \
|
||||||
-e "CPU_CORES=$cpu_cores" \
|
-e "CPU_CORES=$cpu_cores" \
|
||||||
-v "$share_directory:/shared" \
|
-v "$share_directory:/shared" \
|
||||||
|
"${flags[@]}" \
|
||||||
--cap-add NET_ADMIN \
|
--cap-add NET_ADMIN \
|
||||||
--stop-timeout 120 \
|
--stop-timeout 120 \
|
||||||
-d \
|
-d \
|
||||||
|
|||||||
@@ -10,6 +10,17 @@ declare cpu_cores="${args[--cpu-cores]}"
|
|||||||
declare share_directory="${args[--share-directory]}"
|
declare share_directory="${args[--share-directory]}"
|
||||||
# shellcheck disable=SC2154
|
# shellcheck disable=SC2154
|
||||||
declare persistent_dir_prefix="${args[--persistent-dir-prefix]:-$version}"
|
declare persistent_dir_prefix="${args[--persistent-dir-prefix]:-$version}"
|
||||||
|
# shellcheck disable=SC2154
|
||||||
|
declare usb="${args[--usb]}"
|
||||||
|
declare -a flags=()
|
||||||
|
|
||||||
|
if [[ -n "$usb" ]]; then
|
||||||
|
vendor_id="$(udevadm info --query=all --name="$usb" | grep ID_VENDOR_ID | awk -F= '{print $2}')"
|
||||||
|
product_id="$(udevadm info --query=all --name="$usb" | grep ID_MODEL_ID | awk -F= '{print $2}')"
|
||||||
|
flags+=("--device=/dev/bus/usb")
|
||||||
|
flags+=("-e")
|
||||||
|
flags+=(ARGUMENTS="-device usb-host,vendorid=0x${vendor_id},productid=0x${product_id}")
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ "${args[--wipe-persistent-data]}" == 1 ]]; then
|
if [[ "${args[--wipe-persistent-data]}" == 1 ]]; then
|
||||||
declare persistent_data_dir="$HOME/.vm/mac/$persistent_dir_prefix"
|
declare persistent_data_dir="$HOME/.vm/mac/$persistent_dir_prefix"
|
||||||
@@ -40,6 +51,7 @@ if [[ "${args[--persistent]}" == 1 ]]; then
|
|||||||
-v "$share_directory:/shared" \
|
-v "$share_directory:/shared" \
|
||||||
--cap-add NET_ADMIN \
|
--cap-add NET_ADMIN \
|
||||||
--stop-timeout 120 \
|
--stop-timeout 120 \
|
||||||
|
"${flags[@]}" \
|
||||||
-d \
|
-d \
|
||||||
dockurr/macos)
|
dockurr/macos)
|
||||||
else
|
else
|
||||||
@@ -55,6 +67,7 @@ else
|
|||||||
-v "$share_directory:/shared" \
|
-v "$share_directory:/shared" \
|
||||||
--cap-add NET_ADMIN \
|
--cap-add NET_ADMIN \
|
||||||
--stop-timeout 120 \
|
--stop-timeout 120 \
|
||||||
|
"${flags[@]}" \
|
||||||
-d \
|
-d \
|
||||||
dockurr/macos)
|
dockurr/macos)
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -24,46 +24,52 @@ commands:
|
|||||||
- long: --disk-size
|
- long: --disk-size
|
||||||
help: The disk size of the VM's drive in GB
|
help: The disk size of the VM's drive in GB
|
||||||
arg: disk_size
|
arg: disk_size
|
||||||
default: "64"
|
default: '64'
|
||||||
validate: integer
|
validate: integer
|
||||||
- long: --ram-size
|
- long: --ram-size
|
||||||
help: The RAM size of the VM's RAM in GB
|
help: The RAM size of the VM's RAM in GB
|
||||||
arg: ram_size
|
arg: ram_size
|
||||||
default: "4"
|
default: '4'
|
||||||
validate: integer
|
validate: integer
|
||||||
- long: --cpu-cores
|
- long: --cpu-cores
|
||||||
help: The number of CPU cores the VM is allowed to use
|
help: The number of CPU cores the VM is allowed to use
|
||||||
arg: cpu_cores
|
arg: cpu_cores
|
||||||
default: "2"
|
default: '2'
|
||||||
validate: integer
|
validate: integer
|
||||||
- long: --share-directory
|
- long: --share-directory
|
||||||
help: The directory to share with the VM (In Windows, this is the Network#host.lan machine)
|
help: The directory to share with the VM (In Windows, this is the Network#host.lan machine)
|
||||||
arg: share_directory
|
arg: share_directory
|
||||||
default: "."
|
default: '.'
|
||||||
|
completions:
|
||||||
|
- <directory>
|
||||||
|
- long: --usb
|
||||||
|
help: The USB device to mount into the VM (e.g. '/dev/sde')
|
||||||
|
arg: usb
|
||||||
|
validate: device_exists
|
||||||
completions:
|
completions:
|
||||||
- <directory>
|
- <directory>
|
||||||
- long: --version
|
- long: --version
|
||||||
help: The version of Windows to start
|
help: The version of Windows to start
|
||||||
arg: version
|
arg: version
|
||||||
default: "11"
|
default: '11'
|
||||||
allowed:
|
allowed:
|
||||||
- "11"
|
- '11'
|
||||||
- "11l"
|
- '11l'
|
||||||
- "11e"
|
- '11e'
|
||||||
- "10"
|
- '10'
|
||||||
- "10l"
|
- '10l'
|
||||||
- "10e"
|
- '10e'
|
||||||
- "8e"
|
- '8e'
|
||||||
- "7e"
|
- '7e'
|
||||||
- "ve"
|
- 've'
|
||||||
- "xp"
|
- 'xp'
|
||||||
- "2025"
|
- '2025'
|
||||||
- "2022"
|
- '2022'
|
||||||
- "2019"
|
- '2019'
|
||||||
- "2016"
|
- '2016'
|
||||||
- "2012"
|
- '2012'
|
||||||
- "2008"
|
- '2008'
|
||||||
- "2003"
|
- '2003'
|
||||||
|
|
||||||
- name: linux
|
- name: linux
|
||||||
help: Start a Linux VM that's available at http://localhost:8006 and via SSH on port 2222
|
help: Start a Linux VM that's available at http://localhost:8006 and via SSH on port 2222
|
||||||
@@ -104,50 +110,56 @@ commands:
|
|||||||
- long: --disk-size
|
- long: --disk-size
|
||||||
help: The disk size of the VM's drive in GB
|
help: The disk size of the VM's drive in GB
|
||||||
arg: disk_size
|
arg: disk_size
|
||||||
default: "128"
|
default: '128'
|
||||||
validate: integer
|
validate: integer
|
||||||
- long: --ram-size
|
- long: --ram-size
|
||||||
help: The RAM size of the VM's RAM in GB
|
help: The RAM size of the VM's RAM in GB
|
||||||
arg: ram_size
|
arg: ram_size
|
||||||
default: "8"
|
default: '8'
|
||||||
validate: integer
|
validate: integer
|
||||||
- long: --cpu-cores
|
- long: --cpu-cores
|
||||||
help: The number of CPU cores the VM is allowed to use
|
help: The number of CPU cores the VM is allowed to use
|
||||||
arg: cpu_cores
|
arg: cpu_cores
|
||||||
default: "4"
|
default: '4'
|
||||||
validate: integer
|
validate: integer
|
||||||
- long: --share-directory
|
- long: --share-directory
|
||||||
help: The directory to share with the VM (Access by running 'mount -t 9p -o trans=virtio shared /mnt/shared' in the container)
|
help: The directory to share with the VM (Access by running 'mount -t 9p -o trans=virtio shared /mnt/shared' in the container)
|
||||||
arg: share_directory
|
arg: share_directory
|
||||||
default: "."
|
default: '.'
|
||||||
|
completions:
|
||||||
|
- <directory>
|
||||||
|
- long: --usb
|
||||||
|
help: The USB device to mount into the VM (e.g. '/dev/sde')
|
||||||
|
arg: usb
|
||||||
|
validate: device_exists
|
||||||
completions:
|
completions:
|
||||||
- <directory>
|
- <directory>
|
||||||
- long: --dist
|
- long: --dist
|
||||||
help: The Linux distribution to start
|
help: The Linux distribution to start
|
||||||
arg: distribution
|
arg: distribution
|
||||||
allowed:
|
allowed:
|
||||||
- "alma"
|
- 'alma'
|
||||||
- "alpine"
|
- 'alpine'
|
||||||
- "arch"
|
- 'arch'
|
||||||
- "cachy"
|
- 'cachy'
|
||||||
- "centos"
|
- 'centos'
|
||||||
- "debian"
|
- 'debian'
|
||||||
- "fedora"
|
- 'fedora'
|
||||||
- "gentoo"
|
- 'gentoo'
|
||||||
- "kali"
|
- 'kali'
|
||||||
- "kubuntu"
|
- 'kubuntu'
|
||||||
- "mint"
|
- 'mint'
|
||||||
- "manjaro"
|
- 'manjaro'
|
||||||
- "mx"
|
- 'mx'
|
||||||
- "nixos"
|
- 'nixos'
|
||||||
- "suse"
|
- 'suse'
|
||||||
- "oracle"
|
- 'oracle'
|
||||||
- "rocky"
|
- 'rocky'
|
||||||
- "slack"
|
- 'slack'
|
||||||
- "tails"
|
- 'tails'
|
||||||
- "ubuntu"
|
- 'ubuntu'
|
||||||
- "ubuntus"
|
- 'ubuntus'
|
||||||
- "xubuntu"
|
- 'xubuntu'
|
||||||
conflicts: [--image-url]
|
conflicts: [--image-url]
|
||||||
- long: --image-url
|
- long: --image-url
|
||||||
help: |-
|
help: |-
|
||||||
@@ -187,31 +199,37 @@ commands:
|
|||||||
- long: --disk-size
|
- long: --disk-size
|
||||||
help: The disk size of the VM's drive in GB
|
help: The disk size of the VM's drive in GB
|
||||||
arg: disk_size
|
arg: disk_size
|
||||||
default: "64"
|
default: '64'
|
||||||
validate: integer
|
validate: integer
|
||||||
- long: --ram-size
|
- long: --ram-size
|
||||||
help: The RAM size of the VM's RAM in GB
|
help: The RAM size of the VM's RAM in GB
|
||||||
arg: ram_size
|
arg: ram_size
|
||||||
default: "4"
|
default: '4'
|
||||||
validate: integer
|
validate: integer
|
||||||
- long: --cpu-cores
|
- long: --cpu-cores
|
||||||
help: The number of CPU cores the VM is allowed to use
|
help: The number of CPU cores the VM is allowed to use
|
||||||
arg: cpu_cores
|
arg: cpu_cores
|
||||||
default: "2"
|
default: '2'
|
||||||
validate: integer
|
validate: integer
|
||||||
- long: --share-directory
|
- long: --share-directory
|
||||||
help: The directory to share with the VM (Access by running 'mount -S mount_9p shared' in the container; Then it's available under Finder -> Go -> Computer)
|
help: The directory to share with the VM (Access by running 'mount -S mount_9p shared' in the container; Then it's available under Finder -> Go -> Computer)
|
||||||
arg: share_directory
|
arg: share_directory
|
||||||
default: "."
|
default: '.'
|
||||||
|
completions:
|
||||||
|
- <directory>
|
||||||
|
- long: --usb
|
||||||
|
help: The USB device to mount into the VM (e.g. '/dev/sde')
|
||||||
|
arg: usb
|
||||||
|
validate: device_exists
|
||||||
completions:
|
completions:
|
||||||
- <directory>
|
- <directory>
|
||||||
- long: --version
|
- long: --version
|
||||||
help: The version of MacOS to start
|
help: The version of MacOS to start
|
||||||
arg: version
|
arg: version
|
||||||
default: "13"
|
default: '15'
|
||||||
allowed:
|
allowed:
|
||||||
- "15"
|
- '15'
|
||||||
- "14"
|
- '14'
|
||||||
- "13"
|
- '13'
|
||||||
- "12"
|
- '12'
|
||||||
- "11"
|
- '11'
|
||||||
|
|||||||
@@ -10,6 +10,17 @@ declare cpu_cores="${args[--cpu-cores]}"
|
|||||||
declare share_directory="${args[--share-directory]}"
|
declare share_directory="${args[--share-directory]}"
|
||||||
# shellcheck disable=SC2154
|
# shellcheck disable=SC2154
|
||||||
declare persistent_dir_prefix="${args[--persistent-dir-prefix]:-$version}"
|
declare persistent_dir_prefix="${args[--persistent-dir-prefix]:-$version}"
|
||||||
|
# shellcheck disable=SC2154
|
||||||
|
declare usb="${args[--usb]}"
|
||||||
|
declare -a flags=()
|
||||||
|
|
||||||
|
if [[ -n "$usb" ]]; then
|
||||||
|
vendor_id="$(udevadm info --query=all --name="$usb" | grep ID_VENDOR_ID | awk -F= '{print $2}')"
|
||||||
|
product_id="$(udevadm info --query=all --name="$usb" | grep ID_MODEL_ID | awk -F= '{print $2}')"
|
||||||
|
flags+=("--device=/dev/bus/usb")
|
||||||
|
flags+=("-e")
|
||||||
|
flags+=(ARGUMENTS="-device usb-host,vendorid=0x${vendor_id},productid=0x${product_id}")
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ "${args[--wipe-persistent-data]}" == 1 ]]; then
|
if [[ "${args[--wipe-persistent-data]}" == 1 ]]; then
|
||||||
declare persistent_data_dir="$HOME/.vm/windows/$persistent_dir_prefix"
|
declare persistent_data_dir="$HOME/.vm/windows/$persistent_dir_prefix"
|
||||||
@@ -40,6 +51,7 @@ if [[ "${args[--persistent]}" == 1 ]]; then
|
|||||||
-v "$share_directory:/data" \
|
-v "$share_directory:/data" \
|
||||||
--cap-add NET_ADMIN \
|
--cap-add NET_ADMIN \
|
||||||
--stop-timeout 120 \
|
--stop-timeout 120 \
|
||||||
|
"${flags[@]}" \
|
||||||
-d \
|
-d \
|
||||||
dockurr/windows)
|
dockurr/windows)
|
||||||
else
|
else
|
||||||
@@ -55,6 +67,7 @@ else
|
|||||||
-v "$share_directory:/data" \
|
-v "$share_directory:/data" \
|
||||||
--cap-add NET_ADMIN \
|
--cap-add NET_ADMIN \
|
||||||
--stop-timeout 120 \
|
--stop-timeout 120 \
|
||||||
|
"${flags[@]}" \
|
||||||
-d \
|
-d \
|
||||||
dockurr/windows)
|
dockurr/windows)
|
||||||
fi
|
fi
|
||||||
|
|||||||
+663
-615
File diff suppressed because it is too large
Load Diff
@@ -3,3 +3,7 @@ validate_port_number() {
|
|||||||
red_bold "The port number provided is invalid: $1"
|
red_bold "The port number provided is invalid: $1"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
validate_device_exists () {
|
||||||
|
[[ -e /dev/sde ]] || red_bold "The specified device does not exist: $1"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user