Move scripts to bin/ directory

This commit is contained in:
2026-09-08 02:45:25 +08:00
parent 7afd4fdd0c
commit bdb089dee5
11 changed files with 0 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
#!/bin/bash
# returns an unused nbd device
for sys_path in /sys/block/nbd[0-9]*; do
[ -d "$sys_path" ] || continue
if [ -f "$sys_path/size" ] && [ "$(< "$sys_path/size")" -eq 0 ] ; then
TARGET="/dev/${sys_path##*/}"
break
fi
done
if [ -z "$TARGET" ]; then
echo "Error: no free NBD device found" >&2
exit 1
fi
echo $TARGET