Parameter change

Modified jailbase parameter such that it's only required when $state=present
This commit is contained in:
Jake Guffey 2012-06-14 14:33:21 -04:00
parent c1ca8f4932
commit c8fa79d053
4 changed files with 32 additions and 6 deletions

View file

@ -28,12 +28,26 @@ else
jaildir="/usr/jail"
fi
jailbase="$(cat "$__object/parameter/jailbase")"
if [ -f "$__object/parameter/jailbase" ]; then
jailbase="$(cat "$__object/parameter/jailbase")"
else
jailbase=""
fi
state="$(cat "$__object/parameter/state")"
if [ "$state" = "present" ] && [ -z "$jailbase" ]; then
exec >&2
echo "jailbase is a REQUIRED parameter when state=present!"
exit 1
fi
remotebase="${jaildir}/jailbase.tgz"
basepresent="$(cat "$__object/explorer/basepresent")"
if [ "$basepresent" = "NONE" ]; then
echo "$__remote_copy" "${jailbase}" "$__target_host:${remotebase}"
fi
if [ "$state" = "present" ]; then
if [ "$basepresent" = "NONE" ]; then
echo "$__remote_copy" "${jailbase}" "$__target_host:${remotebase}"
fi # basepresent=NONE
fi # state=present

View file

@ -177,6 +177,7 @@ cat <<EOF
mkdir -p ${jaildir}/${name}
if [ ! -d "${jaildir}/base" ]; then
mkdir "${jaildir}/base"
chmod 755 "${jaildir}/base"
tar -xzf "${jaildir}/jailbase.tgz" -C "${jaildir}/base"
if [ ! -d "${jaildir}/base/usr/local" ]; then
mkdir -p "${jaildir}/base/usr/local"
@ -184,6 +185,11 @@ cat <<EOF
if [ ! -d "${jaildir}/base/usr/home" ]; then
mkdir -p "${jaildir}/base/usr/home"
fi
if [ ! -d "${jaildir}/home" ]; then
SAVE=\$PWD; cd ${jaildir}/base
ln -s "home" "usr/home"
cd \$SAVE; unset SAVE
fi
fi
if [ ! -d "${jaildir}/rw" ]; then
mkdir "${jaildir}/rw"
@ -198,6 +204,12 @@ cat <<EOF
if [ -n "\$(ls ${jaildir}/base/var)" ]; then
cp -r ${jaildir}/base/var/* "${jaildir}/rw/${name}/var/"
fi
chmod 755 "${jaildir}/rw/${name}/var"
chmod 755 "${jaildir}/base/var"
if [ -n "\$(ls ${jaildir}/base/var/db)" ]; then
chmod 755 "${jaildir}/rw/${name}/var/db"
chmod 755 "${jaildir}/base/var/db"
fi
mkdir "${jaildir}/rw/${name}/home"
if [ -n "\$(ls ${jaildir}/base/usr/home)" ]; then
cp -r ${jaildir}/base/usr/home/* "${jaildir}/rw/${name}/home/"
@ -293,7 +305,7 @@ if [ "$onboot" = "true" ]; then
# if necessary
cat <<EOF
jail_list="\$(grep '^jail_list=' /etc/rc.conf | cut -d= -f2)"
eval "\$(grep '^jail_list=' /etc/rc.conf)"
if [ -z "\$jail_list" ]; then # no jail_list line in rc.conf at all
echo "jail_list=\"${name}\"" >>/etc/rc.conf
else

View file

@ -7,3 +7,4 @@ devfs-enable
devfs-ruleset
onboot
jaildir
jailbase

View file

@ -1,2 +1 @@
state
jailbase