diff options
-rwxr-xr-x | Makefile | 10 | ||||
-rwxr-xr-x | ezjail-admin | 14 | ||||
-rw-r--r-- | ezjail-config.sh | 22 |
3 files changed, 33 insertions, 13 deletions
@@ -1,8 +1,16 @@ | |||
1 | # I know, this is ain't nice but an empty prefix leads to much confusion | ||
2 | # In most cases ezjail is being installed from ports anyway. If you REALLY REALLY | ||
3 | # want / as your install location, DO set PREFIX before invoking this Makefile | ||
4 | |||
5 | PREFIX?=/usr/local | ||
6 | |||
1 | all: | 7 | all: |
2 | 8 | ||
3 | install: | 9 | install: |
4 | mkdir -p ${PREFIX}/etc/ezjail/ ${PREFIX}/man/man1/ ${PREFIX}/man/man5/ ${PREFIX}/etc/rc.d/ ${PREFIX}/bin/ | 10 | mkdir -p ${PREFIX}/etc/ezjail/ ${PREFIX}/man/man1/ ${PREFIX}/man/man5/ ${PREFIX}/etc/rc.d/ ${PREFIX}/bin/ ${PREFIX}/share/ezjail ${PREFIX}/share/examples/ezjail |
5 | cp -p ezjail.conf.sample ${PREFIX}/etc/ | 11 | cp -p ezjail.conf.sample ${PREFIX}/etc/ |
12 | cp -p ezjail-config.sh ${PREFIX}/share/ezjail/ | ||
13 | cp -p ezjail.flavour.default ${PREFIX}/share/examples/ezjail/ | ||
6 | sed s:EZJAIL_PREFIX:${PREFIX}: ezjail.sh > ${PREFIX}/etc/rc.d/ezjail.sh | 14 | sed s:EZJAIL_PREFIX:${PREFIX}: ezjail.sh > ${PREFIX}/etc/rc.d/ezjail.sh |
7 | sed s:EZJAIL_PREFIX:${PREFIX}: ezjail-admin > ${PREFIX}/bin/ezjail-admin | 15 | sed s:EZJAIL_PREFIX:${PREFIX}: ezjail-admin > ${PREFIX}/bin/ezjail-admin |
8 | sed s:EZJAIL_PREFIX:${PREFIX}: man1/ezjail-admin.1 > ${PREFIX}/man/man1/ezjail-admin.1 | 16 | sed s:EZJAIL_PREFIX:${PREFIX}: man1/ezjail-admin.1 > ${PREFIX}/man/man1/ezjail-admin.1 |
diff --git a/ezjail-admin b/ezjail-admin index 907a61f..d9fce50 100755 --- a/ezjail-admin +++ b/ezjail-admin | |||
@@ -3,6 +3,7 @@ | |||
3 | # ugly: this variable is set during port install time | 3 | # ugly: this variable is set during port install time |
4 | ezjail_prefix=EZJAIL_PREFIX | 4 | ezjail_prefix=EZJAIL_PREFIX |
5 | ezjail_etc=${ezjail_prefix}/etc | 5 | ezjail_etc=${ezjail_prefix}/etc |
6 | ezjail_share=${ezjail_prefix}/share | ||
6 | ezjail_jailcfgs=${ezjail_etc}/ezjail | 7 | ezjail_jailcfgs=${ezjail_etc}/ezjail |
7 | 8 | ||
8 | if [ -f ${ezjail_etc}/ezjail.conf ]; then | 9 | if [ -f ${ezjail_etc}/ezjail.conf ]; then |
@@ -95,9 +96,12 @@ create) | |||
95 | # if flavour contains a '/', it aint a short name | 96 | # if flavour contains a '/', it aint a short name |
96 | if [ ${newjail_flavour} = ${newjail_flavour%/*} -a \ | 97 | if [ ${newjail_flavour} = ${newjail_flavour%/*} -a \ |
97 | -f ${ezjail_etc}/ezjail.flavour.${newjail_flavour} ]; then | 98 | -f ${ezjail_etc}/ezjail.flavour.${newjail_flavour} ]; then |
98 | [ $newjail_flav ] && exerr "Note: flavour ${newjail_flavour} conflicts with file ./${newjail_flavour}" | 99 | [ "$newjail_flav" ] && exerr "Error: flavour ${newjail_flavour} conflicts with file ./${newjail_flavour}" |
99 | $newjail_flav=${ezjail_etc}/ezjail.flavour.${newjail_flavour} | 100 | $newjail_flav=${ezjail_etc}/ezjail.flavour.${newjail_flavour} |
100 | fi | 101 | fi |
102 | |||
103 | # Flavour not found | ||
104 | [ "$newjail_flav" ] || exerr "Error: Flavour file $newjail_flavour not found" | ||
101 | fi | 105 | fi |
102 | 106 | ||
103 | # now take a copy of our template jail | 107 | # now take a copy of our template jail |
@@ -126,6 +130,13 @@ create) | |||
126 | echo export jail_${newjail_nname}_procfs_enable=\"${ezjail_procfs_enable}\" >> ${ezjail_jailcfgs}/${newjail_nname} | 130 | echo export jail_${newjail_nname}_procfs_enable=\"${ezjail_procfs_enable}\" >> ${ezjail_jailcfgs}/${newjail_nname} |
127 | echo export jail_${newjail_nname}_fdescfs_enable=\"${ezjail_fdescfs_enable}\" >> ${ezjail_jailcfgs}/${newjail_nname} | 131 | echo export jail_${newjail_nname}_fdescfs_enable=\"${ezjail_fdescfs_enable}\" >> ${ezjail_jailcfgs}/${newjail_nname} |
128 | 132 | ||
133 | # Final steps for flavour installation | ||
134 | if [ "${newjail_flav}" ]; then | ||
135 | install -o root -g wheel -m 0755 ${newjail_flav} ${newjail_root}/ezjail.flavour | ||
136 | install -o root -g wheel -m 0755 ${ezjail_share}/ezjail-config.sh ${newjail_root}/etc/rc.d/ezjail-config.sh | ||
137 | echo "Shell scripts installed, flavourizing on jails first startup" | ||
138 | fi | ||
139 | |||
129 | ;; | 140 | ;; |
130 | delete) | 141 | delete) |
131 | ######################## ezjail-admin DELETE ######################## | 142 | ######################## ezjail-admin DELETE ######################## |
@@ -190,6 +201,7 @@ list) | |||
190 | eval jail_rootdir=\"\$jail_${jail}_rootdir\" | 201 | eval jail_rootdir=\"\$jail_${jail}_rootdir\" |
191 | printf "%-15s %-28s %s\\n" $jail_ip $jail_hostname $jail_rootdir | 202 | printf "%-15s %-28s %s\\n" $jail_ip $jail_hostname $jail_rootdir |
192 | done | 203 | done |
204 | |||
193 | ;; | 205 | ;; |
194 | setup|update) | 206 | setup|update) |
195 | ######################## ezjail-admin UPDATE ######################## | 207 | ######################## ezjail-admin UPDATE ######################## |
diff --git a/ezjail-config.sh b/ezjail-config.sh index a84407c..fa02423 100644 --- a/ezjail-config.sh +++ b/ezjail-config.sh | |||
@@ -2,21 +2,21 @@ | |||
2 | # | 2 | # |
3 | # BEFORE: rcconf | 3 | # BEFORE: rcconf |
4 | 4 | ||
5 | if [ -f /etc/ezjail.template ]; then | 5 | if [ -f /etc/ezjail.flavour ]; then |
6 | . /etc/ezjail.template | 6 | . /etc/ezjail.flavour |
7 | 7 | ||
8 | # we do need to install only once | 8 | # we do need to install only once |
9 | # rm -f /etc/ezjail.template | 9 | # rm -f /etc/ezjail.flavour |
10 | fi | 10 | fi |
11 | 11 | ||
12 | # set defaults | 12 | # set defaults |
13 | ezjail_template_root=${ezjail_template_root:-"/basejail/config/default"} | 13 | ezjail_flavour_root=${ezjail_flavour_root:-"/basejail/config/default"} |
14 | ezjail_template_files=${ezjail_template_files:-""} | 14 | ezjail_flavour_files=${ezjail_flavour_files:-""} |
15 | ezjail_template_users=${ezjail_template_users:-""} | 15 | ezjail_flavour_users=${ezjail_flavour_users:-""} |
16 | ezjail_template_packages=${ezjail_template_packages:-""} | 16 | ezjail_flavour_packages=${ezjail_flavour_packages:-""} |
17 | 17 | ||
18 | # try to create users | 18 | # try to create users |
19 | for user in $ezjail_template_users; do | 19 | for user in $ezjail_flavour_users; do |
20 | TIFS=$IFS; IFS=:; set -- $user; IFS=$TIFS | 20 | TIFS=$IFS; IFS=:; set -- $user; IFS=$TIFS |
21 | 21 | ||
22 | if [ $# -eq 8 ]; then | 22 | if [ $# -eq 8 ]; then |
@@ -45,8 +45,8 @@ for user in $ezjail_template_users; do | |||
45 | done | 45 | done |
46 | 46 | ||
47 | # try to install files | 47 | # try to install files |
48 | cd $ezjail_template_root | 48 | cd $ezjail_flavour_root |
49 | for file in $ezjail_template_files; do | 49 | for file in $ezjail_flavour_files; do |
50 | TIFS=$IFS; IFS=:; set -- $file; IFS=$TIFS | 50 | TIFS=$IFS; IFS=:; set -- $file; IFS=$TIFS |
51 | 51 | ||
52 | if [ $# -eq 3 -a "$3" ]; then | 52 | if [ $# -eq 3 -a "$3" ]; then |
@@ -60,7 +60,7 @@ done | |||
60 | 60 | ||
61 | # finally install packages | 61 | # finally install packages |
62 | [ -d /basejail/config/pkg ] && cd /basejail/config/pkg | 62 | [ -d /basejail/config/pkg ] && cd /basejail/config/pkg |
63 | [ $ezjail_template_packages ] && pkg_add $ezjail_template_packages | 63 | [ $ezjail_flavour_packages ] && pkg_add $ezjail_flavour_packages |
64 | 64 | ||
65 | # Get rid off ourself | 65 | # Get rid off ourself |
66 | rm -f /etc/rc.d/ezjail-config.sh | 66 | rm -f /etc/rc.d/ezjail-config.sh |