2015-11-01 21:33:08 -05:00
|
|
|
#!/bin/bash
|
2017-12-14 02:02:42 -05:00
|
|
|
set -e
|
|
|
|
|
2017-12-14 18:11:00 -05:00
|
|
|
SCRIPTPATH=$(cd "$(dirname "$0")" > /dev/null; pwd -P)
|
|
|
|
SOURCE_DIR=$(cd "$SCRIPTPATH" > /dev/null; cd ../.. > /dev/null; pwd -P)
|
2017-05-18 11:36:12 -04:00
|
|
|
DATA_DIR="$SOURCE_DIR/data/postgres"
|
2015-11-01 21:33:08 -05:00
|
|
|
|
2016-09-20 18:35:50 -04:00
|
|
|
show_help() {
|
|
|
|
cat <<EOF
|
2016-12-12 01:39:20 -05:00
|
|
|
Usage: ${0##*/} [-h] [--init]
|
2015-11-01 21:33:08 -05:00
|
|
|
|
2016-09-20 18:35:50 -04:00
|
|
|
--init perform first-time initialization
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
initialize=""
|
|
|
|
|
|
|
|
while [ "${#@}" -ne "0" ]; do
|
|
|
|
case "$1" in
|
|
|
|
-h | --help)
|
|
|
|
show_help
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
-i | --init)
|
|
|
|
initialize="initialize"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "unexpected argument: $1" >& 2
|
|
|
|
show_help >& 2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
echo "Using source in: ${SOURCE_DIR}"
|
|
|
|
echo "Using data in: ${DATA_DIR}"
|
|
|
|
|
|
|
|
mkdir -p "${DATA_DIR}"
|
|
|
|
|
2017-05-16 11:05:11 -04:00
|
|
|
docker run -d -p 1080:1080 -p 3000:3000 -v "$DATA_DIR:/shared/postgres_data" -v "$SOURCE_DIR:/src" --hostname=discourse --name=discourse_dev --restart=always discourse/discourse_dev:release /sbin/boot
|
2016-09-20 18:35:50 -04:00
|
|
|
|
|
|
|
if [ "${initialize}" = "initialize" ]; then
|
|
|
|
echo "Installing gems..."
|
2017-04-12 12:41:23 -04:00
|
|
|
"${SCRIPTPATH}/bundle" install
|
2016-09-20 18:35:50 -04:00
|
|
|
|
|
|
|
echo "Migrating database..."
|
2017-04-12 12:41:23 -04:00
|
|
|
"${SCRIPTPATH}/rake" db:migrate
|
2017-04-12 13:33:56 -04:00
|
|
|
RAILS_ENV=test "${SCRIPTPATH}/rake" db:migrate
|
2015-11-01 21:33:08 -05:00
|
|
|
|
2016-09-20 18:35:50 -04:00
|
|
|
echo "Creating admin user..."
|
2017-04-12 12:41:23 -04:00
|
|
|
"${SCRIPTPATH}/rake" admin:create
|
2016-09-20 18:35:50 -04:00
|
|
|
fi
|