diff --git a/logwrap/APKBUILD b/logwrap/APKBUILD new file mode 100644 index 0000000..f2e06eb --- /dev/null +++ b/logwrap/APKBUILD @@ -0,0 +1,20 @@ +# Contributor: Patrycja Rosa +# Maintainer: Patrycja Rosa +pkgname=logwrap +pkgver=1 +pkgrel=0 +pkgdesc="redirect logs based on program name" +url="https://git.ddd.rip/ptrcnull/ptrcports" +arch="noarch" +license="BSD-2-Clause" +source="logwrap" +builddir="$srcdir" +options="!check" + +package() { + install -Dm755 logwrap "$pkgdir"/usr/bin/logwrap +} + +sha512sums=" +afc36edbc97b0a0fa9d6e657abd45d8a625b3f4c88435196508586505d0678f2768186050f6601d3aaedd560b7a9cfc0d86fa7f4555d02ff3bebc2fe64401193 logwrap +" diff --git a/logwrap/logwrap b/logwrap/logwrap new file mode 100644 index 0000000..e0973b1 --- /dev/null +++ b/logwrap/logwrap @@ -0,0 +1,25 @@ +#!/bin/sh + +usage() { + echo "usage: logwrap [-n NAME] PROGRAM" + exit 1 +} + +[ $# = 0 ] && usage + +name="$1" +while getopts "n:" opt; do + case $opt in + 'n') name="$OPTARG" ;; + *) echo "unknown option: $opt"; usage ;; + esac +done +shift $(( $OPTIND - 1 )) + +dir=/var/log +if [ "$(id -u)" != 0 ]; then + dir="$HOME"/.local/var/log +fi +mkdir -p "$dir" + +exec "$@" >> "$dir/$name.log" 2>&1