scripts

Random scripts
git clone git://git.margiolis.net/scripts.git
Log | Files | Refs | README | LICENSE

commit 774a61f8dd79540e99d1d3a752f9495bdb609051
parent 178b0ab86c835a0fed9e347f4bb3a6ff51dcbc6a
Author: Christos Margiolis <christos@margiolis.net>
Date:   Wed, 11 Jan 2023 21:18:54 +0200

minor stuff

Diffstat:
Mbackup | 2+-
Mbookmark | 2+-
Mextr | 2+-
Mmntdroid | 2+-
Msjail | 2+-
Mtag | 11++++++-----
Mvds | 2+-
Mvmstart | 12++++++------
Mvmstop | 2+-
9 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/backup b/backup @@ -5,7 +5,7 @@ main() f_incr=0 # Incremental backup f_snap=0 # Renew snapshots in case they already exist - while getopts ir arg; do + while getopts "ir" arg; do case "${arg}" in i) f_incr=1 ;; r) f_snap=1 ;; diff --git a/bookmark b/bookmark @@ -40,7 +40,7 @@ bmk_fmt() done } -while getopts af arg; do +while getopts "af" arg; do case "${arg}" in a) bmk_getfile bmk_add diff --git a/extr b/extr @@ -5,7 +5,7 @@ usage() echo "usage: ${0##*/} [-d dir] file" 1>&2 && exit 1 } -while getopts d: arg; do +while getopts "d:" arg; do case "${arg}" in d) dir="${OPTARG}" ;; *) usage ;; diff --git a/mntdroid b/mntdroid @@ -3,7 +3,7 @@ MTPT="/mnt/droid" f_umnt=0 -while getopts u arg; do +while getopts "u" arg; do case "${arg}" in u) f_umnt=1 ;; *) echo "usage: ${0##*/} [-u]" 1>&2 && exit 1 ;; diff --git a/sjail b/sjail @@ -77,7 +77,7 @@ usage() exit 1 } -while getopts id:n: arg; do +while getopts "id:n:" arg; do case "${arg}" in i) sjail_init; exit 0 ;; d) sjail_del "${OPTARG}"; exit 0 ;; diff --git a/tag b/tag @@ -8,7 +8,7 @@ usage() exit 1 } -while getopts "a:t:A:n:N:d:g:c:f:" arg; do +while getopts "a:t:A:n:N:d:g:c:" arg; do case "${arg}" in a) artist="${OPTARG}" ;; t) title="${OPTARG}" ;; @@ -18,14 +18,13 @@ case "${arg}" in d) date="${OPTARG}" ;; g) genre="${OPTARG}" ;; c) comment="${OPTARG}" ;; - f) file="${OPTARG}" ;; *) usage ;; esac done shift $((OPTIND - 1)) file="${1}" -test ! -f "${file}" && echo "${0##*/}: file not found" && usage +test ! -f "${file}" && echo "${0##*/}: file not found: ${file}" && usage test -z "${title}" && read -erp "Title: " title test -z "${artist}" && read -erp "Artist: " artist @@ -39,12 +38,14 @@ temp="$(mktemp)" cp -f "${file}" "${temp}" ffmpeg \ -i "${temp}" \ - -map 0 -y -codec copy \ + -nostdin \ + -map 0 -y -c copy \ -metadata title="${title}" \ -metadata album="${album}" \ -metadata artist="${artist}" \ -metadata track="${track}${total:+/"${total}"}" \ ${date:+-metadata date="${date}"} \ ${genre:+-metadata genre="${genre}"} \ - ${comment:+-metadata comment="${comment}"} "${file}" + ${comment:+-metadata comment="${comment}"} \ + "${file}" rm -f ${temp} diff --git a/vds b/vds @@ -2,7 +2,7 @@ PLAYLIST="${HOME}/shit/playlist" -while getopts p: arg; do +while getopts "p:" arg; do case "${arg}" in p) PLAYLIST="${OPTARG}" ;; *) echo "usage: ${0##*/} [-p playlist]" 1>&2 diff --git a/vmstart b/vmstart @@ -13,7 +13,7 @@ disk="disk.img" tap="tap0" vnc="no" -while getopts c:C:d:g:G:i:m:t:uv arg; do +while getopts "c:C:d:g:G:i:m:t:uv" arg; do case "${arg}" in c) cpu="${OPTARG}" ;; C) com="${OPTARG}" ;; @@ -38,11 +38,11 @@ ifconfig "${tap}" up if [ -n "${grubdrv}" ]; then echo "(hd0) disk.img" > device.map - test -n "${img}" && echo "(cd0) ${img}" >> device.map + ${img:+(cd0) ${img}} >> device.map grub-bhyve \ -m device.map \ -r ${grubdrv} \ - `test -n ${grubdir} && echo "-d ${grubdir}"` \ + ${grubdir:+-d ${grubdir}} \ -M ${mem} \ ${name} fi @@ -52,12 +52,12 @@ bhyve \ -c ${cpu} \ -m ${mem} \ -s 0,hostbridge \ - `test -n "${img}" && echo "-s 3,ahci-cd,${img}"` \ + ${img:+-s 3,ahci-cd,${img}} \ -s 4,ahci-hd,${disk} \ -s 5,virtio-net,${tap} \ `test ${vnc} = "yes" && echo "-s 29,fbuf,tcp=0.0.0.0:5900,wait"` \ -s 30,xhci,tablet \ -s 31,lpc \ - `test -n "${com}" && echo "-l com1,${com}"` \ - `test -n "${uefi}" && echo ${uefi}` \ + ${com:+-l com1,${com}} \ + ${uefi:+${uefi}} \ ${name} diff --git a/vmstop b/vmstop @@ -8,7 +8,7 @@ usage() tap="tap0" -while getopts t: arg; do +while getopts "t:" arg; do case "${arg}" in t) tap="${OPTARG}" ;; *) usage ;;