#!/bin/sh PREREQ="" DESCRIPTION="Configuration of LliureX live user..." prereqs() { echo "$PREREQ" } case $1 in # get pre-requisites prereqs) prereqs exit 0 ;; esac . /scripts/casper-functions log_begin_msg "$DESCRIPTION" [ ! -f /root/etc/default/user-setup ] || . /root/etc/default/user-setup # check the conf file LLIUREX_USERS_DIR="/root/etc/lliurex-live-scripts/users" if [ -d "$LLIUREX_USERS_DIR" ] ; then # read users conf files line by line: # username:crypt password:space separated list of groups for U_FILE in $(ls $LLIUREX_USERS_DIR) ; do USER_FILE="${LLIUREX_USERS_DIR}/${U_FILE}" if [ -f "$USER_FILE" ] ; then cat "$USER_FILE" |while read line ; do LLX_USER="${line%%:*}" if [ "$LLX_USER" ] ; then # check user and get group list in the chroot REAL_GROUP_LIST="$(chroot /root id $LLX_USER 2> /dev/null |sed -e "s%.* gid=%%")" if [ "$REAL_GROUP_LIST" ] ; then line="${line#*:}" # set passwd LLX_PASS="${line%%:*}" [ -z "$LLX_PASS" ] || chroot /root usermod -p "$LLX_PASS" "$LLX_USER" > /dev/null 2> /dev/null # get group list LLX_GROUPS=$(echo ${line#*:}) [ "$LLX_GROUPS" ] || LLX_GROUPS="$USER_SETUP_DEFAULT_GROUPS $USER_SETUP_EXTRA_GROUPS" for g in ${LLX_GROUPS} ; do if ! echo "$REAL_GROUP_LIST" |grep -q "(${g})" ; then # we need to add user to group # for sanity, create group first chroot /root groupadd -f "$g" > /dev/null 2> /dev/null chroot /root usermod -aG "$g" "$LLX_USER" > /dev/null 2> /dev/null fi done fi fi done fi done fi log_end_msg