Skip to content
Browse files

Integrated patch from github bded6394e2fc780b50ba5254af6a70c23aa27800

Documentation For Zotonic CLI

Add docs describing each of the commands.
Add minimal USAGE docs.

Thanks Alain O'Dea
  • Loading branch information...
1 parent ea8eefc commit 0ab463213351ccfc846d5023153086ecdb4462c4 @arjan arjan committed Feb 13, 2011
View
10 bin/zotonic
@@ -18,7 +18,13 @@
# usage zotonic [command] [arguments...]
#
-ZOTONIC_BIN=`dirname $0 | xargs readlink -e`
-$ZOTONIC_BIN/zotonic-$1 ${@:2}
+ZOTONIC_BIN=`dirname $0 || readlink -e $0`
+if [ ! $1 ]
+then
+ echo USAGE: $0 [`ls $ZOTONIC_BIN | grep zotonic- | grep -v _ | sed 's/zotonic-//g'`] 1>&2
+ echo USAGE: See ZotonicCommands.txt 1>&2
+else
+ $ZOTONIC_BIN/zotonic-$1 ${@:2}
+fi
exit 0
View
63 bin/zotonic-addsite
@@ -6,7 +6,7 @@
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
-# http://www.apache.org/licenses/LICENSE-2.0
+# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@@ -25,43 +25,44 @@ SITE=$1
if [ ! $SITE ]
then
- echo USAGE: $0 [site_name] 1>&2
+ echo USAGE: $0 [site_name] 1>&2
+ echo USAGE: See ZotonicCommands.txt 1>&2
else
- if [ -e $SITES/$SITE ]
- then
- echo $0: cannot add site "\`$SITE'": $SITES/$SITE already exists 1>&2
- else
- # Copy the default site as a template
- cp -R $SITES/default $SITES/$SITE
+ if [ -e $SITES/$SITE ]
+ then
+ echo $0: cannot add site "\`$SITE'": $SITES/$SITE already exists 1>&2
+ else
+ # Copy the default site as a template
+ cp -R $SITES/default $SITES/$SITE
- # Remove duplicate module
- rm $SITES/$SITE/default.erl
+ # Remove duplicate module
+ rm $SITES/$SITE/default.erl
- # Generate Site Module refactor script
- REFACTOR_MODULE=`tempfile`
- sed s/yoursite/$SITE/g \
- < $ZOTONIC_BIN/zotonic-addsite_module.sed.in \
- > $REFACTOR_MODULE
+ # Generate Site Module refactor script
+ REFACTOR_MODULE=`tempfile`
+ sed s/yoursite/$SITE/g \
+ < $ZOTONIC_BIN/zotonic-addsite_module.sed.in \
+ > $REFACTOR_MODULE
- # Refactor Site Module
- sed -f "$REFACTOR_MODULE" \
- < $SITES/default/default.erl \
- > $SITES/$SITE/$SITE.erl
+ # Refactor Site Module
+ sed -f "$REFACTOR_MODULE" \
+ < $SITES/default/default.erl \
+ > $SITES/$SITE/$SITE.erl
- # Generate Site Config refactor script
- REFACTOR_CONFIG=`tempfile`
- sed s/yoursite/$SITE/g \
- < $ZOTONIC_BIN/zotonic-addsite_config.sed.in \
- > $REFACTOR_CONFIG
+ # Generate Site Config refactor script
+ REFACTOR_CONFIG=`tempfile`
+ sed s/yoursite/$SITE/g \
+ < $ZOTONIC_BIN/zotonic-addsite_config.sed.in \
+ > $REFACTOR_CONFIG
- # Refactor Site Config
- sed -f $REFACTOR_CONFIG \
- < $SITES/default/config.in \
- > $SITES/$SITE/config
+ # Refactor Site Config
+ sed -f $REFACTOR_CONFIG \
+ < $SITES/default/config.in \
+ > $SITES/$SITE/config
- # Make the new site
- make --silent --directory=$ZOTONIC
- fi
+ # Make the new site
+ make --silent --directory=$ZOTONIC
+ fi
fi
. $ZOTONIC_BIN/zotonic_teardown
View
1 bin/zotonic-copysite
@@ -27,6 +27,7 @@ SERVER=$2
if [ ! $SITE ]
then
echo USAGE: $0 [site_name] [source_server] 1>&2
+ echo USAGE: See ZotonicCommands.txt 1>&2
else
if [ ! $SERVER ]
then
View
3 bin/zotonic-createdb
@@ -24,10 +24,11 @@ SITE=$1
if [ ! "$SITE" ]
then
echo USAGE: $0 [site_name] 1>&2
+ echo USAGE: See ZotonicCommands.txt 1>&2
else
# Create the site database
sed s/yoursite/$SITE/g \
- < zotonic-createdb.sql.in \
+ < zotonic-createdb_sql.in \
| psql
fi
View
0 bin/zotonic-createdb.sql.in → bin/zotonic-createdb_sql.in
File renamed without changes.
View
1 bin/zotonic-sitedir
@@ -26,6 +26,7 @@ SITE=$1
if [ ! "$SITE" ]
then
echo USAGE: $0 [site_name] 1>&2
+ echo USAGE: See ZotonicCommands.txt 1>&2
else
echo "$SITES/$SITE"
fi
View
1 bin/zotonic-snapshot
@@ -26,6 +26,7 @@ SITE=$1
if [ ! $SITE ]
then
echo USAGE: $0 [site_name] 1>&2
+ echo USAGE: See ZotonicCommands.txt 1>&2
else
mkdir -p $SITES/$SITE/files/snapshot
pg_dump zotonic_$SITE \
View
77 doc/ZotonicCommands.txt
@@ -0,0 +1,77 @@
+Zotonic Commands
+================
+The zotonic command can run a number of utility commands availble in
+zotonic/bin.
+
+OS X Compatibility Problem
+--------------------------
+If you symlink to zotonic/bin/zotonic, then you will need GNU coreutils on
+OS X or `readlink -e` will fail. I could not find a clean work-around for
+this with built-in OS X CLI tools. This is needed to traverse deeply
+symlinked commands.
+
+zotonic addsite [site_name]
+--------------------------
+Create a new site with [site_name] as its name. This new site will be based
+on the current content of the default site. It uses the default site as a
+template or skeleton.
+
+zotonic copysite [site_name] [source_server]
+--------------------------------------------
+Copy [site_name] and its database content from the [source_server] over SSH
+and load its content into the filesystem and database of the local machine.
+
+You will need to have created the database zotonic_[site_name] for this to
+work.
+
+Warning: This command will reset the content of the database to the content
+retrieved from the [source_server]. It does, however, generate and output
+a restore file in case this was run by accident and explains how to recover.
+
+zotonic createdb [site_name]
+----------------------------
+Create a database called zotonic_[site_name] with the basic setup in place to
+host a Zotonic datastore.
+
+This script will likely need to be run as postgres unless zotonic has been
+granted CREATEDB in postgres as follows:
+
+ ALTER ROLE zotonic WITH CREATEDB
+
+zotonic debug
+-------------
+Launch the Zotonic server interactively and get an EShell on the running
+instance. This is very similar to running ./start.sh.
+
+zotonic restart
+---------------
+Restart the background Zotonic server instance.
+
+zotonic shell
+-------------
+Connect to the background Zotonic server instance and provide and EShell.
+
+zotonic sitedir [site_name]
+---------------------------
+Get the absolute path for a site based on [site_name]
+
+zotonic snapshot [site_name]
+----------------------------
+Take a version control snapshot of [site_name] including its database content.
+
+This works differently from mod_backup in that it consistently uses the same
+filename for the SQL backup to make revision-based full site rollbacks
+possible.
+
+zotonic start
+-------------
+Start the background Zotonic server instance.
+
+zotonic stop
+------------
+Stop the background Zotonic server instance.
+
+zotonic update
+--------------
+Update the server. Compiles and loads any new code, flushes caches and
+rescans all modules.

0 comments on commit 0ab4632

Please sign in to comment.
Something went wrong with that request. Please try again.