commit 19a4397a508e94c964dd6bc9e7334a2e9e3cb471
parent 68c33b130c74d6d077c578806bcf05fa6f9e4bf0
Author: Christos Margiolis <christos@margiolis.net>
Date: Mon, 27 Feb 2023 01:37:54 +0200
improve vmstart
Diffstat:
6 files changed, 47 insertions(+), 25 deletions(-)
diff --git a/Makefile b/Makefile
@@ -5,6 +5,7 @@ TARGS = audl \
autocomp \
backup \
batnfy \
+ buildtrace \
bookmark \
doccomp \
docprev \
diff --git a/ausplit b/ausplit
@@ -5,24 +5,23 @@ main()
{
test ${#} -ne 2 && usage
- auin="${1}"
local tfile="${2}"
- total="$(wc -l < "${tfile}")"
- # The extension must exist in `tag`.
+
+ auin="${1}"
+ total="$(wc -l < "${tfile}" | awk '{print $1}')"
ext="${1#*.}"
read -erp "Album/book title: " album
read -erp "Artist/author: " author
read -erp "Publication year: " year
- namefmt="$(fmt_name "${album}")"
- mkdir -p "${namefmt}" || exit 1
+ albumdir="$(fmt_name "${album}")"
+ mkdir -p "${albumdir}" || exit 1
- # FIXME
while read -r line; do
end="$(echo "${line}" | cut -d' ' -f1)"
test -n "${start}" && split_file
- title="$(echo "${line}" | cut -d' ' -f 2-)"
+ title="$(echo "${line}" | cut -d' ' -f2-)"
titlefmt="$(fmt_name "${title}")"
track="$((track+1))"
start="${end}"
@@ -34,7 +33,8 @@ main()
usage()
{
- echo "usage: ${0##*/} audio timecode_file" 1>&2 && exit 1
+ echo "usage: ${0##*/} audio timecode_file" 1>&2
+ exit 1
}
fmt_name()
@@ -48,22 +48,19 @@ split_file()
{
echo "From ${start} to ${end}; ${track} ${title}"
echo "Splitting \"${title}\"..."
- ofile="${namefmt}/$(printf "%.2d" "${track}")-${titlefmt}.${ext}"
+ ofile="${albumdir}/$(printf "%.2d" "${track}")-${titlefmt}.${ext}"
ffmpeg \
-nostdin -y -loglevel -8 \
-i "${auin}" \
-ss "${start}" \
`test ${track} -eq ${total} || echo "-to ${end}"` \
-vn -c copy \
- "${ofile}" &&
- echo "Tagging \"${title}\"..." &&
- tag \
- -a "${author}" \
- -A "${album}" \
- -t "${title}" \
- -n "${track}" \
- -N "${total}" \
- -d "${year}" \
+ -map 0 \
+ -metadata title="${title}" \
+ -metadata album="${album}" \
+ -metadata artist="${author}" \
+ -metadata track="${track}/${total}" \
+ -metadata date="${date}" \
"${ofile}"
}
diff --git a/backup b/backup
@@ -27,7 +27,7 @@ main()
dst_last_snap=$(last_snap "${dst_pool}")
nsnaps=$(zfs list -t snapshot -o name ${dst_pool} | sed 1d | wc -l)
- delete_existing_snap "${src_pool}" "${src_last_snap}"
+ delete_existing_snap "${dst_pool}" "${dst_last_snap}"
zfs snapshot -r ${src_pool}@${new_snap}
if [ ${f_incr} -eq 1 ]; then
diff --git a/buildtrace b/buildtrace
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+kldunload dtraceall
+cd /usr/src
+cd cddl/lib/libdtrace && make all install && cd -
+cd cddl/usr.sbin/dtrace && make all install && cd -
+cd sys/modules/dtrace/ && make all install && cd -
+kldload dtraceall
diff --git a/upd b/upd
@@ -1,6 +1,6 @@
#!/bin/sh
-case $1 in
+case "${1}" in
www) src="${HOME}/src/margiolis.net/public/"
dst="master@margiolis.net:/var/www/htdocs/margiolis.net"
;;
@@ -16,10 +16,10 @@ case $1 in
desk) src="${2}"
dst="pleb:${3}"
;;
- *) echo "usage: ${0##*/} {www | ftp | vps | lap | desk} src dst" 1>&2 && exit 1 ;;
+ *) echo "usage: ${0##*/} {www | ftp | vps | lap | desk} src dst" 1>&2
+ exit 1
+ ;;
esac
-test -z "${src}" && echo "${0##*/}: src is empty" 1>&2 && exit 1
-test -z "${dst}" && echo "${0##*/}: dest is empty" 1>&2 && exit 1
read -erp "${0##*/}: transfer '${src}' to '${dst}' (y/N)? " act
test "${act}" = "y" && rsync -Purv --delete-after "${src}" "${dst}"
diff --git a/vmstart b/vmstart
@@ -7,11 +7,23 @@ usage()
exit 1
}
+err()
+{
+ echo "${0##*/} ${@}" 1>&2
+ exit 1
+}
+
cpu="2"
mem="2G"
disk="disk.img"
tap="tap0"
vnc="no"
+uefifile="/usr/local/share/uefi-firmware/BHYVE_UEFI.fd"
+
+# TODO initial setup?
+# TODO virtio-blk
+# TODO vnc wait?
+# TODO does grub work properly?
while getopts "c:C:d:g:G:i:m:t:uv" arg; do
case "${arg}" in
@@ -23,7 +35,7 @@ case "${arg}" in
i) img="${OPTARG}" ;;
m) mem="${OPTARG}" ;;
t) tap="${OPTARG}" ;;
- u) uefi="-l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd" ;;
+ u) uefi="-l bootrom,${uefifile}" ;;
v) vnc="yes" ;;
*) usage ;;
esac
@@ -33,8 +45,12 @@ shift $((OPTIND - 1))
name="${1}"
test -z "${name}" && usage
+test ! -f ${uefifile} && \
+err "${uefifile} not found. Install $(pkg search uefi-edk | awk '{print $1}')"
+
+ifconfig "${tap}" up || exit 1
+
test -n "${disksiz}" && truncate -s "${disksiz}" ${disk}
-ifconfig "${tap}" up
if [ -n "${grubdrv}" ]; then
echo "(hd0) disk.img" > device.map