aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/jail-update2
-rwxr-xr-xsrc/mkjail47
-rwxr-xr-xsrc/templatepkg15
3 files changed, 35 insertions, 29 deletions
diff --git a/src/jail-update b/src/jail-update
index f6635b5..07d1d1b 100755
--- a/src/jail-update
+++ b/src/jail-update
@@ -25,6 +25,8 @@ else
exit 1
fi
+# TODO: get the correct template folder
+
if [ -f $JAIL_LIST ]; then
for jailpath in `cat $JAIL_LIST`; do
jail="`basename $jailpath`"
diff --git a/src/mkjail b/src/mkjail
index 49c6c8a..0f9834d 100755
--- a/src/mkjail
+++ b/src/mkjail
@@ -18,9 +18,10 @@
#
COMMON="/usr/libexec/simplepkg/common.sh"
+BASENAME="`basename $0`"
function usage {
- echo "usage: [ROOT=/otherroot] `basename $0` <jail-name> [template]"
+ echo "usage: [ARCH=arch] [VERSION=version] [ROOT=/otherroot] $BASENAME <jail-name> [template]"
exit 1
}
@@ -38,47 +39,47 @@ else
eval_config `basename $0` -u
fi
-if [[ ! -z "$2" && -f "$BASE_CONF/$2.template" ]]; then
- TEMPLATE="$BASE_CONF/$2.template"
-elif [[ ! -z "$2" && ! -f "$BASE_CONF/$2.template" ]]; then
- echo template $2 not found, using default template
- TEMPLATE="$BASE_CONF/default.template"
-elif [[ -z "$2" && -f "$BASE_CONF/default.template" ]]; then
- TEMPLATE="$BASE_CONF/default.template"
- echo using default template
+if [ ! -z "$2" ]; then
+ search_template $2
+ result="$?"
else
- echo `basename $0` error: no templates found
- echo please create a template using templatepkg
+ result="$?"
+ search_default_template
+fi
+
+if [ "$result" != "0" ]; then
exit 1
fi
+TEMPLATE="$TEMPLATE_BASE.template"
+
if [ ! -d "$JAIL_ROOT/$server" ]; then
mkdir -p $JAIL_ROOT/$server
else
if [ ! -z "`ls $JAIL_ROOT/$server | grep -v 'lost+found'`" ]; then
- echo error: folder $JAIL_ROOT/$server already exists and seens to be not empty
- echo probably the jail $1 already exists
+ echo $BASENAME: error: folder $JAIL_ROOT/$server already exists and seens to be not empty
+ echo $BASENAME: probably the jail $1 already exists
exit 1
fi
fi
-echo "instaling packages into $JAIL_ROOT/$server using $TEMPLATE..."
+echo "$BASENAME: instaling packages into $JAIL_ROOT/$server using $TEMPLATE..."
install_packages
-TEMPLATE="`echo $TEMPLATE | sed -e 's/\.template$//'`"
-echo "copying template files..."
-if [ -d "$TEMPLATE.d" ]; then
- rsync -av $TEMPLATE.d/ $JAIL_ROOT/$server/
+echo "$BASENAME: copying template files..."
+if [ -d "$TEMPLATE_BASE.d" ]; then
+ rsync -av $TEMPLATE_BASE.d/ $JAIL_ROOT/$server/
fi
-echo "executing template scripts..."
+echo "$BASENAME: executing template scripts..."
if [ -d "$TEMPLATE.s" ]; then
for script in `ls $TEMPLATE.s/`; do
- if [ -x "$TEMPLATE.s/$script" ]; then
- exec $TEMPLATE.s/$script $JAIL_ROOT $server
+ if [ -x "$TEMPLATE_BASE.s/$script" ]; then
+ exec $TEMPLATE_BASE.s/$script $JAIL_ROOT $server
fi
done
fi
-echo "$JAIL_ROOT/$server" >> $JAIL_LIST
-echo "done creating $server jail"
+echo $JAIL_ROOT/$server >> $JAIL_LIST
+echo $BASENAME: done creating $server jail
+
diff --git a/src/templatepkg b/src/templatepkg
index 9c1f8bc..dc0323c 100755
--- a/src/templatepkg
+++ b/src/templatepkg
@@ -19,6 +19,7 @@
#
COMMON="/usr/libexec/simplepkg/common.sh"
+BASENAME="`basename $0`"
if [ -f "$COMMON" ]; then
source $COMMON
@@ -31,24 +32,26 @@ fi
APPEND="0"
if [[ ! -z "$3" && "$1" == "-a" ]]; then
ROOT="$3"
- TEMPLATE="$BASE_CONF/$2.template"
+ search_template $2 --new
APPEND="1"
elif [[ ! -z "$2" && "$1" == "-a" ]]; then
ROOT="/"
- TEMPLATE="$BASE_CONF/$2.template"
+ search_template $2 --new
APPEND="1"
elif [[ ! -z "$2" ]]; then
ROOT="$2"
- TEMPLATE="$BASE_CONF/$1.template"
+ search_template $1 --new
elif [[ ! -z "$1" ]]; then
- TEMPLATE="$BASE_CONF/$1.template"
+ search_template $1 --new
ROOT="/"
else
- echo "usage: `basename $0` [-a] <template> [root-dir]"
- echo -e "\t-a: append packages into <$BASE_CONF/template.template>"
+ echo "usage: $BASENAME [-a] <template> [root-dir]"
+ echo -e "\t-a: append packages into a template"
exit 1
fi
+TEMPLATE="$BASE_TEMPLATE.template"
+
if [ ! -d "$ROOT/var/log/packages" ]; then
echo $ROOT/var/log/packages: directory not found
exit 1