Skip to content

Commit

Permalink
Remove reference_data.sql usages. IQSS#7256
Browse files Browse the repository at this point in the history
  • Loading branch information
poikilotherm committed Oct 23, 2020
1 parent b0dea63 commit 1a122d4
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 108 deletions.
9 changes: 2 additions & 7 deletions scripts/installer/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ DISTRIBUTION_WAR_FILE=${INSTALLER_ZIP_DIR}/dataverse.war
GLASSFISH_SETUP_SCRIPT=${INSTALLER_ZIP_DIR}/as-setup.sh
POSTGRES_DRIVERS=${INSTALLER_ZIP_DIR}/pgdriver
API_SCRIPTS=${INSTALLER_ZIP_DIR}/setup-datasetfields.sh ${INSTALLER_ZIP_DIR}/setup-users.sh ${INSTALLER_ZIP_DIR}/setup-builtin-roles.sh ${INSTALLER_ZIP_DIR}/setup-dvs.sh ${INSTALLER_ZIP_DIR}/data ${INSTALLER_ZIP_DIR}/setup-identity-providers.sh ${INSTALLER_ZIP_DIR}/setup-all.sh ${INSTALLER_ZIP_DIR}/post-install-api-block.sh
DB_SCRIPT=${INSTALLER_ZIP_DIR}/reference_data.sql
JHOVE_CONFIG=${INSTALLER_ZIP_DIR}/jhove.conf
JHOVE_SCHEMA=${INSTALLER_ZIP_DIR}/jhoveConfig.xsd
SOLR_SCHEMA=${INSTALLER_ZIP_DIR}/schema.xml ${INSTALLER_ZIP_DIR}/schema_dv_mdb_fields.xml ${INSTALLER_ZIP_DIR}/schema_dv_mdb_copies.xml ${INSTALLER_ZIP_DIR}/updateSchemaMDB.sh
Expand All @@ -16,9 +15,9 @@ installer: dvinstall.zip
clean:
/bin/rm -rf ${INSTALLER_ZIP_DIR} dvinstall.zip

dvinstall.zip: ${GLASSFISH_SETUP_SCRIPT} ${POSTGRES_DRIVERS} ${JSF_PATCH_DIR} ${DISTRIBUTION_WAR_FILE} ${API_SCRIPTS} ${DB_SCRIPT} ${JHOVE_CONFIG} ${JHOVE_SCHEMA} ${SOLR_SCHEMA} ${SOLR_CONFIG} ${PYTHON_FILES} ${INSTALL_SCRIPT}
dvinstall.zip: ${GLASSFISH_SETUP_SCRIPT} ${POSTGRES_DRIVERS} ${JSF_PATCH_DIR} ${DISTRIBUTION_WAR_FILE} ${API_SCRIPTS} ${JHOVE_CONFIG} ${JHOVE_SCHEMA} ${SOLR_SCHEMA} ${SOLR_CONFIG} ${PYTHON_FILES} ${INSTALL_SCRIPT}
@echo making installer...
zip -r dvinstall.zip ${GLASSFISH_SETUP_SCRIPT} ${POSTGRES_DRIVERS} ${JSF_PATCH_DIR} ${DISTRIBUTION_WAR_FILE} ${API_SCRIPTS} ${DB_SCRIPT} ${JHOVE_CONFIG} ${JHOVE_SCHEMA} ${SOLR_SCHEMA} ${SOLR_CONFIG} ${PYTHON_FILES} ${INSTALL_SCRIPT}
zip -r dvinstall.zip ${GLASSFISH_SETUP_SCRIPT} ${POSTGRES_DRIVERS} ${JSF_PATCH_DIR} ${DISTRIBUTION_WAR_FILE} ${API_SCRIPTS} ${JHOVE_CONFIG} ${JHOVE_SCHEMA} ${SOLR_SCHEMA} ${SOLR_CONFIG} ${PYTHON_FILES} ${INSTALL_SCRIPT}
@echo
@echo "Done!"

Expand Down Expand Up @@ -55,10 +54,6 @@ ${API_SCRIPTS}: ../api/setup-datasetfields.sh ../api/setup-users.sh ../api/setup
@echo copying api scripts
/bin/cp -R ../api/setup-datasetfields.sh ../api/setup-users.sh ../api/setup-dvs.sh ../api/setup-identity-providers.sh ../api/setup-all.sh ../api/post-install-api-block.sh ../api/setup-builtin-roles.sh ../api/data ${INSTALLER_ZIP_DIR}

${DB_SCRIPT}: ../database/reference_data.sql ${INSTALLER_ZIP_DIR}
@echo copying reference data sql script
/bin/cp ../database/reference_data.sql ${INSTALLER_ZIP_DIR}

${JHOVE_CONFIG}: ../../conf/jhove/jhove.conf ${INSTALLER_ZIP_DIR}
@echo copying jhove config file
/bin/cp ../../conf/jhove/jhove.conf ${INSTALLER_ZIP_DIR}
Expand Down
4 changes: 0 additions & 4 deletions scripts/installer/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ setup-identity-providers.sh
setup-users.sh
data (the entire directory with all its contents)

from scripts/database:

reference_data.sql

from conf/jhove:

