Skip to content
This repository has been archived by the owner on Nov 19, 2022. It is now read-only.

Commit

Permalink
merge from HEAD r88439:88492
Browse files Browse the repository at this point in the history
svn path=/branches/robertj/xsp/; revision=88513
  • Loading branch information
robert-j committed Oct 30, 2007
2 parents 03c21c2 + 879ff19 commit 32bbed1
Show file tree
Hide file tree
Showing 6 changed files with 297 additions and 2 deletions.
20 changes: 20 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
2007-10-30 Marek Habersack <mhabersack@novell.com>

* man/Makefile.am (EXTRA_DIST): added mono-asp-apps.1.in
(CLEANFILES): added mono-asp-apps.1

2007-10-30 Marek Habersack <mhabersack@novell.com>

* configure.in: added man/mono-asp-apps.1 to the list of generated
files.

* man/mono-asp-apps.1.in: added

2007-10-30 Marek Habersack <mhabersack@novell.com>

* tools/mono-asp-apps/README: added

2007-10-30 Marek Habersack <mhabersack@novell.com>

* tools/mono-asp-apps/mono-asp-apps: added

2007-10-29 Robert Jordan <robertj@gmx.net>

* src/Mono.WebServer.FastCgi/WorkerRequest.cs:
Expand Down
1 change: 1 addition & 0 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ AC_OUTPUT([
man/xsp.1
man/dbsessmgr.1
man/asp-state.1
man/mono-asp-apps.1
man/Makefile
scripts/Makefile
src/Makefile
Expand Down
4 changes: 2 additions & 2 deletions man/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
man_MANS = xsp.1 mod-mono-server.1 fastcgi-mono-server.1 dbsessmgr.1 asp-state.1
EXTRA_DIST = xsp.1.in dbsessmgr.1.in asp-state.1.in
CLEANFILES = mod-mono-server.1 fastcgi-mono-server.1 asp-state.1
EXTRA_DIST = xsp.1.in dbsessmgr.1.in asp-state.1.in mono-asp-apps.1.in
CLEANFILES = mod-mono-server.1 fastcgi-mono-server.1 asp-state.1 1 mono-asp-apps.1

mod-mono-server.1: xsp.1
cp xsp.1 $@
Expand Down
63 changes: 63 additions & 0 deletions man/mono-asp-apps.1.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
.\"
.\" mono-asp-apps manual page.
.\" (c) Copyright 2007 Novell, Inc.
.\" Author:
.\" Marek Habersack <mhabersack@novell.com>
.\"
.TH mono-asp-apps "1" "31 Oct 2007" "mono-asp-apps @VERSION@" "User Commands"
.SH NAME
mono-asp-apps - utility to manage ASP.NET 2.0 applications installed from RPMs
.SH SYNOPSIS
.B mono-asp-apps
command [options]
.SH DESCRIPTION
The 'mono-asp-apps' command is useful on systems which install applications from
RPM packages and when the RPM packages have been created according to the Mono
RPM packaging guidelines for ASP.NET applications.
.PP
The utility allows one to initialize, enable, disable and start installed applications.
Note that you do not use this utility to manage applications hosted and managed by
the Apache (or other) web server, only by xsp.
.PP
Note that this utility is useful only on systems where at least one application packaged
according to the Mono ASP.NET 2.0 RPM packaging guidelines has been installed.
.SH COMMANDS
The commands which take an application name, require the it to be one of the registered
names. See the \fB`list`\fR command below.
.TP
.I init APPLICATION_NAME
Initializes the application named \fBAPPLICATION_NAME\fR, if it hasn't been done already.
Initialization actions performed are application specific, but may include creating
databases and populating them, creating directories, downloading files etc.
.TP
.I enable APPLICATION_NAME
Enables \fBAPPLICATION_NAME\fR for automatic start when XSP is started as part of the
system bootup process.
.TP
.I disable APPLICATION_NAME
Disables \fBAPPLICATION_NAME\fR, so that it is not started automatically when XSP is
started as part of the system bootup process.
.TP
.I start APPLICATION_NAME [server_options]
Manually starts the xsp2 process passing the configuration of APPLICATION_NAME to the
xsp2 process. Applications may ship with a bundled \fIstart\fR script which will be
used instead of xsp2 if present. \fBserver_options\fB are passed verbatim to the
server process.
.TP
.I list
Lists all the applications known to the utility.

.SH AUTHORS
Marek Habersack <mhabersack@novell.com>

.SH SEE ALSO
.BR xsp (1)

.SH MORE INFORMATION
The Mono project (http://www.go-mono.com) is a collaborative effort
led by Novell (http://www.novell.com) to implement an open source
version of the .NET Framework.
.SH MAILING LISTS
Mailing lists are listed at the
http://www.mono-project.com/Mailing_Lists

5 changes: 5 additions & 0 deletions tools/mono-asp-apps/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This is a utility to manage ASP.NET applications installed from RPM
packages.

As such, it should not be installed with non-packaged XSP, only shipped
in the XSP RPM.
206 changes: 206 additions & 0 deletions tools/mono-asp-apps/mono-asp-apps
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
#!/bin/bash
ASP_APPS_ROOT=/usr/share/mono/asp.net
ASP_APPS_APPS=$ASP_APPS_ROOT/apps
ASP_APPS_DATA=$ASP_APPS_ROOT/data
XSP_CONFIGS_ROOT=/etc/xsp/2.0
XSP_ENABLED_APPS=$XSP_CONFIGS_ROOT/applications-enabled
XSP_AVAILABLE_APPS=$XSP_CONFIGS_ROOT/applications-available
PG_HBA_LOCATIONS="/var/lib/pgsql/data"
APP_NAME=""
APP_INFO=""
APP_ROOT=""
APP_DATA=""
COMMAND=""

function die ()
{
echo Error executing the script:
echo $*
echo
exit 1
}

function findApplication ()
{
if [ -z "$1" ]; then
die "Missing application name on the command line"
fi

if [ ! -f "$ASP_APPS_DATA/$1/info" -o ! -d "$ASP_APPS_APPS/$1" ]; then
die "Application '$1' not found"
fi

APP_NAME="$1"
APP_DATA="$ASP_APPS_DATA/$1"
APP_INFO="$APP_DATA/info"
APP_ROOT="$ASP_APPS_APPS/$1"
}

function load_app_info ()
{
. "$APP_INFO"
APP_NEEDS_INIT="`echo ${NeedsInit:-false} | tr A-Z a-z`"
APP_INITIALIZED="`echo ${Initialized:-false} | tr A-Z a-z`"

if [ "$COMMAND" != "init" -a "$APP_NEEDS_INIT" = "true" -a "$APP_INITIALIZED" = "false" ]; then
die -e "Application '$APP_NAME' needs to be initialized with command:\n\t/usr/bin/mono-asp-apps init $APP_NAME"
fi

if [ -z "$WebappFile" -o ! -f "$WebappFile" ]; then
die "Missing webapp file for application '$1'"
fi

if [ -z "$Version" ]; then
die "Missing application '$1' version information"
fi
}

function check_postgres_access ()
{
local ok=0
local hbaloc

for l in $PG_HBA_LOCATIONS; do
if [ ! -f "$l/pg_hba.conf" ]; then
continue
fi
hbaloc="$l/pg_hba.conf"
if egrep "^host[[:space:]]+all[[:space:]]+test[[:space:]]+127\.0\.0\.1/32[[:space:]]+md5" "$hbaloc" > /dev/null 2>&1; then
ok=1
break
fi
done

if [ $ok -ne 1 ]; then
if [ -z "$hbaloc" ]; then
cat <<EOF
PostgreSQL configuration does not exist. Typically, it means that you haven't
ran your PostgreSQL RDBMS for the first time yet. Please start the server
process by issuing the following command as root:
/etc/init.d/postgresql start
and then try runing $0 again.
EOF
die Missing PostgreSQL configuration
else
cat <<EOF
Your PostgreSQL configuration at $hbaloc is not ready for this application.
Please add the following code in the first line of the above file:
host all test 127.0.0.1/32 md5
And issue the following command:
/etc/init.d/postgresql restart
EOF
die Invalid PostgreSQL configuration
fi
fi
}

function command_init ()
{
local initfile
load_app_info
if [ "$APP_NEEDS_INIT" = "false" ]; then
exit 0
fi
if [ "$APP_INITIALIZED" = "true" ]; then
exit 0
fi

initfile="$APP_DATA/init"
if [ ! -x "$initfile" ]; then
die "Application '$APP_NAME' requires initialization, but init script '$initfile' is missing"
fi
check_postgres_access
pushd > /dev/null 2>&1
cd "$APP_DATA"

su -c "$initfile" -p postgres
popd > /dev/null 2>&1

sed -e 's/^Initialized="\(.*\)"/Initialized="true"/g' < "$APP_INFO" > "$APP_INFO".new
mv "$APP_INFO".new "$APP_INFO"
}

function command_enable ()
{
load_app_info
ln -sf "$WebappFile" "$XSP_ENABLED_APPS/`basename $WebappFile`"
}

function command_disable ()
{
local linkfile
load_app_info

linkfile="$XSP_ENABLED_APPS/`basename $WebappFile`"
if [ -L "$linkfile" ]; then
rm "$linkfile"
fi
}

function command_start ()
{
load_app_info
export MONO_IOMAP=all
if [ -x "$APP_DATA/start" ]; then
cd "$APP_DATA"
exec "$APP_DATA/start" $*
fi

exec xsp2 --appconfigfile "$WebappFile" $*
}

function command_list ()
{
local appname
local appversion

echo "Installed apps:"
for d in "$ASP_APPS_DATA"/*; do
if [ ! -d "$d" ]; then
continue
fi
if [ ! -f "$d"/info ]; then
continue
fi
appname="`cat \"$d\"/info | grep ^Name= | cut -d '\"' -f 2`"
appversion="`cat \"$d\"/info | grep ^Version= | cut -d '\"' -f 2`"
echo $appname-$appversion
done
}

function show_commands ()
{
cat <<EOF
Available commands:
init
enable
disable
start
list
EOF
exit 1
}

case $1 in
init|enable|disable|start|list) COMMAND="$1" ;;
*) if [ -z "$1" ]; then
show_commands
else
$die "Uknown command: $1"
fi ;;
esac

if [ "$COMMAND" != "list" ]; then
findApplication "$2"
shift 2
else
shift 1
fi
eval command_$COMMAND "$*"

0 comments on commit 32bbed1

Please sign in to comment.