Skip to content

Instantly share code, notes, and snippets.

@mwoodiupui
Last active August 29, 2015 14:05
Show Gist options
  • Save mwoodiupui/6af80f8b4c4e1ad687c1 to your computer and use it in GitHub Desktop.
Save mwoodiupui/6af80f8b4c4e1ad687c1 to your computer and use it in GitHub Desktop.
Shell script to create a customized build.properties for DSpace
#! /bin/sh
# Copyright 2014 Indiana University
# Mark H. Wood, IUPUI University Library
### Configure me!
DS_HOST=${DSENV_HOST:-`hostname -f`}
DS_PORT=${DSENV_PORT:-8080}
DS_HOME="${HOME}/dspaces" # MAGIC
[email protected] # MAGIC
### Defaults
DBMS='postgres'
DB_HOST=localhost
### Options
while getopts '?h:o' option
do
case "${option}" in
'o')
DBMS='oracle'
;;
'h')
DB_HOST=${OPTARG}
;;
'?')
echo $0 '[-o] [-h db-host] name'
echo '"db-host" defaults to localhost'
exit
;;
*)
echo Known but unimplemented option ${option}
exit
;;
esac
done
### Collect specifics
shift $(( OPTIND - 1 ))
DS_NAME=$1
if [ "x${DS_NAME}" = "x" ]
then
echo "Please specify a name for the environment/context/database"
exit 1
fi
FILE=${DS_NAME}.properties
read -p "DB password: " -s
DB_PW="${REPLY}"
echo ""
case "${DBMS}" in
'oracle')
DB_DRIVER='oracle.jdbc.OracleDriver'
DB_PORT=1521
DB_URL="jdbc:oracle:thin:@${DB_HOST}:${DB_PORT}/XE" # MAGIC
DB_USER=${DS_NAME}
echo "Don't forget: mvn -Ddb.name=oracle"
;;
'postgres')
DB_NAME="${DS_NAME}"
DB_DRIVER='org.postgresql.Driver'
DB_PORT=5432
DB_URL="jdbc:postgresql://${DB_HOST}:${DB_PORT}/${DB_NAME}"
DB_USER=${USER}
;;
*)
echo "Unknown DBMS: ${DBMS}"
echo "Try 'oracle' or 'postgres'."
exit 1
;;
esac
### Generate the file
cat > ${FILE} <<- EOF
dspace.install.dir = ${DS_HOME}/${DS_NAME}
dspace.hostname = ${DS_HOST}
dspace.baseUrl = http://${DS_HOST}:${DS_PORT}/${DS_NAME}
dspace.name = ${DS_NAME}
solr.server = http://${DS_HOST}:${DS_PORT}/${DS_NAME}/solr
default.language = en_US
db.name = ${DBMS}
db.driver = ${DB_DRIVER}
db.url = ${DB_URL}
db.username = ${DB_USER}
db.password = ${DB_PW}
db.schema =
db.maxconnections = 30
db.maxwait = 5000
db.maxidle = -1
db.statementpool = true
db.poolname = dspacepool
mail.server = localhost
mail.server.username=
mail.server.password=
mail.server.port = 25
mail.from.address = ${DS_NAME}@${DS_HOST}
mail.feedback.recipient = ${DS_ADMIN}
mail.admin = ${DS_ADMIN}
mail.alert.recipient = ${DS_ADMIN}
mail.registration.notify = ${DS_ADMIN}
handle.canonical.prefix = http://hdl.handle.net/
handle.prefix = 123456789
http.proxy.host =
http.proxy.port =
loglevel.other = INFO
loglevel.dspace = INFO
EOF
chmod g-rwx,o-rwx ${FILE}
### Done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment