Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • DM/dm-docs
  • hammonds/dm-docs
  • hparraga/dm-docs
3 results
Show changes
Showing
with 572 additions and 0 deletions
#!/bin/sh
#
# Script used for destroying all DM databases
# Deployment configuration can be set in etc/$DM_DB_NAME.deploy.conf file
#
# Usage:
#
# $0 [DM_DB_NAME [DM_DB_SCRIPTS_DIR]]
#
DM_DB_NAME=dm
DM_DB_USER=dm
DM_DB_PASSWORD=dm
DM_DB_HOST=127.0.0.1
DM_DB_PORT=11136
DM_DB_ADMIN_USER=postgres
DM_DB_ADMIN_HOSTS="127.0.0.1 bluegill1.aps.anl.gov visa%.aps.anl.gov"
DM_DB_ADMIN_PASSWORD=
DM_DB_CHARACTER_SET=utf8
CURRENT_DIR=`pwd`
MY_DIR=`dirname $0` && cd $MY_DIR && MY_DIR=`pwd`
cd $CURRENT_DIR
if [ -z "${DM_ROOT_DIR}" ]; then
DM_ROOT_DIR=$MY_DIR/..
fi
DM_SQL_DIR=$DM_ROOT_DIR/db
DM_RUN_DIR=$DM_ROOT_DIR/var/run
DM_ENV_FILE=${DM_ROOT_DIR}/setup.sh
if [ ! -f ${DM_ENV_FILE} ]; then
echo "Environment file ${DM_ENV_FILE} does not exist."
exit 1
fi
. ${DM_ENV_FILE} > /dev/null
# DM_SUPPORT_DIR should now be defined.
if [ -z "$DM_SUPPORT_DIR" ]; then
echo "Invalid environment file ${DM_ENV_FILE}: DM_SUPPORT_DIR is not defined."
exit 1
fi
PG_DIR=$DM_SUPPORT_DIR/postgresql/$DM_HOST_ARCH
PG_CONTROL_SCRIPT=$DM_ROOT_DIR/etc/init.d/dm-postgresql
PG_DATA_DIR=$PG_DIR/data
PG_HBA_CONF=$PG_DATA_DIR/pg_hba.conf
DB_LOCK_FILE=${DB_RUN_DIR}/${_db_name}.db.lock
DB_CREATE_SCRIPT=${DM_ROOT_DIR}/db/create_${DM_DB_NAME}_db.sql
# Use first argument as db name, if provided
if [ ! -z "$1" ]; then
DM_DB_NAME=$1
fi
echo "Using DB name: $DM_DB_NAME"
# Look for deployment file in etc directory, and use it to override
# default entries
deployConfigFile=$DM_ROOT_DIR/etc/${DM_DB_NAME}.deploy.conf
if [ -f $deployConfigFile ]; then
echo "Using deployment config file: $deployConfigFile"
. $deployConfigFile
else
echo "Deployment config file $deployConfigFile not found, using defaults"
fi
# Second argument overrides directory with db population scripts
DM_DB_SCRIPTS_DIR=${DM_DB_SCRIPTS_DIR:=$DM_SQL_DIR}
if [ ! -z "$2" ]; then
DM_DB_SCRIPTS_DIR=$2
fi
if [ ! -d $DM_DB_SCRIPTS_DIR ]; then
echo "DB Scripts directory $DM_DB_SCRIPTS_DIR does not exist."
exit 1
fi
echo "Using DB scripts directory: $DM_DB_SCRIPTS_DIR"
execute() {
msg="$@"
if [ ! -z "$DM_DB_ADMIN_PASSWORD" ]; then
sedCmd="s?$DM_DB_ADMIN_PASSWORD?\\*\\*\\*\\*\\*\\*?g"
echo "Executing: $@" | sed -e $sedCmd
else
echo "Executing: $@"
fi
eval "$@"
}
createDb() {
if [ -f $DB_LOCK_FILE ]; then
echo "Database lock file $DB_LOCK_FILE already exists, will not proceed."
return 1
fi
execute ${PG_DIR}/bin/createdb -U $DM_DB_USER -h $DM_DB_HOST -p $DM_DB_PORT $DM_DB_NAME || return 1
execute ${PG_DIR}/bin/psql -U $DM_DB_USER -h $DM_DB_HOST -p $DM_DB_PORT -d $DM_DB_NAME -f $DM_DB_SCRIPT || return 1
touch $DB_LOCK_FILE
}
createDbUser() {
_dbUser=$1
_dbPassword=$2
shift 2
_dbFlags=$@
# create user
execute ${PG_DIR}/bin/createuser -h $DM_DB_HOST -p $DM_DB_PORT -E $_dbFlags $_dbUser || return 1
# modify password
_tmpFile=/tmp/$$.sql
echo "alter user $_dbUser with password '$_$dbPassword';" > $_tmpFile
$PG_DIR/bin/psql -h $DB_HOST -p $DB_PORT -d postgres -f $_tmpFile
rm -f $_tmpFile
}
# Check for failed earlier attempt
if [ -f $PG_HBA_CONF.orig ]; then
echo "File $PG_HBA_CONF.orig exists, refusing to proceed."
exit 1
fi
# create db tables
# Initialize db if needed
dbAction=restart
createDbUsers=false
if [ ! -f $PG_HBA_CONF ]; then
echo "PG_HBA_CONF: $PG_HBA_CONF"
echo "Initializing database"
$PG_CONTROL_SCRIPT initdb || exit 1
dbAction=start
createDbUsers=true
fi
# Modify db permissions, restart db.
echo "Modifying db access permissions"
mv $PG_HBA_CONF $PG_HBA_CONF.orig
cat $PG_HBA_CONF.orig | sed 's?host.*all.*all.*127.*?host all all 127.0.0.1/32 trust?g' | sed 's?host.*all.*all.*::1/128.*?host all all ::1/128 trust?g' > $PG_HBA_CONF || exit 1
echo "Restarting database server"
$PG_CONTROL_SCRIPT $dbAction
# Create db users if needed
if [ $createDbUsers = "true" ]; then
# Read db passwords
if [ -z "$DM_DB_ADMIN_PASSWORD" ]; then
sttyOrig=`stty -g`
stty -echo
read -p "Enter DB password for the $DM_DB_ADMIN_USER (DB root) user: " DM_DB_ADMIN_PASSWORD
read -p "Enter DB password for the $DM_DB_USER user:" DM_DB_PASSWORD
stty $sttyOrig
fi
# Add superuser flag for the DB root user
echo "Creating $DM_DB_ADMIN_USER"
createDbUser $DM_DB_ADMIN_USER $DB_DB_ADMIN_PASSWORD -s || exit 1
# Allow database creation for the DM user
echo "Creating $DM_DB_USER"
createDbUser $DM_DB_ADMIN_USER $DB_DB_ADMIN_PASSWORD -d || exit 1
fi
# Create db
echo "Creating database: $DM_DB_NAME"
createDb || exit 1
# populate db
cd $CURRENT_DIR && cd $DM_DB_SCRIPTS_DIR
DM_DB_TABLES="\
"
#for dbTable in $DM_DB_TABLES; do
# dbFile=populate_$dbTable.sql
# if [ -f $dbFile ]; then
# echo "Populating $dbTable using $dbFile script"
# execute $mysqlCmd $dbFile
# else
# echo "$dbFile not found, skipping $dbTable update"
# fi
#done
# cleanup
echo "Restoring db access permissions"
mv $PG_HBA_CONF.orig $PG_HBA_CONF
#!/bin/sh
DM_SVN_URL=https://subversion.xray.aps.anl.gov/DataManagement
MY_DIR=`dirname $0` && cd $MY_DIR && MY_DIR=`pwd`
if [ -z "${DM_ROOT_DIR}" ]; then
DM_ROOT_DIR=$MY_DIR/..
fi
DM_SUPPORT_DIR=$DM_ROOT_DIR/../support
execute() {
echo "Executing: $@"
eval "$@"
}
if [ ! -d $DM_SUPPORT_DIR ]; then
echo "Creating new DM support directory $DM_SUPPORT_DIR."
cd `dirname $DM_SUPPORT_DIR`
execute svn co $DM_SVN_URL/support support
fi
cd $DM_SUPPORT_DIR
execute svn update
execute $DM_SUPPORT_DIR/bin/clean_all.sh
execute $DM_SUPPORT_DIR/bin/install_all.sh
#!/bin/sh
SVN_ROOT=https://subversion.xray.aps.anl.gov/DataManagement
svn ls $SVN_ROOT/tags
#!/bin/sh
SVN_ROOT=https://subversion.xray.aps.anl.gov/DataManagement
version=$1
if [ -z $version ]; then
echo "Usage: $0 <version>"
exit 1
fi
svn copy $SVN_ROOT/trunk $SVN_ROOT/tags/$version -m "Creating tag $version"
#!/bin/sh
#
# Script used for un-configuring DM webapp
# Deployment configuration can be set in etc/$DM_DB_NAME.deploy.conf file
#
# Usage:
#
# $0 [DM_DB_NAME]
#
MY_DIR=`dirname $0` && cd $MY_DIR && MY_DIR=`pwd`
if [ -z "${DM_ROOT_DIR}" ]; then
DM_ROOT_DIR=$MY_DIR/..
fi
DM_ENV_FILE=${DM_ROOT_DIR}/setup.sh
if [ ! -f ${DM_ENV_FILE} ]; then
echo "Environment file ${DM_ENV_FILE} does not exist."
exit 2
fi
. ${DM_ENV_FILE} > /dev/null
# Use first argument as db name, if provided
DM_DB_NAME=${DM_DB_NAME:=dm}
if [ ! -z "$1" ]; then
DM_DB_NAME=$1
fi
echo "Using DB name: $DM_DB_NAME"
# Look for deployment file in etc directory, and use it to override
# default entries
deployConfigFile=$DM_ROOT_DIR/etc/${DM_DB_NAME}.deploy.conf
if [ -f $deployConfigFile ]; then
echo "Using deployment config file: $deployConfigFile"
. $deployConfigFile
else
echo "Deployment config file $deployConfigFile not found, using defaults"
fi
DM_HOST_ARCH=`uname | tr [A-Z] [a-z]`-`uname -m`
GLASSFISH_DIR=$DM_SUPPORT_DIR/glassfish/$DM_HOST_ARCH
JAVA_HOME=$DM_SUPPORT_DIR/java/$DM_HOST_ARCH
export AS_JAVA=$JAVA_HOME
ASADMIN_CMD=$GLASSFISH_DIR/bin/asadmin
DM_DB_POOL=postgresql_${DM_DB_NAME}_DbPool
DM_DATA_SOURCE=${DM_DB_NAME}_DataSource
DM_DOMAIN=domain1
# restart server
echo "Restarting glassfish"
$ASADMIN_CMD stop-domain ${DM_DOMAIN}
$ASADMIN_CMD start-domain ${DM_DOMAIN}
# delete JDBC resource associated with this connection pool
echo "Deleting JDBC resource $DM_DATA_SOURCE"
$ASADMIN_CMD delete-jdbc-resource ${DM_DATA_SOURCE}
# delete JDBC connection pool
echo "Deleting JDBC connection pool $DM_DB_POOL"
$ASADMIN_CMD delete-jdbc-connection-pool ${DM_DB_POOL}
#!/bin/sh
#
# Script used for undeploying DM webapp
# Deployment configuration can be set in etc/$DM_DB_NAME.deploy.conf file
#
# Usage:
#
# $0 [DM_DB_NAME]
#
MY_DIR=`dirname $0` && cd $MY_DIR && MY_DIR=`pwd`
if [ -z "${DM_ROOT_DIR}" ]; then
DM_ROOT_DIR=$MY_DIR/..
fi
DM_ENV_FILE=${DM_ROOT_DIR}/setup.sh
if [ ! -f ${DM_ENV_FILE} ]; then
echo "Environment file ${DM_ENV_FILE} does not exist."
exit 2
fi
. ${DM_ENV_FILE} > /dev/null
# Use first argument as db name, if provided
DM_DB_NAME=${DM_DB_NAME:=dm}
if [ ! -z "$1" ]; then
DM_DB_NAME=$1
fi
echo "Using DB name: $DM_DB_NAME"
# Look for deployment file in etc directory, and use it to override
# default entries
deployConfigFile=$DM_ROOT_DIR/etc/${DM_DB_NAME}.deploy.conf
if [ -f $deployConfigFile ]; then
echo "Using deployment config file: $deployConfigFile"
. $deployConfigFile
else
echo "Deployment config file $deployConfigFile not found, using defaults"
fi
DM_HOST_ARCH=`uname | tr [A-Z] [a-z]`-`uname -m`
DM_CONTEXT_ROOT=${DM_CONTEXT_ROOT:=DmWebPortal}
GLASSFISH_DIR=$DM_SUPPORT_DIR/glassfish/$DM_HOST_ARCH
DM_DEPLOY_DIR=$GLASSFISH_DIR/glassfish/domains/domain1/autodeploy
DM_APP_DIR=$GLASSFISH_DIR/glassfish/domains/domain1/applications/$DM_CONTEXT_ROOT
DM_DIST_DIR=$DM_ROOT_DIR/src/java/DmWebPortal/dist
DM_WAR_FILE=$DM_CONTEXT_ROOT.war
JAVA_HOME=$DM_SUPPORT_DIR/java/$DM_HOST_ARCH
export AS_JAVA=$JAVA_HOME
ASADMIN_CMD=$GLASSFISH_DIR/bin/asadmin
# remove war file from autodeploy directory
echo "Removing war file $DM_DEPLOY_DIR/$DM_WAR_FILE"
rm -f $DM_DEPLOY_DIR/${DM_WAR_FILE}*
# remove war file from autodeploy directory
if [ -d $DM_APP_DIR ]; then
echo "Removing application directory $DM_APP_DIR"
rm -rf $DM_APP_DIR
else
echo "Application directory $DM_APP_DIR not found"
fi
# restart server
echo "Restarting glassfish"
$ASADMIN_CMD stop-domain ${DM_DOMAIN}
$ASADMIN_CMD start-domain ${DM_DOMAIN}
#!/bin/sh
# DM setup script for Bourne-type shells
# This file is typically sourced in user's .bashrc file
myDir=`dirname $BASH_SOURCE`
currentDir=`pwd` && cd $myDir
if [ ! -z "$DM_ROOT_DIR" -a "$DM_ROOT_DIR" != `pwd` ]; then
echo "WARNING: Resetting DM_ROOT_DIR environment variable (old value: $DM_ROOT_DIR)"
fi
export DM_ROOT_DIR=`pwd`
export DM_HOST_ARCH=`uname | tr [A-Z] [a-z]`-`uname -m`
if [ -z $DM_DATA_DIR ]; then
export DM_DATA_DIR=$DM_ROOT_DIR/../data
if [ -d $DM_DATA_DIR ]; then
cd $DM_DATA_DIR
export DM_DATA_DIR=`pwd`
fi
fi
if [ ! -d $DM_DATA_DIR ]; then
#echo "WARNING: $DM_DATA_DIR directory does not exist. Developers should point DM_DATA_DIR to the desired area."
unset DM_DATA_DIR
fi
if [ -z $DM_VAR_DIR ]; then
export DM_VAR_DIR=$DM_ROOT_DIR/../var
if [ -d $DM_VAR_DIR ]; then
cd $DM_VAR_DIR
export DM_VAR_DIR=`pwd`
fi
fi
# Check support setup
if [ -z $DM_SUPPORT_DIR ]; then
export DM_SUPPORT_DIR=$DM_ROOT_DIR/../support
if [ -d $DM_SUPPORT_DIR ]; then
cd $DM_SUPPORT_DIR
export DM_SUPPORT_DIR=`pwd`
fi
fi
if [ ! -d $DM_SUPPORT_DIR ]; then
echo "ERROR: $DM_SUPPORT_DIR directory does not exist. Developers should point DM_SUPPORT_DIR to the desired area."
unset DM_SUPPORT_DIR
return 1
else
export DM_GLASSFISH_DIR=$DM_SUPPORT_DIR/glassfish/$DM_HOST_ARCH
fi
# Add to path only if directory exists.
prependPathIfDirExists() {
_dir=$1
if [ -d ${_dir} ]; then
PATH=${_dir}:$PATH
fi
}
# Setup path and other variables
prependPathIfDirExists $DM_SUPPORT_DIR/postgresql/$DM_HOST_ARCH/bin
prependPathIfDirExists $DM_SUPPORT_DIR/java/$DM_HOST_ARCH/bin
prependPathIfDirExists $DM_SUPPORT_DIR/ant/bin
prependPathIfDirExists $DM_ROOT_DIR/bin
PATH=.:$PATH
export PATH
if [ -z $LD_LIBRARY_PATH ]; then
LD_LIBRARY_PATH=.
else
LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH
fi
export LD_LIBRARY_PATH
# Setup python path.
# Check if we have local python
if [ -z $DM_PYTHON_DIR ]; then
pythonDir=$DM_SUPPORT_DIR/python/$DM_HOST_ARCH
else
pythonDir=$DM_PYTHON_DIR
fi
if [ -d $pythonDir ]; then
cd $pythonDir
pythonDir=`pwd`
export PATH=`pwd`/bin:$PATH
export LD_LIBRARY_PATH=`pwd`/lib:$LD_LIBRARY_PATH
export DM_PYTHON_DIR=$pythonDir
fi
if [ -z $PYTHONPATH ]; then
PYTHONPATH=$DM_ROOT_DIR/lib/python
else
PYTHONPATH=$DM_ROOT_DIR/lib/python:$PYTHONPATH
fi
export PYTHONPATH
# Get back to where we were before invoking the setup script
cd $currentDir
# Print out user environment
echo
echo "Your DM environment is defined as follows:"
echo
env | grep DM_ | grep -v GDM_
echo
echo
TOP = ..
SUBDIRS = java
include $(TOP)/tools/make/RULES_DM
TOP=../../..
ANT=dm-ant
ANT_ARGS=-Dlibs.CopyLibs.classpath=lib/org-netbeans-modules-java-j2seproject-copylibstask.jar
BUILD_PROPERTIES_FILE=nbproject/private/private.properties
GENERIC_BUILD_PROPERTIES_FILE=$(BUILD_PROPERTIES_FILE).generic.build
all install: dist
clean clean-all clean-install distclean: ant-clean
.PHONY: propertiesFile
propertiesFile:
if [ ! -f $(BUILD_PROPERTIES_FILE) ]; then cmd="cat $(GENERIC_BUILD_PROPERTIES_FILE) | sed 's?DM_GLASSFISH_DIR?$${DM_GLASSFISH_DIR}?g' > $(BUILD_PROPERTIES_FILE)" && eval $$cmd ; fi
.PHONY: ant-clean
ant-clean: propertiesFile
$(ANT) $(ANT_ARGS) clean
# For compiling from command line, we have to use generic build properties file
.PHONY: dist
dist: propertiesFile
if [ -f $(BUILD_PROPERTIES_FILE) ]; then mv $(BUILD_PROPERTIES_FILE) $(BUILD_PROPERTIES_FILE).orig; fi
cmd="cat $(GENERIC_BUILD_PROPERTIES_FILE) | sed 's?DM_GLASSFISH_DIR?$${DM_GLASSFISH_DIR}?g' > $(BUILD_PROPERTIES_FILE)" && eval $$cmd
$(ANT) $(ANT_ARGS) dist
if [ -f $(BUILD_PROPERTIES_FILE).orig ]; then mv $(BUILD_PROPERTIES_FILE).orig $(BUILD_PROPERTIES_FILE); fi
<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. -->
<!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project name="DmWebPortal" default="default" basedir=".">
<description>Builds, tests, and runs the project DmWebPortal.</description>
<import file="nbproject/build-impl.xml"/>
<!--
There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed
before and after some main targets. They are:
-pre-init: called before initialization of project properties
-post-init: called after initialization of project properties
-pre-compile: called before javac compilation
-post-compile: called after javac compilation
-pre-compile-single: called before javac compilation of single file
-post-compile-single: called after javac compilation of single file
-pre-compile-test: called before javac compilation of JUnit tests
-post-compile-test: called after javac compilation of JUnit tests
-pre-compile-test-single: called before javac compilation of single JUnit test
-post-compile-test-single: called after javac compilation of single JUunit test
-pre-dist: called before archive building
-post-dist: called after archive building
-post-clean: called after cleaning build products
-pre-run-deploy: called before deploying
-post-run-deploy: called after deploying
Example of pluging an obfuscator after the compilation could look like
<target name="-post-compile">
<obfuscate>
<fileset dir="${build.classes.dir}"/>
</obfuscate>
</target>
For list of available properties check the imported
nbproject/build-impl.xml file.
Other way how to customize the build is by overriding existing main targets.
The target of interest are:
init-macrodef-javac: defines macro for javac compilation
init-macrodef-junit: defines macro for junit execution
init-macrodef-debug: defines macro for class debugging
do-dist: archive building
run: execution of project
javadoc-build: javadoc generation
Example of overriding the target for project execution could look like
<target name="run" depends="<PROJNAME>-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
</target>
Notice that overridden target depends on jar target and not only on
compile target as regular run target does. Again, for list of available
properties which you can use check the target you are overriding in
nbproject/build-impl.xml file.
-->
</project>
File added
File added
File added
File added
File added
File added