cl-user-tools-0.2/000075500000000000000000000000001113633740600140655ustar00rootroot00000000000000cl-user-tools-0.2/scripts/000075500000000000000000000000001113633740600155545ustar00rootroot00000000000000cl-user-tools-0.2/scripts/cl-config000075500000000000000000000015031113633740600173420ustar00rootroot00000000000000#!/bin/sh -efu if [ -z "${__included_cl_config-}" ]; then __included_cl_config=1 . shell-config cl_slapd_config() { local SLAPD_CONF="/etc/openldap/sldap-generated.conf" [ "$#" -ge 1 ] && SLAPD_CONF="$1" base=$(shell_config_get "$SLAPD_CONF" suffix ' '|sed -e 's/"//g') binddn=$(shell_config_get "$SLAPD_CONF" rootdn ' '|sed -e 's/"//g') bindpw=$(shell_config_get "$SLAPD_CONF" rootpw ' '|sed -e 's/"//g') [ -n "$bindpw" ] && bindpw="-w $bindpw" || bindpw="-W" export base binddn bindpw } local_getent_group() { local group="$1" if [ -n "$group" ]; then grep -v "^#" /etc/group | grep "^$group:" else grep -v "^#" /etc/group fi } local_getent_passwd() { local user="$1" if [ -n "$user" ]; then grep -v "^#" /etc/passwd | grep "^$user:" else grep -v "^#" /etc/passwd fi } fi #__included_cl_config cl-user-tools-0.2/scripts/cl-groupadd000075500000000000000000000023721113633740600177070ustar00rootroot00000000000000#!/bin/sh -e . cl-config [ "$#" -ge 2 ] || fatal "more arguments required" config="$1" group="$2" shift 2 cl_slapd_config "$config" #check for name local_getent_group "$group" | grep -qs "^$group:" && fatal "same name already exists" ldap-getent-group "$config" "$group" | grep -qs "^$group:" && fatal "same name already exists" #calculate gid local_gid_avail="$(local_getent_group| cut -f3 -d: |sort -unr|head -n1)" ldap_gid_avail="$(ldap-getent-group "$config"| cut -f3 -d: |sort -unr|head -n1)" #[ "$local_gid_avail" -gt "$ldap_gid_avail" ] && gid_avail="$local_gid_avail" || gid_avail="$ldap_gid_avail" [ -n "$ldap_gid_avail" ] && [ "$local_gid_avail" -lt "$ldap_gid_avail" ] && gid_avail="$ldap_gid_avail" || gid_avail="$local_gid_avail" gid_min="${gid_min:-$(sed -rn 's,^GID_MIN[[:space:]]+([^[:space:]]+),\1,p' /etc/login.defs)}" gid_max="${gid_max:-$(sed -rn 's,^GID_MAX[[:space:]]+([^[:space:]]+),\1,p' /etc/login.defs)}" gid=$(( $gid_avail + 1 )) [ "$gid" -le "$gid_max" ] || fatal "not free gid available" [ "$gid" -lt "$gid_min" ] && gid="$gid_min" message "using gid - $gid" #edit ldap ldapadd -a -D "$binddn" $bindpw -x <