From 523224e63efeb74fc0bbd038a25a10772756ca46 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Sat, 31 Dec 2005 01:50:10 +0000 Subject: Flavours now head to their final layout: the whole bunch of stuff found below flavour dir is being installed into the new jails root, including the flavour config, packages and files. The startup scripts now only creates users, chowns the files it is told to and installs packages. --- examples/example/ezjail.flavour | 13 +++++++------ ezjail-admin | 7 +++++-- ezjail-config.sh | 26 +++++++++++++------------- 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/examples/example/ezjail.flavour b/examples/example/ezjail.flavour index eee2a67..25ae08d 100755 --- a/examples/example/ezjail.flavour +++ b/examples/example/ezjail.flavour @@ -17,15 +17,16 @@ # admin::wheel::Admin=User:$1$p75bbfK.$Kz3dwkoVlgZrfLZdAXQt91:/home/admin:/bin/sh \ # pgsql:1002:pgsql:1002:Post=Gres::-/usr/local/psql:/bin/nologin' -# ezjails init script tries to install all files listed here from the path -# /config to the corresponding location inside the jail. Directories are being -# copied recursively. +# ezjail-admin script installs all files found in FLAVOUR/root to the +# new jail's root +# +# Files or directories that should not belong to root:wheel will be +# chowned -R according to the following variable +# # Format is as follows: # # user:group:file(s) # # Example: # -# ezjail_flavour_files='root:wheel:/etc/*.conf \ -# root:wheel:/etc/localtime \ -# admin:wheel:/home/admin/' +# ezjail_flavour_files='admin:wheel:/home/admin/' diff --git a/ezjail-admin b/ezjail-admin index d7c8791..59d6ce9 100755 --- a/ezjail-admin +++ b/ezjail-admin @@ -85,7 +85,6 @@ create) # do some sanity checks on the selected flavour (if any) if [ "${newjail_flavour}" ]; then [ -d ${ezjail_flavours}/${newjail_flavour}/ ] || exerr "Error: Flavour config directory ${ezjail_flavours}/${newjail_flavour} not found" - [ -d ${ezjail_flavours}/${newjail_flavour}/ezjail.flavour ] || exerr "Error: Flavour config ${ezjail_flavours}/${newjail_flavour}/ezjail.flavour not found" fi # now take a copy of our template jail @@ -138,7 +137,11 @@ create) # Final steps for flavour installation if [ "${newjail_flavour}" ]; then - cp -r -p ${ezjail_jaildir}/${newjail_flavour} ${newjail_root}/config + # install files, packages and config to new jail + # user creating, chown and package installation on jails startup + cd ${ezjail_jaildir}/${newjail_flavour} + find * | cpio -p -v ${newjail_root} > /dev/null + install -o root -g wheel -m 0755 ${ezjail_share}/ezjail-config.sh ${newjail_root}/etc/rc.d/ezjail-config.sh echo "Note: Shell scripts installed, flavourizing on jails first startup" fi diff --git a/ezjail-config.sh b/ezjail-config.sh index 19aa801..e7e9d9c 100644 --- a/ezjail-config.sh +++ b/ezjail-config.sh @@ -1,18 +1,17 @@ #!/bin/sh -# -# BEFORE: rcconf set -o noglob -if [ -f /config/ezjail.flavour ]; then - . /config/ezjail.flavour +if [ -f /ezjail.flavour ]; then + . /ezjail.flavour - # we do need to install only once - rm -f /config/ezjail.flavour + # we do need to install only once delete here to avoid errors + # in this script to prevent jail startup forever + rm -f /ezjail.flavour fi # set defaults -ezjail_flavour_files=${ezjail_flavour_files:-""} ezjail_flavour_users=${ezjail_flavour_users:-""} +ezjail_flavour_files=${ezjail_flavour_files:-""} # try to create users for user in $ezjail_flavour_users; do @@ -42,24 +41,25 @@ for user in $ezjail_flavour_users; do fi done -# try to install files -cd /config +# chmod all files not belonging to root for file in $ezjail_flavour_files; do TIFS=$IFS; IFS=:; set -- $file; IFS=$TIFS set +o noglob if [ $# -eq 3 -a "$3" ]; then owner=$1; [ $2 ] && owner="$1:$2" for file in ./$3; do - find ${file} | cpio -p -d / chown -R $owner /$file done fi set -o noglob done -# finally install packages +# install packages set -o noglob -[ -d /config/pkg ] && cd /config/pkg && pkg_add * +[ -d /pkg ] && cd /pkg && pkg_add * + +# source post install script +[ -d /ezjail.postinstall ] && . /ezjail.postinstall # Get rid off ourself -rm -f /etc/rc.d/ezjail-config.sh +rm -rf /pkg /etc/rc.d/ezjail-config.sh /ezjail.postinstall -- cgit v1.2.3