Comment field added to adduser line, install files and packages rudiments
This commit is contained in:
parent
8aac89898b
commit
29bde9a891
@ -1,14 +1,16 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# BEFORE: rcconf
|
||||||
|
|
||||||
if [ -f /etc/ezjail.template ]; then
|
if [ -f /etc/ezjail.template ]; then
|
||||||
. /etc/ezjail.template
|
. /etc/ezjail.template
|
||||||
|
|
||||||
# we do need to install only once
|
# we do need to install only once
|
||||||
# rm /etc/ezjail.template
|
# rm -f /etc/ezjail.template
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# set defaults
|
# set defaults
|
||||||
ezjail_template_root=${ezjail_template_root:-"/basejail/config/_JAILNAME_"}
|
ezjail_template_root=${ezjail_template_root:-"/basejail/config/default"}
|
||||||
ezjail_template_files=${ezjail_template_files:-""}
|
ezjail_template_files=${ezjail_template_files:-""}
|
||||||
ezjail_template_users=${ezjail_template_users:-""}
|
ezjail_template_users=${ezjail_template_users:-""}
|
||||||
ezjail_template_packages=${ezjail_template_packages:-""}
|
ezjail_template_packages=${ezjail_template_packages:-""}
|
||||||
@ -16,28 +18,49 @@ ezjail_template_packages=${ezjail_template_packages:-""}
|
|||||||
# try to create users
|
# try to create users
|
||||||
for user in $ezjail_template_users; do
|
for user in $ezjail_template_users; do
|
||||||
TIFS=$IFS; IFS=:; set -- $user; IFS=$TIFS
|
TIFS=$IFS; IFS=:; set -- $user; IFS=$TIFS
|
||||||
if [ $# -eq 7 ]; then
|
|
||||||
name=$1; grouplist=$3; gidlist=$4
|
|
||||||
|
|
||||||
[ $2 ] && uid="-u $2" || uid=""
|
if [ $# -eq 8 ]; then
|
||||||
[ $5 ] && pass=$5 || pass="*"
|
gc=1; name=$1; grouplist=$3; gidlist=$4; home=$7
|
||||||
[ $6 ] && home=$6
|
|
||||||
[ $7 ] && shell="-s $7"
|
|
||||||
|
|
||||||
[ x$6 = x${6#-} ] && mkhome="-r" || mkhome=""; home=${6#-}
|
[ $2 ] && uid="-u $2" || uid=""
|
||||||
[ $home ] && home="-h $home";
|
[ $5 ] && comment="-c \"`echo $5 | tr _ ' '`\"" || comment=""
|
||||||
|
[ $6 ] && pass="$6" || pass="*"
|
||||||
|
[ $8 ] && shell="-s $8" || shell=""
|
||||||
|
|
||||||
|
[ "$home" = "${home#-}" ] && mkhome="-m" || mkhome=""
|
||||||
|
[ ${home#-} ] && home="-d ${home#-}" || home=""
|
||||||
|
|
||||||
|
# ensure all groups
|
||||||
if [ $grouplist ]; then
|
if [ $grouplist ]; then
|
||||||
gc=1
|
for group in `echo $grouplist | tr "," " "`; do
|
||||||
for $group in `echo $grouplist | tr "," " "`; do
|
gid=`echo $gidlist | cut -d , -f $gc`; [ $gid ] && gid="-g $gid"
|
||||||
gid=`echo $gidlist | cut -d , -f $gc`; [ $gid ] && gid="-n $gid"
|
pw groupadd -n $group $gid
|
||||||
echo pw groupadd -n $group $gid
|
gc=$((1+$gc))
|
||||||
gc=(($gc + 1))
|
|
||||||
done
|
done
|
||||||
endif
|
|
||||||
if [ $name ]; then
|
|
||||||
echo pw useradd $name $uid $shell $home $grouplist
|
|
||||||
fi
|
fi
|
||||||
|
# create user
|
||||||
|
[ $grouplist ] && grouplist="-G $grouplist"
|
||||||
|
[ $name ] && echo "$pass" | pw useradd -n $name $uid $shell $mkhome $home $grouplist $comment -H 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# try to install files
|
||||||
|
cd $ezjail_template_root
|
||||||
|
for file in $ezjail_template_files; do
|
||||||
|
TIFS=$IFS; IFS=:; set -- $file; IFS=$TIFS
|
||||||
|
|
||||||
|
if [ $# -eq 3 -a "$3" ]; then
|
||||||
|
owner=$1; [ $2 ] && owner="$1:$2"
|
||||||
|
for file in $3; do
|
||||||
|
find ${file#/} | cpio -p -d /
|
||||||
|
chown -R $owner $file
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# finally install packages
|
||||||
|
[ -d /basejail/config/pkg ] && cd /basejail/config/pkg
|
||||||
|
[ $ezjail_template_packages ] && pkg_add $ezjail_template_packages
|
||||||
|
|
||||||
|
# Get rid off ourself
|
||||||
|
rm -f /etc/rc.d/ezjail-config.sh
|
||||||
|
@ -4,13 +4,13 @@
|
|||||||
# ezjails jail init script tries to create the following users. Format is
|
# ezjails jail init script tries to create the following users. Format is
|
||||||
# as follows:
|
# as follows:
|
||||||
#
|
#
|
||||||
# username:<uid>:group[,group,...]:<gid[,gid,...]>:cryptpw:[-]homedir:shell
|
# username:uid:group[,group,..]:gid[,gid,..]:fullname:cryptpw:[-]homedir:shell
|
||||||
#
|
#
|
||||||
# Example:
|
# Example:
|
||||||
#
|
#
|
||||||
# ezjail_template_users='::heroes:1003::: \
|
# ezjail_template_users='::heroes:1003:::: \
|
||||||
# admin::wheel::$1$p75bbfK.$Kz3dwkoVlgZrfLZdAXQt91:/home/admin:/bin/sh \
|
# admin::wheel::"Admin User":$1$p75bbfK.$Kz3dwkoVlgZrfLZdAXQt91:/home/admin:/bin/sh \
|
||||||
# pgsql:1002:pgsql:1002::-/usr/local/psql:/bin/nologin'
|
# pgsql:1002:pgsql:1002:"PostGres"::-/usr/local/psql:/bin/nologin'
|
||||||
|
|
||||||
# ezjails init script tries to install all files listed here from the path
|
# ezjails init script tries to install all files listed here from the path
|
||||||
# specified in the ezjail_template_root variable root to the corresponding
|
# specified in the ezjail_template_root variable root to the corresponding
|
||||||
|
Loading…
x
Reference in New Issue
Block a user