diff options
author | erdgeist <erdgeist@erdgeist.org> | 2006-02-08 16:23:31 +0000 |
---|---|---|
committer | erdgeist <erdgeist@erdgeist.org> | 2006-02-08 16:23:31 +0000 |
commit | 36adb5181c830b8fa9e946c544ea0e7c3e8ce73e (patch) | |
tree | a25b3bf4c0dca1d47dbd1360a6f18a89b80b6b30 /ezjail-config.sh | |
parent | 0e2bb6a9ec73da8ef90e8e7cce2bff8ce0f135e2 (diff) |
Simplyfing a lot of the code. Harder to read, now :(
Diffstat (limited to 'ezjail-config.sh')
-rw-r--r-- | ezjail-config.sh | 39 |
1 files changed, 11 insertions, 28 deletions
diff --git a/ezjail-config.sh b/ezjail-config.sh index 3a1d8ea..71080e2 100644 --- a/ezjail-config.sh +++ b/ezjail-config.sh | |||
@@ -13,49 +13,32 @@ fi | |||
13 | ezjail_flavour_users=${ezjail_flavour_users:-""} | 13 | ezjail_flavour_users=${ezjail_flavour_users:-""} |
14 | ezjail_flavour_files=${ezjail_flavour_files:-""} | 14 | ezjail_flavour_files=${ezjail_flavour_files:-""} |
15 | 15 | ||
16 | # try to create users | 16 | # try to create users, variables named after pw useradd params |
17 | for user in ${ezjail_flavour_users}; do | 17 | for user in ${ezjail_flavour_users}; do |
18 | TIFS=${IFS}; IFS=:; set -- ${user}; IFS=${TIFS} | 18 | TIFS=${IFS}; IFS=:; set -- ${user}; IFS=${TIFS} |
19 | if [ $# -eq 8 ]; then | 19 | if [ $# -eq 8 ]; then |
20 | gc=1; name=$1; grouplist=$3; gidlist=$4; home=$7 | 20 | u=${2:+-u$2}; G=$3; gs=$4; c=${5:+-c$5}; p=${6:-*}; d=${7#-}; m=${7%%[!-]*}; s=${8:+-s$8}; |
21 | |||
22 | [ $2 ] && uid="-u $2" || uid="" | ||
23 | [ $5 ] && comment="-c$5" || comment="" | ||
24 | [ $6 ] && pass="$6" || pass="*" | ||
25 | [ $8 ] && shell="-s $8" || shell="" | ||
26 | |||
27 | [ "${home}" = "${home#-}" ] && mkhome="-m" || mkhome="" | ||
28 | [ ${home#-} ] && home="-d ${home#-}" || home="" | ||
29 | 21 | ||
30 | # ensure all groups | 22 | # ensure all groups |
31 | if [ ${grouplist} ]; then | 23 | gc=1; for n in `echo -n ${G} | tr , ' '`; do |
32 | for group in `echo -n ${grouplist} | tr "," " "`; do | 24 | g=`echo -n ${gs} | cut -d , -f ${gc}` |
33 | gid=`echo ${gidlist} | cut -d , -f ${gc}`; [ "${gid}" ] && gid="-g ${gid}" | 25 | pw groupadd -q -n ${n} ${g:+-g${g}} |
34 | pw groupadd -n ${group} ${gid} | 26 | gc=$((1+${gc})) |
35 | gc=$((1+${gc})) | 27 | done |
36 | done | 28 | |
37 | fi | ||
38 | # create user | 29 | # create user |
39 | [ "${grouplist}" ] && grouplist="-G ${grouplist}" | 30 | [ $1 ] && echo ${p} | pw useradd -n $1 ${u} ${s} ${m:+-m} ${d:+-d${d}} ${G:+-G${G}} "`echo -n ${c} | tr = ' '`" -H 0 |
40 | [ "${name}" ] && echo "${pass}" | pw useradd -n ${name} ${uid} ${shell} ${mkhome} ${home} ${grouplist} "`echo -n${comment} | tr = ' '`" -H 0 | ||
41 | fi | 31 | fi |
42 | done | 32 | done |
33 | set +o noglob | ||
43 | 34 | ||
44 | # chmod all files not belonging to root | 35 | # chmod all files not belonging to root |
45 | for file in ${ezjail_flavour_files}; do | 36 | for file in ${ezjail_flavour_files}; do |
46 | TIFS=${IFS}; IFS=:; set -- ${file}; IFS=${TIFS} | 37 | TIFS=${IFS}; IFS=:; set -- ${file}; IFS=${TIFS} |
47 | set +o noglob | 38 | [ $# -gt 2 ] && owner="$1:$2" && shift 2 && chown -R ${owner} $* |
48 | if [ $# -eq 3 -a "$3" ]; then | ||
49 | owner=$1; [ $2 ] && owner="$1:$2" | ||
50 | for file in ./$3; do | ||
51 | chown -R ${owner} /${file} | ||
52 | done | ||
53 | fi | ||
54 | set -o noglob | ||
55 | done | 39 | done |
56 | 40 | ||
57 | # install packages | 41 | # install packages |
58 | set +o noglob | ||
59 | [ -d /pkg ] && PACKAGESITE=file:// pkg_add -r /pkg/* | 42 | [ -d /pkg ] && PACKAGESITE=file:// pkg_add -r /pkg/* |
60 | 43 | ||
61 | # source post install script | 44 | # source post install script |