dot

packages and services management
Log | Files | Refs | README

commit 3fd273b6c5dedb9794781f900cc872d95fc2f442
parent 516b7b7184293e3004769977fccfc32969e90bf0
Author: Josuah Demangeon <mail@josuah.net>
Date:   Mon, 29 Jan 2018 19:20:32 +0100

daemon scripts not dependent of daemon(1)

Diffstat:
Mbin/daemon | 34++++++++++++++++++++--------------
Mdaemon/crond | 7+++++--
Mdaemon/geomyidae | 13+++++++++++--
Mdaemon/git | 12++++++++++--
Mdaemon/ii | 17+++++++++++++----
Mdaemon/inetd | 6++++--
Ddaemon/monitor | 4----
Mdaemon/ngircd | 8++++++--
Mdaemon/opentracker | 7+++++--
Mdaemon/quark | 11+++++++++--
Mdaemon/ratox | 11++++++++---
Mdaemon/tor | 6++++--
Mdot/profile | 96++++++++++++++++++++++++++++++++++++++++----------------------------------------
13 files changed, 143 insertions(+), 89 deletions(-)

diff --git a/bin/daemon b/bin/daemon @@ -1,29 +1,35 @@ #!/bin/sh -mkdir -p "$HOME/.cache/log" +export LOG="${HOME}/.cache/log" -cmd=$1 -[ $# -gt 1 ] && shift +mkdir -p "${LOG}" -case $cmd in +case "${1}" in ('') - ls -1 "$HOME/etc/daemon" | while IFS='' read -r svc + find "${HOME}/etc/daemon" -type f -mindepth 1 | sort | sed 's|.*/||' | + while IFS='' read -r service do - printf '%-14s: %s\n' "$svc" "$(pgrep -x "$svc" | tr '\n' ' ')" + printf '%-14s: %s\n' "${service}" \ + "$(pgrep -x "${service}" | tr '\n' ' ')" done ;; (start) - s=$1 - shift - [ -f "$HOME/etc/daemon/$s" ] || exec printf '%s: no script found\n' "$s" - sh "$HOME/etc/daemon/$s" "$@" >> "$HOME/.cache/log/$s" 2>&1 - printf '%-14s: %s\n' "$s" "$(pgrep -x "$s" | tr '\n' ' ')" + service="${2}" + shift 2 + + [ -f "${HOME}/etc/daemon/${service}" ] || + exec printf '%s: no script found\n' "${service}" + + "${HOME}/etc/daemon/${service}" "$@" + + printf '%-14s: %s\n' "${service}" \ + "$(pgrep -x "${service}" | tr '\n' ' ')" ;; (stop) - pkill -x "$1" - printf '%-14s: %s\n' "$1" "$(pgrep -x "$1" | tr '\n' ' ')" + pkill -x "${2}" + printf '%-14s: %s\n' "${1}" "$(pgrep -x "${1}" | tr '\n' ' ')" ;; (*) - printf 'usage: daemon [start service | stop service]\n' + printf 'usage: daemon [start <service> | stop <service>]\n' ;; esac diff --git a/daemon/crond b/daemon/crond @@ -1,3 +1,6 @@ -#!/bin/sh +#!/bin/sh -e -exec crond -f "$HOME/.config/crontab" & +exec crond \ + -f "/etc/crontab" \ + 1> "${LOG}/crond" \ + 2> "${LOG}/crond" & diff --git a/daemon/geomyidae b/daemon/geomyidae @@ -1,3 +1,12 @@ -#!/bin/sh +#!/bin/sh -e -exec geomyidae -b "$1" -p "${2:-70}" -h josuah.net +path="${1:-${HOME}/srv}" +port="${2:-70}" +host="${3:-josuah.net}" + +exec geomyidae \ + -b "${path}" \ + -p "${port}" \ + -h "${host}" \ + 1> "${LOG}/geomyidae" \ + 2> "${LOG}/geomyidae" & diff --git a/daemon/git b/daemon/git @@ -1,3 +1,11 @@ -#!/bin/sh +#!/bin/sh -e -exec git daemon --base-path="$HOME/srv/git" --export-all --port=9000 & +path="${1:-${HOME}/srv/git}" +port="${2:-9000}" + +exec git daemon \ + --base-path="${path}" \ + --export-all \ + --port="${port}" \ + 1> "${LOG}/git" \ + 2> "${LOG}/git" & diff --git a/daemon/ii b/daemon/ii @@ -1,7 +1,16 @@ -#!/bin/sh +#!/bin/sh -e -p=${2:-6667} +host="${1:?host required}" +port="${2:-6667}" -mkdir -p "$HOME/.cache/irc" +mkdir -p "${HOME}/${VAR}/${1}" "${HOME}/${LOG}/ii" -exec ii -s "$1" -i "$HOME/.cache/irc" -p "$p" -n "$NICK" -k PASS -f "$NAME" & +exec ii \ + -s "${host}" \ + -i "${HOME}/.cache/irc" \ + -p "${port}" \ + -n "${NICK}" \ + -k PASS \ + -f "${NAME}" \ + 1> "${VAR}/irc/${host}/log" \ + 2> "${LOG}/ii/${host}" & diff --git a/daemon/inetd b/daemon/inetd @@ -1,3 +1,5 @@ -#!/bin/sh +#!/bin/sh -e -exec inetd -d "$HOME/.config/inet" & +exec inetd \ + 1> "${LOG}/inetd" \ + 2> "${LOG}/inetd" & diff --git a/daemon/monitor b/daemon/monitor @@ -1,4 +0,0 @@ -#!/bin/sh - -mkdir -p "$HOME/.cache/stat/data" -vmstat "${1:-15}" | monitor > "$HOME/.cache/stat/data" & diff --git a/daemon/ngircd b/daemon/ngircd @@ -1,3 +1,7 @@ -#!/bin/sh +#!/bin/sh -e -exec ngircd -nf "/etc/ngircd/conf" & +exec ngircd \ + -n \ + -f "/etc/ngircd/conf" \ + 1> "${LOG}/ngircd" \ + 2> "${LOG}/ngircd" & diff --git a/daemon/opentracker b/daemon/opentracker @@ -1,3 +1,6 @@ -#!/bin/sh +#!/bin/sh -e -exec opentracker -d "$SYSROOT/.cache/torrent" & +exec opentracker \ + -d "${VAR}/torrent" \ + 1> "${LOG}/opentracker" \ + 2> "${LOG}/opentracker" & diff --git a/daemon/quark b/daemon/quark @@ -1,3 +1,10 @@ -#!/bin/sh +#!/bin/sh -e -exec quark -h 0.0.0.0 -d "$1" -V & +path="${1:-${HOME}/srv}" + +exec quark \ + -h 0.0.0.0 \ + -d "${path}" \ + -V \ + 1> "${LOG}/quark" \ + 2> "${LOG}/quark" & diff --git a/daemon/ratox b/daemon/ratox @@ -1,5 +1,10 @@ -#!/bin/sh +#!/bin/sh -e -cd "$HOME/.cache/ratox" +path="${1:-${VAR}/ratox}" -exec ratox & +mkdir -p "${path}" +cd "${path}" + +exec ratox \ + 1> "${LOG}/ratox" \ + 2> "${LOG}/ratox" & diff --git a/daemon/tor b/daemon/tor @@ -1,3 +1,5 @@ -#!/bin/sh +#!/bin/sh -e -exec tor & +exec tor \ + 1> "${LOG}/geomyidae" \ + 2> "${LOG}/geomyidae" & diff --git a/dot/profile b/dot/profile @@ -1,53 +1,53 @@ -export NAME="Josuah Demangeon" -export TZ="Europe/Paris" -export NICK="josuah" - -export EMAIL="mail@josuah.net" -export MAILTO="$EMAIL" -export MAIL="$HOME/.cache/mail/mbox" -export MAILDIR="$HOME/.cache/mail" - -export EDITOR="edit" -export ISUAL="edit" -export PAGER="less" -export MANPAGER="less" - -export LOG="$HOME/.cache/log" - -export PLAN9="$HOME/.local/src/plan9" -export PATH="$HOME/etc/bin:$HOME/.local/bin:$PATH:$PLAN9/bin" -export MANPATH="$HOME/etc/man:/usr/share/man:/usr/local/man" -export MANPATH="$HOME/.local/share/man:$MANPATH:$PLAN9/man" -export C_INCLUDE_PATH="$HOME/.local/include" -export LIBRARY_PATH="$HOME/.local/lib:/usr/local/lib/inotify" -export LD_LIBRARY_PATH="$HOME/.local/lib:/usr/local/lib/inotify" - -export LANG=en_US.UTF-8 -export LC_LC_COLLATE=C -export LC_CTYPE=en_US.UTF-8 -export LC_MONETARY=en_US.UTF-8 -export LC_MESSAGES=en_US.UTF-8 -export LC_NUMERIC=en_US.UTF-8 -export LC_TIME=en_US.UTF-8 - -export BLIH="josuah.demangeon@epitech.eu" -export CVSROOT="anoncvs@anoncvs.fr.openbsd.org:/cvs" -export PKG_PATH="https://ftp.fr.openbsd.org/pub/OpenBSD/" - -export ABDUCO_SOCKET_DIR="$HOME/.cache" -export ABDUCO_CMD="dvtm-status" -export MBLAZE="$HOME/.config/mblaze" -export LESS="-R~X" -export LESSHISTFILE=- -export SSH_AUTH_SOCK="$HOME/.cache/ssh-agent" +export NAME='Josuah Demangeon' +export TZ='Europe/Paris' +export NICK='josuah' + +export EMAIL='mail@josuah.net' +export MAILTO="${EMAIL}" +export MAIL="${HOME}/.cache/mail/mbox" +export MAILDIR="${HOME}/.cache/mail" + +export EDITOR='edit' +export ISUAL='edit' +export PAGER='less' +export MANPAGER='less' + +export VAR="${HOME}/.cache" +export LOG="${VAR}/log" + +export PLAN9="${HOME}/.local/src/plan9" +export PATH="${HOME}/etc/bin:${HOME}/.local/bin:${PATH}:${PLAN9}/bin" +export MANPATH="${HOME}/etc/man:/usr/share/man:/usr/local/man" +export MANPATH="${HOME}/.local/share/man:${MANPATH}:${PLAN9}/man" +export C_INCLUDE_PATH="${HOME}/.local/include" +export LIBRARY_PATH="${HOME}/.local/lib:/usr/local/lib/inotify" +export LD_LIBRARY_PATH="${HOME}/.local/lib:/usr/local/lib/inotify" + +export LANG='en_US.UTF-8' +export LC_LC_COLLATE='C' +export LC_CTYPE='en_US.UTF-8' +export LC_MONETARY='en_US.UTF-8' +export LC_MESSAGES='en_US.UTF-8' +export LC_NUMERIC='en_US.UTF-8' +export LC_TIME='en_US.UTF-8' + +export BLIH='josuah.demangeon@epitech.eu' +export CVSROOT='anoncvs@anoncvs.fr.openbsd.org:/cvs' +export PKG_PATH='https://ftp.fr.openbsd.org/pub/OpenBSD/' +export ABDUCO_SOCKET_DIR="${HOME}/.cache" +export ABDUCO_CMD='dvtm-status' +export MBLAZE="${HOME}/.config/mblaze" +export LESS='-R~X' +export LESSHISTFILE='-' +export SSH_AUTH_SOCK="${HOME}/.cache/ssh-agent" export EXINIT='set ruler' -export PS1='$([ $? -gt 0 ] && printf "\033[31;1mx\033[m\n\r")'"$( - printf '\033]0;$PWD $(git-status)\a') -${SSH_TTY:+$(uname -n)}$ " - pgrep -x ssh-agent || { mkdir -p "${SSH_AUTH_SOCK%/*}" - rm -f "$SSH_AUTH_SOCK" - ssh-agent -a "$SSH_AUTH_SOCK" + rm -f "${SSH_AUTH_SOCK}" + ssh-agent -a "${SSH_AUTH_SOCK}" } + +export PS1='$([ "${?}" -gt 0 ] && printf "\033[31;1mx\033[m\n\r")' +export PS1="${PS1}$(printf '\033]0;${PWD} $(git-status)\a') +${SSH_TTY:+$(uname -n)}$ "