dot

packages and services management
Log | Files | Refs | README

commit f3840502945e2967787eb7539ae123fb945c31f5
parent e5a594c3ef02d5111f90898b135803a09c1ebe25
Author: Josuah Demangeon <mail@josuah.net>
Date:   Sun, 16 Dec 2018 23:17:13 +0100

service-*: fix handling of autobundles and cosmetic change

Diffstat:
Mbin/group-valid | 12++++--------
Mbin/service-compile | 6+++---
Mbin/service-list | 8++++----
Mbin/user-add | 16++++++++--------
Mbin/user-group | 12++++++++----
Mbin/user-home | 2+-
Mbin/user-pass | 5++---
Mbin/user-valid | 10+++-------
8 files changed, 33 insertions(+), 38 deletions(-)

diff --git a/bin/group-valid b/bin/group-valid @@ -2,12 +2,8 @@ elgetpositionals forx -o 0 x { ${@} } -importas user x +importas group x -ifelse -n { heredoc 0 ${1} grep -q "^[a-z][-a-z0-9]*$" } - { if { echo "user-valid: \"${user}\" has invalid character" } exit 2 } - -ifelse { grep -q "^${1}:" /etc/group } - { if { echo "user-valid: \"${user}\" already exist" } exit 3 } - -exit 0 +ifelse { heredoc 0 ${1} grep -q "^[a-z][-a-z0-9]*$" } { exit 0 } +if { fdmove -c 1 2 echo "group-valid: \"${group}\" has invalid character" } +exit 2 diff --git a/bin/service-compile b/bin/service-compile @@ -13,9 +13,9 @@ if { } importas base x - if -t { - if -n { test -f ${base}/type } - if -n { grep -Fxq bundle ${base}/type } + if -nt { + if { test -d ${base}/type } + if { grep -Fxvq bundle ${base}/type } } if { mkdir -p ${base} } if { redirfd -w 1 ${base}/type echo bundle } diff --git a/bin/service-list b/bin/service-list @@ -15,10 +15,10 @@ importas service x backtick -n x { pipeline { s6-svstat -o up,wantedup /var/s6/scandir/${service} } sed " - s/true true/+/ - s/true false/?/ - s/false true/!/ - s/false false/ / + s/true true/ ok / + s/true false/ no / + s/false true/fail/ + s/false false/down/ " } importas flag x diff --git a/bin/user-add b/bin/user-add @@ -1,12 +1,12 @@ #!/usr/bin/env execlineb +multisubstitute { + importas user 1 + importas main 2 +} +shift -n 2 elgetpositionals -if { user-valid ${@} } -if { group-valid ${@} } +if { group-add ${main} ${@} } -backtick -n x { cut -d ":" -f 3 /etc/passwd } -importas id - -forx -o 0 x { ${@} } -importas user x -redirfd -a /etc/passwd ${user}:x: +backtick -n x { dollarat -n -d , } +importas groups x diff --git a/bin/user-group b/bin/user-group @@ -1,10 +1,14 @@ #!/usr/bin/env execlineb +multisubstitute { + importas user 1 + importas main 2 +} +shift -n 2 elgetpositionals -shift -n 1 -if { group-add $@ } +if { group-add ${main} $@ } forbacktickx -n -o 0 x { dollarat -n -d , } -importas group x +importas groups x -usermod -g ${user} -G $1 ${user} +usermod -g ${main} -G ${groups} ${user} diff --git a/bin/user-home b/bin/user-home @@ -1,4 +1,4 @@ #!/usr/bin/env execlineb elgetpositionals -usermod -d $2 $1 +awk -F : /usr/ diff --git a/bin/user-pass b/bin/user-pass @@ -1,5 +1,4 @@ #!/usr/bin/env execlineb -importas -i user 1 +elgetpositionals -forbacktickx -n x { dollarat } importas user x -passwd $user +passwd ${1} diff --git a/bin/user-valid b/bin/user-valid @@ -4,10 +4,6 @@ elgetpositionals forx -o 0 x { ${@} } importas user x -ifelse -n { heredoc 0 ${1} grep -q "^[a-z][-a-z0-9]*$" } - { if { echo "user-valid: \"${user}\" has invalid character" } exit 2 } - -ifelse { grep -q "^${1}:" /etc/passwd } - { if { echo "user-valid: \"${user}\" already exist" } exit 3 } - -exit 0 +ifelse { heredoc 0 ${1} grep -q "^[a-z][-a-z0-9]*$" } { exit 0 } +if { fdmove -c 1 2 echo "user-valid: \"${user}\" has invalid character" } +exit 2