summaryrefslogtreecommitdiff
path: root/ezjail-config.sh
diff options
context:
space:
mode:
Diffstat (limited to 'ezjail-config.sh')
-rw-r--r--ezjail-config.sh43
1 files changed, 43 insertions, 0 deletions
diff --git a/ezjail-config.sh b/ezjail-config.sh
new file mode 100644
index 0000000..0b9d083
--- /dev/null
+++ b/ezjail-config.sh
@@ -0,0 +1,43 @@
1#!/bin/sh
2
3if [ -f /etc/ezjail.template ]; then
4 . /etc/ezjail.template
5
6 # we do need to install only once
7 # rm /etc/ezjail.template
8fi
9
10# set defaults
11ezjail_template_root=${ezjail_template_root:-"/basejail/config/_JAILNAME_"}
12ezjail_template_files=${ezjail_template_files:-""}
13ezjail_template_users=${ezjail_template_users:-""}
14ezjail_template_packages=${ezjail_template_packages:-""}
15
16# try to create users
17for user in $ezjail_template_users; do
18 TIFS=$IFS; IFS=:; set -- $user; IFS=$TIFS
19 if [ $# -eq 7 ]; then
20 name=$1; grouplist=$3; gidlist=$4
21
22 [ $2 ] && uid="-u $2" || uid=""
23 [ $5 ] && pass=$5 || pass="*"
24 [ $6 ] && home=$6
25 [ $7 ] && shell="-s $7"
26
27 [ x$6 = x${6#-} ] && mkhome="-r" || mkhome=""; home=${6#-}
28 [ $home ] && home="-h $home";
29
30 if [ $grouplist ]; then
31 gc=1
32 for $group in `echo $grouplist | tr "," " "`; do
33 gid=`echo $gidlist | cut -d , -f $gc`; [ $gid ] && gid="-n $gid"
34 echo pw groupadd -n $group $gid
35 gc=(($gc + 1))
36 done
37 endif
38 if [ $name ]; then
39 echo pw useradd $name $uid $shell $home $grouplist
40 fi
41 fi
42
43done