function search_default_template {
- if [ -f "$BASE_CONF/templates/default.template" ]; then
+ if [ -e "$BASE_CONF/templates/default.template" ]; then
TEMPLATE_BASE="$BASE_CONF/templates/default"
echo $BASENAME: using default template
- elif [ -f "$BASE_CONF/default.template" ]; then
+ elif [ -e "$BASE_CONF/default.template" ]; then
TEMPLATE_BASE="$BASE_CONF/default"
echo $BASENAME using default template
- elif [ -f "$BASE_CONF/defaults/templates/default/default.template" ]; then
+ elif [ -e "$BASE_CONF/defaults/templates/default/default.template" ]; then
TEMPLATE_BASE="$BASE_CONF/defaults/templates/default"
else
echo $BASENAME: error: default template not found
# usage: template_svn_commit <template-folder>
if use_svn && [ -d "$1/.svn" ]; then
- echo Commiting changes to the repository...
cd $1
+ echo First checking out from the repository...
+ svn update
+ echo Commiting changes to the repository...
svn commit -m "changes for `date`"
if [ "$?" != "0" ]; then
echo $BASENAME: commit error
elif echo $1 | grep -q -e "^--"; then
usage
elif [ ! -z "$1" ]; then
- echo "This is jail-commit; Run \"$BASENAME --help\" for help"
do_commit $1 $2
template_svn_commit `dirname $TEMPLATE_BASE`
else
- echo "This is jail-commit; Run \"$BASENAME --help\" for help"
if [ -f $JAIL_LIST ]; then
for jailpath in `cat $JAIL_LIST`; do
do_commit $jailpath
echo ""
exit
+ # TODO: opcao para apagar script de pos-instalacao
+
}
function check_svn_repo {
if use_svn && [ -d "$TEMPLATE_BASE/.svn" ]; then
- cd $TEMPLATE_BASE
+ cd `dirname $TEMPLATE_BASE`
if ! svn_check $TEMPLATE_BASE.d; then
svn mkdir $TEMPLATE_BASE.d
function check_template_exist {
# check if a template exists
+ # and create missing components
local components
- components="$TEMPLATE_BASE.template $TEMPLATE_BASE.perms $TEMPLATE_BASE.d $TEMPLATE_BASE.s"
+ components="template perms d s"
if [ ! -d "`dirname $TEMPLATE_BASE`" ]; then
echo $BASENAME: template not found
fi
for component in $components; do
- if [ ! -e "$component" ]; then
- echo $BASENAME: template component not found: $component
- echo $BASENAME: please run $BASENAME -c before update a template
- exit 1
+
+ if [ ! -e "$TEMPLATE_BASE.$component" ]; then
+ echo "$BASENAME: template component not found: $component; creating..."
+
+ cd `dirname $TEMPLATE_BASE`
+
+ if [ "$component" == "perms" ] || [ "$component" == "template" ]; then
+ touch $TEMPLATE_BASE.$component
+ else
+ mkdir $TEMPLATE_BASE.$component
+ fi
+
+ if use_svn && [ -d "$TEMPLATE_BASE/.svn" ]; then
+ svn add $TEMPLATE_BASE.$component
+ info_commit="yes"
+ fi
+
fi
done
+ if [ "$info_commit" == "yes" ]; then
+ echo "$BASENAME: please run 'jail-commit --all' to add new files in the svn repository"
+ fi
+
}
function template_delete {
if use_svn && [ -d "$basedir/.svn" ]; then
cd $BASE_CONF/templates
+ svn update
svn del --force $template
if [ "$?" != "0" ]; then
echo $BASENAME: error deleting template $template
fi
else
- if [ -d "$TEMPLATE_BASE.s" ]; then
+ if [ -e "$TEMPLATE_BASE.s/$1" ]; then
+
+ echo $BASENAME: file $TEMPLATE_BASE.s/$1 not a regular file
+
+ elif [ -d "$TEMPLATE_BASE.s" ]; then
touch $TEMPLATE_BASE.s/$1
chmod +x $TEMPLATE_BASE.s/$1
[ -d "`dirname $TEMPLATE_BASE`/.svn" ]; then
echo "$BASENAME: please run 'jail-commit --all' to send changes to the repository"
fi
+ elif [ -e "$TEMPLATE_BASE.template" ]; then
+ echo $BASENAME: file $TEMPLATE_BASE.template not a regular file
else
echo $BASENAME: file not found: $TEMPLATE_BASE.template
fi