From 9becc61bb321fc16d3ba5778e2ef5078efd07d22 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Thu, 17 Nov 2005 00:30:15 +0000 Subject: Default PREFIX provided, flavour stuff added --- Makefile | 10 +++++++++- ezjail-admin | 14 +++++++++++++- ezjail-config.sh | 22 +++++++++++----------- 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 6d0e141..9618d7d 100755 --- a/Makefile +++ b/Makefile @@ -1,8 +1,16 @@ +# I know, this is ain't nice but an empty prefix leads to much confusion +# In most cases ezjail is being installed from ports anyway. If you REALLY REALLY +# want / as your install location, DO set PREFIX before invoking this Makefile + +PREFIX?=/usr/local + all: install: - mkdir -p ${PREFIX}/etc/ezjail/ ${PREFIX}/man/man1/ ${PREFIX}/man/man5/ ${PREFIX}/etc/rc.d/ ${PREFIX}/bin/ + mkdir -p ${PREFIX}/etc/ezjail/ ${PREFIX}/man/man1/ ${PREFIX}/man/man5/ ${PREFIX}/etc/rc.d/ ${PREFIX}/bin/ ${PREFIX}/share/ezjail ${PREFIX}/share/examples/ezjail cp -p ezjail.conf.sample ${PREFIX}/etc/ + cp -p ezjail-config.sh ${PREFIX}/share/ezjail/ + cp -p ezjail.flavour.default ${PREFIX}/share/examples/ezjail/ sed s:EZJAIL_PREFIX:${PREFIX}: ezjail.sh > ${PREFIX}/etc/rc.d/ezjail.sh sed s:EZJAIL_PREFIX:${PREFIX}: ezjail-admin > ${PREFIX}/bin/ezjail-admin 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 @@ # ugly: this variable is set during port install time ezjail_prefix=EZJAIL_PREFIX ezjail_etc=${ezjail_prefix}/etc +ezjail_share=${ezjail_prefix}/share ezjail_jailcfgs=${ezjail_etc}/ezjail if [ -f ${ezjail_etc}/ezjail.conf ]; then @@ -95,9 +96,12 @@ create) # if flavour contains a '/', it aint a short name if [ ${newjail_flavour} = ${newjail_flavour%/*} -a \ -f ${ezjail_etc}/ezjail.flavour.${newjail_flavour} ]; then - [ $newjail_flav ] && exerr "Note: flavour ${newjail_flavour} conflicts with file ./${newjail_flavour}" + [ "$newjail_flav" ] && exerr "Error: flavour ${newjail_flavour} conflicts with file ./${newjail_flavour}" $newjail_flav=${ezjail_etc}/ezjail.flavour.${newjail_flavour} fi + + # Flavour not found + [ "$newjail_flav" ] || exerr "Error: Flavour file $newjail_flavour not found" fi # now take a copy of our template jail @@ -126,6 +130,13 @@ create) echo export jail_${newjail_nname}_procfs_enable=\"${ezjail_procfs_enable}\" >> ${ezjail_jailcfgs}/${newjail_nname} echo export jail_${newjail_nname}_fdescfs_enable=\"${ezjail_fdescfs_enable}\" >> ${ezjail_jailcfgs}/${newjail_nname} + # Final steps for flavour installation + if [ "${newjail_flav}" ]; then + install -o root -g wheel -m 0755 ${newjail_flav} ${newjail_root}/ezjail.flavour + install -o root -g wheel -m 0755 ${ezjail_share}/ezjail-config.sh ${newjail_root}/etc/rc.d/ezjail-config.sh + echo "Shell scripts installed, flavourizing on jails first startup" + fi + ;; delete) ######################## ezjail-admin DELETE ######################## @@ -190,6 +201,7 @@ list) eval jail_rootdir=\"\$jail_${jail}_rootdir\" printf "%-15s %-28s %s\\n" $jail_ip $jail_hostname $jail_rootdir done + ;; setup|update) ######################## 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 @@ # # BEFORE: rcconf -if [ -f /etc/ezjail.template ]; then - . /etc/ezjail.template +if [ -f /etc/ezjail.flavour ]; then + . /etc/ezjail.flavour # we do need to install only once - # rm -f /etc/ezjail.template + # rm -f /etc/ezjail.flavour fi # set defaults -ezjail_template_root=${ezjail_template_root:-"/basejail/config/default"} -ezjail_template_files=${ezjail_template_files:-""} -ezjail_template_users=${ezjail_template_users:-""} -ezjail_template_packages=${ezjail_template_packages:-""} +ezjail_flavour_root=${ezjail_flavour_root:-"/basejail/config/default"} +ezjail_flavour_files=${ezjail_flavour_files:-""} +ezjail_flavour_users=${ezjail_flavour_users:-""} +ezjail_flavour_packages=${ezjail_flavour_packages:-""} # try to create users -for user in $ezjail_template_users; do +for user in $ezjail_flavour_users; do TIFS=$IFS; IFS=:; set -- $user; IFS=$TIFS if [ $# -eq 8 ]; then @@ -45,8 +45,8 @@ for user in $ezjail_template_users; do done # try to install files -cd $ezjail_template_root -for file in $ezjail_template_files; do +cd $ezjail_flavour_root +for file in $ezjail_flavour_files; do TIFS=$IFS; IFS=:; set -- $file; IFS=$TIFS if [ $# -eq 3 -a "$3" ]; then @@ -60,7 +60,7 @@ done # finally install packages [ -d /basejail/config/pkg ] && cd /basejail/config/pkg -[ $ezjail_template_packages ] && pkg_add $ezjail_template_packages +[ $ezjail_flavour_packages ] && pkg_add $ezjail_flavour_packages # Get rid off ourself rm -f /etc/rc.d/ezjail-config.sh -- cgit v1.2.3