jhove.conf
Expand Down
71 changes: 1 addition & 70 deletions scripts/installer/install
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ if (exists($ENV{'MY_POD_NAME'}))
my $jq_exec_path = "";
my $psql_exec_path = "";
my $cwd;
my $WARFILE_LOCATION = "dataverse.war";
my $REFERENCE_DATA_SQL = "../database/reference_data.sql";
my $WARFILE_LOCATION = "dataverse.war";


my @CONFIG_VARIABLES;
Expand Down Expand Up @@ -317,23 +316,6 @@ unless ($postgresonly)
# 1b. check and remember the working dir:
chomp( $cwd = `pwd` );

# 1c. check if the reference data SQL file is there:

$REFERENCE_DATA_SQL = "../database/reference_data.sql";

unless ( -f $REFERENCE_DATA_SQL ) {
# if it's not in ../database, then we're probably running out of the
# unzipped installer bundle, so it should be right here in the current directory:
$REFERENCE_DATA_SQL = "reference_data.sql";
}

unless ( -f $REFERENCE_DATA_SQL ) {
print "\nWARNING: Can't find .sql data template!\n";
print "(are you running the installer in the right directory?)\n";

exit 0;
}

# 1d. jq executable:

my $sys_path = $ENV{'PATH'};
Expand Down Expand Up @@ -563,15 +545,6 @@ my $glassfish_dir = $CONFIG_DEFAULTS{'GLASSFISH_DIRECTORY'};

my $done = &setup_appserver();

# 7. POPULATE THE DATABASE WITH REFERENCE DATA
# TODO: move this further down
# (in this step some pre-supplied content is inserted into the database that we have just created;
# it is not *necessary* for the application to run in the very basic mode; but some features - certain
# types of metadata imports, for example - will be unavailable if it's not done.

&import_reference_data();


# Check if the App is running:

unless ((
Expand Down Expand Up @@ -1513,48 +1486,6 @@ sub setup_postgres {
}
}

sub import_reference_data {
print "\npopulating the database with reference data:\n\n";

# (we have already verified that the referenceData.sql file exists)

my $psql_command = $psql_exec_path . "/psql -h " . $CONFIG_DEFAULTS{'POSTGRES_SERVER'}
. " -p " . $CONFIG_DEFAULTS{'POSTGRES_PORT'}
. " -U " . $CONFIG_DEFAULTS{'POSTGRES_USER'}
. " -d " . $CONFIG_DEFAULTS{'POSTGRES_DATABASE'} . " -f " . $REFERENCE_DATA_SQL;

print "EXECUTING PSQL COMMAND: $psql_command\n";
unless ( ( my $exitcode = system("$psql_command") ) == 0 )
{
print "WARNING: Could not pre-populate Postgres database for the Dataverse application!\n";
print "(command: " . $psql_command . ")\n";
print "(psql exit code: " . $exitcode . ")\n";
print "\nYou must populate the database in order for all the features of your \n";
print "new Dataverse to be available. \n";
print "\n";
print "You can try this again, by executing the following on the command line:\n";
print " psql -U $CONFIG_DEFAULTS{'POSTGRES_USER'} -d $CONFIG_DEFAULTS{'POSTGRES_DATABASE'} -f $REFERENCE_DATA_SQL\n";
print "then re-start payara \n\n";
print "\n";
print "If it's still failing, please consult the installation manual and/or\n";
print "seek support from the Dataverse team.\n\n";

print "Press any key to continue... ";

unless ($noninteractive)
{
system "stty cbreak </dev/tty >/dev/tty 2>&1";
my $key = getc(STDIN);
system "stty -cbreak </dev/tty >/dev/tty 2>&1";
print "\n";
}
}
else
{
print "\nOK, done!\n";
}
}

sub read_config_defaults {
my $config_file = shift @_;

Expand Down
27 changes: 0 additions & 27 deletions scripts/installer/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,17 +245,6 @@
sys.exit("Sorry, I can't seem to find an appropriate warfile.\nAre you running the installer from the right directory?")
print(warfile+" available to deploy. Good.")

# 1b. check for reference_data.sql
referenceData = '../database/reference_data.sql'
if not os.path.isfile(referenceData):
# if it's not there, then we're probably running out of the
# unzipped installer bundle, so it should be right here in the current directory:
referenceData = 'reference_data.sql'
if not os.path.isfile(referenceData):
sys.exit("Can't find reference_data.sql!\nAre you running the installer from the right directory?")

print("found "+referenceData+"... good")

# 1c. check if jq is available
# (but we're only doing it if it's not that weird "pod name" mode)
if podName != "start-glassfish":
Expand Down Expand Up @@ -558,22 +547,6 @@
# @todo: restart/try to deploy again if it failed?
# @todo: if asadmin deploy says it was successful, verify that the application is running... if not - repeat the above?

# 6. Import reference data
print("importing reference data...")
# open the new postgresQL connection (as the application user):
conn_string="dbname='"+pgDb+"' user='"+pgUser+"' password='"+pgPassword+"' host='"+pgHost+"'"
conn = psycopg2.connect(conn_string)
conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)
cur = conn.cursor()
try:
cur.execute(open(referenceData, "r").read())
print("done.")
except:
print("WARNING: failed to import reference data!")

cur.close()
conn.close()

# 7. RUN SETUP SCRIPTS AND CONFIGURE EXTRA SETTINGS
# (note that we may need to change directories, depending on whether this is a dev., or release installer)
# 7a. run setup scripts
Expand Down

0 comments on commit 1a122d4

Please sign in to comment.