summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2005-11-08 15:11:51 +0000
committererdgeist <erdgeist@erdgeist.org>2005-11-08 15:11:51 +0000
commitcb9940f7341d63e385d804464fb1939de9a4e6e1 (patch)
tree28facca25b896e90e93f50faf7967b5e6dd82b9e
parent6ca864f1251d64fb0bf647be29cd5a14a88d583e (diff)
Start of default config sub system
-rw-r--r--ezjail-config.sh43
-rw-r--r--ezjail.template36
2 files changed, 79 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
diff --git a/ezjail.template b/ezjail.template
new file mode 100644
index 0000000..3f7ebb1
--- /dev/null
+++ b/ezjail.template
@@ -0,0 +1,36 @@
1# ezjail template example
2# refer to ezjail(5) for more information
3#
4# ezjails jail init script tries to create the following users. Format is
5# as follows:
6#
7# username:<uid>:group[,group,...]:<gid[,gid,...]>:cryptpw:[-]homedir:shell
8#
9# Example:
10#
11# ezjail_template_users=\
12# "admin::wheel::$1$p75bbfK.$Kz3dwkoVlgZrfLZdAXQt91:/home/admin:/bin/sh \
13# pgsql:1002:pgsql:1002:*:-/usr/local/psql:/bin/nologin \
14# ::heroes:1003::::"
15
16# ezjails init script tries to install all files listed here from the path
17# specified in the ezjail_template_root variable root to the corresponding
18# location inside the jail. Directories are being copied recursive. Format
19# is as follows:
20#
21# user:group:file(s)
22#
23# Example:
24#
25# ezjail_template_root=/basejail/config/_JAILNAME_
26# ezjail_template_files=\
27# "root:wheel:/etc/{resolv,rc,make}.conf \
28# admin:wheel:/home/admin/"
29
30# ezjails jail init script tries to install packages specified in the
31# ezjail_template_packages variable. All packages without an absolute
32# path are assumed to be located in /basejail/config/pkg
33#
34# Example:
35#
36# ezjail_template_packages="sudo-1.6.8.9.tbz pico-4.64.tbz"