dot

packages and services management
Log | Files | Refs | README

commit 2f782001fde98444b1ed046a2c159dba342d630e
parent 5683caff8b9b001edaadef3f5727779c78fc6881
Author: Josuah Demangeon <josuah.demangeon@gandi.net>
Date:   Thu, 10 Aug 2017 10:02:34 +0200

git, pkg/bin: configure script and users setup

Diffstat:
Mex-vi/.exrc | 1-
Mgit/bin/git-index | 5++---
Mgit/start | 2+-
Mpkg/bin/pkg-configure | 58+++++++++++++++++++++++++++++++++++++++++++++++++++-------
Mshell/profile | 5++---
5 files changed, 56 insertions(+), 15 deletions(-)

diff --git a/ex-vi/.exrc b/ex-vi/.exrc @@ -1,4 +1,3 @@ -set number set showmode set showmatch set autoindent diff --git a/git/bin/git-index b/git/bin/git-index @@ -2,7 +2,7 @@ NAME="${1##*/}" HEADER='<!doctype html><html> <head> <meta charset="utf-8"/> -<style> pre { float: left; margin: 4em; } </style> +<style> pre { float: left; margin: 4em 0 4em 4em; } </style> </head> <body> <pre> @@ -67,8 +67,7 @@ cd "git/$NAME" || exit 1 printf '</pre><pre>' - git -C "$1" log --graph --date=short \ - --format='%H %cd %cn <%ce>%n%n %s%n' | + git -C "$1" log --graph --date=short --format='%H %cd %cn <%ce>%n%s%n' | sed -r ' s|&|\&amp;|g s|<|\&lt;|g diff --git a/git/start b/git/start @@ -1 +1 @@ -git daemon --base-path="$GIT" & PID=$! +git daemon --base-path="$GIT" --export-all & PID=$! diff --git a/pkg/bin/pkg-configure b/pkg/bin/pkg-configure @@ -1,13 +1,57 @@ ROOT="${ROOT:-$HOME}" -PKG="${PKG:-$ROOT/pkg}" -ETC="${ETC:-$ROOT/etc}" +ETC="${ETC:-$ETC}" +PKG="${PKG:-$PKG}" -find "$PKG" -path "$PKG/*/.*" | while IFS='' read -r path + +# --- dotfiles ----------------------------------------------------------------- + +find "$PKG/${1:-}" -path "$ROOT/pkg/*/.*" | while IFS='' read -r path do - [ -d "$path" ] && mkdir -p "$ROOT/${path#$PKG/*/}" - [ -f "$path" ] && ln -sf "$path" "$ROOT/${path#$PKG/*/}" + [ -d "$path" ] && mkdir -p "$HOME/${path#$PKG/*/}" + [ -f "$path" ] && ln -sf "$path" "$HOME/${path#$PKG/*/}" done -find -L "$ROOT" -type l -exec rm {} + +find -L "$ROOT" -type l -exec rm {} + 2> /dev/null + + +# --- crontab ------------------------------------------------------------------ + +[ -f "$PKG/$1/cron" ] && cp "$ROOT/pkg/$1/cron" > "$ETC/cron.d/$1" + + +# --- user --------------------------------------------------------------------- + +if [ ! -f "$PKG/$1/user" ] +then printf 'no user to add for %s\n' '$1" + +elif [ "$(whoami)" = root ] +then useradd -f "$PKG/$1/user" + +elif command -v doas +then doas useradd -f "$PKG/$1/user" + +elif command -v sudo +then sudo useradd -f "$PKG/$1/user" + +elif command -v su +then su -c 'useradd -f "$1"' "$PKG/$1/user" +fi + + +# --- setup -------------------------------------------------------------------- + +if [ ! -f "$1/setup" ] +then printf 'no setup needed for %s\n' "$1" + +elif [ "$(whoami)" = root ] +then sh "$PKG/$1/setup" + +elif command -v doas +then doas sh "$PKG/$1/setup" + +elif command -v sudo +then sudo sh "$PKG/$1/setup" -cat "$PKG"/*/cron > "$ETC/crontab" +elif command -v su +then su -c 'sh "$1"' "$PKG/$1/setup" +fi diff --git a/shell/profile b/shell/profile @@ -15,6 +15,5 @@ export NICK='josuah' export MAIL="$HOME/var/mail/INBOX" export EMAIL='mail@josuah.net' -export EDITOR='less -N' VISUAL='less -N' PAGER=less MANPAGER=less -command -v rlwrap > /dev/null && LESSEDIT='rlwrap' || LESSEDIT='' -export LESSEDIT="$LESSEDIT vi -c %lm %f" +export EDITOR=vi VISUAL=$EDITOR +export PAGER=less MANPAGER=$PAGER