3 # GNU MediaGoblin -- federated, autonomous media hosting
4 # Copyright (C) 2011, 2012 GNU MediaGoblin Contributors. See AUTHORS.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU Affero General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU Affero General Public License for more details.
16 # You should have received a copy of the GNU Affero General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 USAGE
="Usage: $0 -h | [-p PATH] -e ENVIRONMENT"
21 ENVIRONMENT
="migration-18"
22 USER_DEV
="user_dev_default"
23 DEV_ENV_DIRECTORY_PATH
="../mg-dev-environments"
25 while getopts ":hp:e:" opt
;
30 echo "Sets up an example mediagoblin instance for testing code."
32 echo " -h Shows this help message."
33 echo " -p=PATH The path to your mg-dev-environments repository"
34 echo " -e=ENVIRONMENT The name of the environment you want to set up. Useful"
35 echo " if you want to set up a database from a past version."
36 echo " This defaults to a database from the most recent version"
44 DEV_ENV_DIRECTORY_PATH
=$OPTARG
47 echo "Invalid Option: -$OPTARG" >&2
50 echo "Option -$OPTARG requires an argument" >&2
55 if [ ! -d $DEV_ENV_DIRECTORY_PATH ]; then
56 echo "$DEV_ENV_DIRECTORY_PATH not found. Have you downloaded the repo from \
57 git@gitorious.org:mediagoblin/mg-dev-environments.git ?" >&2
62 if [ ! -d "user_dev" ]; then
63 echo "ERROR: This script should be executed from within your mediagoblin \
64 instance directory" >&2
68 if [ ! -e "$DEV_ENV_DIRECTORY_PATH/$ENVIRONMENT.tar.gz" ]; then
69 echo "$ENVIRONMENT.tar.gz not found in directory $DEV_ENV_DIRECTORY_PATH" >&2
73 echo "This script will WIPE YOUR FULL CURRENT ENVIRONMENT and REPLACE IT with a test database and media!"
74 echo "Your databases and user_dev/ will all likely be wiped!"
75 echo -n "Do you want to continue? (y/n) "
79 while [ "$USER_CONFIRM"=="y" ]; do
88 if [ $counter -lt 5 ]; then
89 echo "Invalid option. Please enter 'y' or 'n'"
90 echo "Do you want to continue? (y/n)"
101 tar -xzf $DEV_ENV_DIRECTORY_PATH/$ENVIRONMENT.
tar.gz
102 tar -xzf $DEV_ENV_DIRECTORY_PATH/$USER_DEV.
tar.gz