logwrap: new ptrcport
This commit is contained in:
parent
c8ede93e65
commit
d386af3e80
2 changed files with 45 additions and 0 deletions
20
logwrap/APKBUILD
Normal file
20
logwrap/APKBUILD
Normal file
|
@ -0,0 +1,20 @@
|
|||
# Contributor: Patrycja Rosa <alpine@ptrcnull.me>
|
||||
# Maintainer: Patrycja Rosa <alpine@ptrcnull.me>
|
||||
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
|
||||
"
|
25
logwrap/logwrap
Normal file
25
logwrap/logwrap
Normal file
|
@ -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
|
Loading…
Reference in a new issue