]> gitweb.fluxo.info Git - simplepkg.git/commitdiff
templatepkg: added -t and -p
authorrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>
Thu, 5 Apr 2007 23:14:35 +0000 (23:14 +0000)
committerrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>
Thu, 5 Apr 2007 23:14:35 +0000 (23:14 +0000)
jail-update: added --help
jail-commit: added --help and --all

git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@268 04377dda-e619-0410-9926-eae83683ac58

trunk/src/jail-commit
trunk/src/jail-update
trunk/src/templatepkg

index d398e0fbf8660abffd911d4b4abf66a1bbde4194..61b93bf986239977c9bfbdb916cc90e027286efb 100755 (executable)
@@ -30,7 +30,9 @@ fi
 function usage {
 
   echo $BASENAME: commit a jail configuration into a template
-  echo usage: $BASENAME [<jail-path> [template]]
+  echo "usage: $BASENAME [<jail-path> [template]]"
+  echo "       $BASENAME --all to commit all templates"
+  echo "       $BASENAME --help for help"
 
 }
 
@@ -129,7 +131,11 @@ function do_commit {
 
 }
 
-if [ ! -z "$1" ]; then
+if [ "$1" == "--help" ]; then
+  usage
+elif [ "$1" == "--all" ]; then
+  template_svn_commit $BASE_CONF/templates
+elif [ ! -z "$1" ]; then
   do_commit $1 $2
 else
   if [ -f $JAIL_LIST ]; then
index 1a6ea9b1ffd8507c51fec2773980475e2e5d4176..b8456749604df726c001f5ce427f6b3d219f2aa1 100755 (executable)
@@ -34,7 +34,7 @@ function usage {
 
 }
 
-if [ -z "$1" ]; then
+if [ -z "$1" ] || [ "$1" == "--help" ]; then
   usage
   exit 1
 fi
index 912f5918faf610c85b9d981e2767e80580dbc9ca..858911d163ab53a490711fe6d1c09b83cd3333a4 100755 (executable)
@@ -72,6 +72,14 @@ function usage {
   echo ""   
   echo "      $BASENAME -l [template-name]"
   echo ""   
+  echo "  -p | --post-install: add or edit post-installation scripts:"
+  echo ""   
+  echo "      $BASENAME -p <template-name> <script-name>"
+  echo ""   
+  echo "  -t | --template-edit: edit template package list:"
+  echo ""   
+  echo "      $BASENAME -t <template-name>"
+  echo ""   
   echo "  -h | --help: display this summary."   
   echo ""   
   echo "  for -c, -u and -a jail-root defaults to / if ommited"
@@ -491,9 +499,14 @@ function template_remove {
   basedir="`dirname $TEMPLATE_BASE`"
   template="`basename $basedir`"
 
+  if [ ! -d "$basedir" ]; then
+    echo $BASENAME: template $template does not exist
+    exit 1
+  fi
+
   if use_svn && [ -d "$basedir/.svn" ]; then
     cd $BASE_CONF/templates
-    svn del $template
+    svn del --force $template
     if [ "$?" != "0" ]; then
       echo $BASENAME: error deleting template $template
     else
@@ -529,6 +542,72 @@ function template_list {
 
 }
 
+function template_post_install_edit {
+
+  # add or edit a post-installation script
+  # usage: template_post_install_edit <script-name>
+
+  if [ -z "$1" ]; then
+    echo $BASENAME: no template specified
+    exit 1
+  elif echo $1 | grep -q "/"; then
+    echo $BASENAME: error: invalid script name $1
+  fi
+
+  if [ -f "$TEMPLATE_BASE.s/$1" ]; then
+    sha1sum="`sha1sum $TEMPLATE_BASE.s/$1`"
+    if [ ! -z "$EDITOR" ]; then
+      $EDITOR $TEMPLATE_BASE.s/$1
+    else
+      vi $TEMPLATE_BASE.s/$1
+    fi
+    if [ "$sha1sum" != "`sha1sum $TEMPLATE_BASE.s/$1`" ]; then
+      echo $BASENAME: please run jail-commit to send changes to the repository
+    fi    
+  else
+
+    if [ -d "$TEMPLATE_BASE.s" ]; then
+
+      touch $TEMPLATE_BASE.s/$1
+      chmod +x $TEMPLATE_BASE.s/$1
+
+      if [ -d "$TEMPLATE_BASE.s/.svn" ]; then
+        cd $TEMPLATE_BASE.s
+        svn add $1
+        echo "$BASENAME: please run jail-commit to send the script to the repository"
+      fi
+
+      echo "$BASENAME: script created; run templatepkg -p `basename $TEMPLATE_BASE` $1 again to edit it"
+
+    else
+      echo $BASENAME: folder not found: $TEMPLATE_BASE.s
+    fi
+
+  fi
+
+}
+
+function template_edit {
+
+  # edit a template package list
+  # usage: template_edit
+
+  if [ -f "$TEMPLATE_BASE.template" ]; then
+    sha1sum="`sha1sum $TEMPLATE_BASE.template`"
+    if [ ! -z "$EDITOR" ]; then
+      $EDITOR $TEMPLATE_BASE.template
+    else
+      vi $TEMPLATE_BASE.template
+    fi
+    if [ "$sha1sum" != "`sha1sum $TEMPLATE_BASE.template`" ]; then
+      echo $BASENAME: please run jail-commit to send changes to the repository
+    fi
+  else
+    echo $BASENAME: file not found: $TEMPLATE_BASE.template
+  fi
+
+}
+
 function require {
 
   # requires a string
@@ -630,6 +709,16 @@ elif [ "$1" == "-l" ] || [ "$1" == "--list" ]; then
 
   template_list $2
 
+elif [ "$1" == "-p" ] || [ "$1" == "--post-install" ]; then
+
+  require $3
+  template_post_install_edit $3
+
+elif [ "$1" == "-t" ] || [ "$1" == "--template-edit" ]; then
+
+  require $2
+  template_edit
+
 elif [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
 
   usage