diff --git a/earth_enterprise/SConstruct b/earth_enterprise/SConstruct index 10a36eb3ac..bf2167dac5 100644 --- a/earth_enterprise/SConstruct +++ b/earth_enterprise/SConstruct @@ -87,6 +87,7 @@ installdirs = { 'server_lib': inst_server_dir('lib'), 'server_root': Dir('server/', installdir), 'server_share': inst_server_dir('share'), + 'server_sql': inst_server_dir('share/opengee-server/sql'), 'httpd': inst_server_dir('gehttpd'), 'httpdmodules': inst_server_dir('gehttpd/modules'), @@ -100,9 +101,6 @@ installdirs = { 'maps': inst_server_dir('gehttpd/htdocs/maps'), 'httpddocs': inst_server_dir('gehttpd/htdocs/shared_assets/docs'), - - 'getomcat_webapps': inst_server_dir('getomcat/webapps'), - 'getomcat_lib': inst_server_dir('getomcat/lib'), 'search_plugins': inst_server_dir('search/plugins'), 'search_tabs': inst_server_dir('search/tabs'), 'search_api': inst_server_dir('search/api'), diff --git a/earth_enterprise/Upgrade.md b/earth_enterprise/Upgrade.md new file mode 100644 index 0000000000..8290aa0e0b --- /dev/null +++ b/earth_enterprise/Upgrade.md @@ -0,0 +1,20 @@ +# Upgrading Earth Enterprise Fusion and Server to version 5.2.1 + +Upgrading to GEE 5.2.1 is supported from Earth Enterprise 5.2.0 version using the following steps: + +1. Do NOT uninstall GEE 5.2.0. We recommend that you upgrade GEE 5.2.0 by simply installing GEE 5.2.1. Installing GEE 5.2.1 on top of GEE 5.2.0 will ensure that your PostgreSQL databases are backed up and upgraded correctly to the new PostgreSQL version used by GEE 5.2.1. [Install Fusion or Earth Server](https://github.com/google/earthenterprise/wiki/Install-Fusion-or-Earth-Server). This can be achieved by running the scripts to install fusion and earth server: + +```bash +cd earth_enterprise/src/installer +sudo ./install_fusion.sh +sudo ./install_server.sh +``` + +Alternatively, instead of using scripts, on Redhat and Centos, you can upgrade GEE 5.2.0 to GEE 5.2.1 using [RPM packages](https://github.com/google/earthenterprise/blob/master/earth_enterprise/BUILD_RPMS.md) + +1. If you decide that you want to uninstall GEE 5.2.0 before installing GEE 5.2.1, first make sure to backup your PostgreSQL databases. Please keep in mind that the database backup, made by 5.2.0, would not be compatible with GEE 5.2.1 PostgreSQL databases. + + * Create a backup folder: `mkdir -p /tmp/MyBackupFolder` + * Make gepguser owner of the created folder: `chown gepguser /tmp/MyBackupFolder` + * Dump PostGreSQL databases using '/opt/google/bin/geresetpgdb' script. This script needs to be run under user 'gepguser'. + This can be achieved by switching to user 'gepguser' then executing: `/opt/google/bin/geresetpgdb backup /tmp/MyBackupFolder` diff --git a/earth_enterprise/geplaces/geplaces b/earth_enterprise/geplaces/geplaces index 209079af37..b845b59946 100755 --- a/earth_enterprise/geplaces/geplaces +++ b/earth_enterprise/geplaces/geplaces @@ -32,10 +32,8 @@ then exit 0 fi $BINDIR/createdb -U geuser --owner=geuser geplaces - $BINDIR/createlang -U geuser plpgsql geplaces - $BINDIR/psql -q -U geuser -d geplaces -f $SQLDIR/postgis.sql 2>/dev/null >/dev/null -# $BINDIR/psql -q -U geuser -d geplaces -f $SQLDIR/postgis_upgrade.sql 2>/dev/null >/dev/null - $BINDIR/psql -q -U geuser -d geplaces -f $SQLDIR/spatial_ref_sys.sql 2>/dev/null >/dev/null + $BINDIR/psql -U geuser -d geplaces -c "CREATE EXTENSION postgis" + zcat $SHAREDIR/geplaces/geplaces_db.gz | $BINDIR/psql -q -U geuser -d geplaces 2>/dev/null >/dev/null # Create new cities view diff --git a/earth_enterprise/geplaces/geplaces_db.gz b/earth_enterprise/geplaces/geplaces_db.gz index 9b3621b5c7..d301c4758c 100644 --- a/earth_enterprise/geplaces/geplaces_db.gz +++ b/earth_enterprise/geplaces/geplaces_db.gz @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7eea572471cbc81a7d65aa2a2dd7c6de53e54b78fa0d6842a9ca864879e48c3c -size 89882406 +oid sha256:6fc481b42b861e4773314e7f0f64ce40edd3107fa9774743f42b2626d577d823 +size 89881935 diff --git a/earth_enterprise/rpms/build.gradle b/earth_enterprise/rpms/build.gradle index b928ceb377..c032fe9b01 100644 --- a/earth_enterprise/rpms/build.gradle +++ b/earth_enterprise/rpms/build.gradle @@ -91,6 +91,8 @@ def stagedInstallDir_server_geplaces = new File(stagedInstallDir, 'geplaces/opt/google/share/geplaces') def stagedInstallDir_server_user_magic = new File(stagedInstallDir, 'server/user_magic') +def stagedInstallDir_server_version = + new File(stagedInstallDir, 'server/opt/google/gehttpd/htdocs/earth/gee_long_version.txt') def stagedInstallDir_fusion = new File(stagedInstallDir, 'fusion') def packageInstallRootDir = new File('/') @@ -139,7 +141,7 @@ task stageOpenGeeInstall(type: Exec, dependsOn: 'compileOpenGee') { task openGeePostGisRpm(type: GeeRpm) { packageName = 'opengee-postgis' release = "1.${rpmPlatformString}" - version = '1.5.8' + version = '2.3.4' user = 'root' permissionGroup = 'root' packageGroup = 'Application/Productivity' @@ -269,6 +271,8 @@ task openGeeCommonRpm(type: GeeRpm, dependsOn: openGeeSharedFiles) { requires('chkconfig') requires('shadow-utils') requires('sudo') + conflicts('opengee-postgis', '2.0', LESS ) + conflicts('opengee-postgis', '2.4', GREATER | EQUAL) requiresCommands(packageSharedCommands + ['cat', 'cut', 'getent', 'grep' ]) @@ -341,8 +345,9 @@ task openGeeServerRpm (type: GeeRpm, dependsOn: openGeeSharedFiles) { autoFindProvides = true autoFindRequires = true - requires('opengee-postgis', '1.5.8', GREATER | EQUAL) - conflicts('opengee-postgis', '2.0', GREATER | EQUAL) + requires('opengee-postgis', '2.3.4', GREATER | EQUAL) + conflicts('opengee-postgis', '2.0', LESS ) + conflicts('opengee-postgis', '2.4', GREATER | EQUAL) requires('opengee-common', openGeeVersion, GREATER | EQUAL) requiresPre('opengee-common', openGeeVersion, GREATER | EQUAL) @@ -358,6 +363,9 @@ task openGeeServerRpm (type: GeeRpm, dependsOn: openGeeSharedFiles) { // Prefix variable definitions to all install scripts: installUtils = file('build/shared/install-utils.sh') + // Add geresetpgdb script: + installUtils = file(new File(stagedInstallDir_server_opt, 'google/bin/gepgcommon')) + preInstall = file('opengee-server/pre-install.sh') postInstall = file('opengee-server/post-install.sh') preUninstall = file('opengee-server/pre-uninstall.sh') diff --git a/earth_enterprise/rpms/opengee-server/post-install.sh b/earth_enterprise/rpms/opengee-server/post-install.sh index aab42d7a95..12358177c3 100755 --- a/earth_enterprise/rpms/opengee-server/post-install.sh +++ b/earth_enterprise/rpms/opengee-server/post-install.sh @@ -21,6 +21,7 @@ umask 002 # Definitions PUBLISHER_ROOT="/gevol/published_dbs" INITSCRIPTUPDATE="/usr/sbin/update-rc.d" +PGSQL="/var/opt/google/pgsql" PGSQL_DATA="/var/opt/google/pgsql/data" PGSQL_LOGS="/var/opt/google/pgsql/logs" PGSQL_PROGRAM="/opt/google/bin/pg_ctl" @@ -170,7 +171,15 @@ fix_postinstall_filepermissions() reset_pgdb() { # a) Always do an upgrade of the psql db - echo 2 | run_as_user "$GEPGUSER" "/opt/google/bin/geresetpgdb upgrade" + DB_BACKUP="" + DB_BACKUP_LATEST="$(ls -td -- $PGSQL/data.backup_dump*/ | head -n 1)" + echo "Latest backup: $DB_BACKUP_LATEST" + if [ -d "$DB_BACKUP_LATEST" ]; then + DB_BACKUP="$DB_BACKUP_LATEST" + echo "Restoring data backup from: $DB_BACKUP" + fi + + echo 2 | run_as_user "$GEPGUSER" "/opt/google/bin/geresetpgdb upgrade $DB_BACKUP" echo -e "upgrade done" # b) Check for Success of PostGresDb diff --git a/earth_enterprise/rpms/opengee-server/pre-install.sh b/earth_enterprise/rpms/opengee-server/pre-install.sh index 9a21411267..166a51a9ac 100755 --- a/earth_enterprise/rpms/opengee-server/pre-install.sh +++ b/earth_enterprise/rpms/opengee-server/pre-install.sh @@ -35,7 +35,12 @@ main_preinstall() if [ "$NEW_INSTALL" = "true" ] ; then check_username "$GEAPACHEUSER" check_username "$GEPGUSER" + fi + + # Dump database if it exists + database_backup + } #----------------------------------------------------------------- @@ -54,6 +59,15 @@ check_username() # user already exists -- update primary group usermod -g "$GEGROUP" "$1" fi + +} + +database_backup() +{ + # If the GEE data directory exists and PostgreSQL is installed + if [ -d "$BASEINSTALLDIR_VAR/pgsql/data" ] && [ -f "$BASEINSTALLDIR_OPT/bin/psql" ]; then + do_dump + fi } #----------------------------------------------------------------- diff --git a/earth_enterprise/searchexample/searchexample b/earth_enterprise/searchexample/searchexample index c50618b187..0d261a28c9 100755 --- a/earth_enterprise/searchexample/searchexample +++ b/earth_enterprise/searchexample/searchexample @@ -32,10 +32,7 @@ then exit 0 fi $BINDIR/createdb -U geuser --owner=geuser searchexample - $BINDIR/createlang -U geuser plpgsql searchexample - $BINDIR/psql -q -U geuser -d searchexample -f $SQLDIR/postgis.sql 2>/dev/null >/dev/null -# $BINDIR/psql -q -U geuser -d searchexample -f $SQLDIR/postgis_upgrade.sql 2>/dev/null >/dev/null - $BINDIR/psql -q -U geuser -d searchexample -f $SQLDIR/spatial_ref_sys.sql 2>/dev/null >/dev/null + $BINDIR/psql -U geuser -d searchexample -c "CREATE EXTENSION postgis" zcat $SHAREDIR/searchexample/searchexample_db.gz | $BINDIR/psql -q -U geuser -d searchexample 2>/dev/null >/dev/null else if [ $1 == "delete" ] diff --git a/earth_enterprise/searchexample/searchexample_db.gz b/earth_enterprise/searchexample/searchexample_db.gz index 93c597ce97..e1df53f471 100755 --- a/earth_enterprise/searchexample/searchexample_db.gz +++ b/earth_enterprise/searchexample/searchexample_db.gz @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:42ca4c95e9ba861f3c804cc63f76578c692f076a21290f66a06e78a104c09663 -size 223752 +oid sha256:b0a693b22a11ec26b992fdbc044df30e3b74573490220aeb506643e83c0faed3 +size 223815 diff --git a/earth_enterprise/src/SConstruct b/earth_enterprise/src/SConstruct index 0ebb41dd5d..bea3cb43f6 100644 --- a/earth_enterprise/src/SConstruct +++ b/earth_enterprise/src/SConstruct @@ -357,6 +357,7 @@ installdirs = { 'server_root': Dir('server/', installdir), 'server_share': InstServerDir('share'), 'server_search': InstServerDir('search'), + 'server_sql': InstServerDir('share/opengee-server/sql'), 'httpd': InstServerDir('gehttpd'), 'httpdmodules': InstServerDir('gehttpd/modules'), diff --git a/earth_enterprise/src/installer/install_server.sh b/earth_enterprise/src/installer/install_server.sh index 6facc7e47f..52f155e464 100755 --- a/earth_enterprise/src/installer/install_server.sh +++ b/earth_enterprise/src/installer/install_server.sh @@ -28,6 +28,7 @@ SCRIPTDIR=`dirname $0` PUBLISHER_ROOT="/gevol/published_dbs" INSTALL_LOG="$INSTALL_LOG_DIR/geserver_install_$(date +%Y_%m_%d.%H%M%S).log" BACKUP_DIR="$BASEINSTALLDIR_VAR/server-backups/$(date +%Y_%m_%d.%H%M%S)" +BACKUP_DATA_DIR=$BACKUP_DIR/data.backup # script arguments BACKUPSERVER=true @@ -93,11 +94,16 @@ main_preinstall() fi # 5b) Perform backup - if [ $BACKUPSERVER == true ]; then + if [ "$BACKUPSERVER" = true ]; then # Backing up current Server Install... backup_server fi + # Backup PGSQL data + if [ -d "$PGSQL_DATA" ]; then + backup_pgsql_data + fi + # 6) Check valid host properties if ! check_bad_hostname; then exit 1 @@ -109,15 +115,15 @@ main_preinstall() # 64 bit check if [[ "$(uname -i)" != "x86_64" ]]; then - echo -e "\n$GEEF $LONG_VERSION can only be installed on a 64 bit operating system." + echo -e "\n$GEES $LONG_VERSION can only be installed on a 64 bit operating system." exit 1 fi # 8) Check if group and users exist check_group - check_username $GEAPACHEUSER_NAME - check_username $GEPGUSER_NAME + check_username "$GEAPACHEUSER_NAME" + check_username "$GEPGUSER_NAME" # 10) Configure Publish Root configure_publish_root @@ -161,10 +167,10 @@ main_postinstall() # 5) Add the server to services # For RedHat and SuSE - test -f $CHKCONFIG && $CHKCONFIG --add geserver + test -f "$CHKCONFIG" && "$CHKCONFIG" --add geserver # 6) Register publish root - $BASEINSTALLDIR_OPT/bin/geconfigurepublishroot --noprompt --path=$PUBLISHER_ROOT + "$BASEINSTALLDIR_OPT/bin/geconfigurepublishroot" --noprompt --path="$PUBLISHER_ROOT" # 7) Install the GEPlaces and SearchExample Databases install_search_databases @@ -176,7 +182,7 @@ main_postinstall() # 9) Run geecheck config script # If file ‘/opt/google/gehttpd/cgi-bin/set_geecheck_config.py’ exists: if [ -f "$GEE_CHECK_CONFIG_SCRIPT" ]; then - cd $BASEINSTALLDIR_OPT/gehttpd/cgi-bin + cd "$BASEINSTALLDIR_OPT/gehttpd/cgi-bin" python ./set_geecheck_config.py fi @@ -236,7 +242,7 @@ parse_arguments() if [ -d "$1" ]; then TMPINSTALLDIR="$1" else - show_no_tmp_dir_message $1 + show_no_tmp_dir_message "$1" parse_arguments_retval=-1 break fi @@ -268,11 +274,24 @@ configure_publish_root() { # Update PUBLISHER_ROOT if geserver already installed local STREAM_SPACE="$GEHTTPD_CONF/stream_space" - if [ -e $STREAM_SPACE ]; then - PUBLISHER_ROOT=`cat $STREAM_SPACE |cut -d" " -f3 |sed 's/.\{13\}$//'` + if [ -e "$STREAM_SPACE" ]; then + PUBLISHER_ROOT=`cat $STREAM_SPACE | cut -d" " -f3 | sed 's/.\{13\}$//'` fi } +backup_pgsql_data() +{ + # Make the temporary data backup directory + mkdir -p "$BACKUP_DATA_DIR" + chown "$GEPGUSER_NAME" "$BACKUP_DATA_DIR" + + # Dump PGSQL data + RESET_DB_SCRIPT=$TMPINSTALLDIR/server/opt/google/bin/geresetpgdb + + echo 2 | run_as_user "$GEPGUSER_NAME" \ + "$(printf '%q' "$RESET_DB_SCRIPT") backup $(printf '%q' "$BACKUP_DATA_DIR")" +} + #----------------------------------------------------------------- # Install Functions #----------------------------------------------------------------- @@ -280,100 +299,100 @@ copy_files_to_target() { printf "\nCopying files from source to target directories..." - mkdir -p $BASEINSTALLDIR_OPT/share/doc - mkdir -p $BASEINSTALLDIR_OPT/gehttpd/conf - mkdir -p $BASEINSTALLDIR_OPT/gehttpd/htdocs/shared_assets/images - mkdir -p $BASEINSTALLDIR_OPT/search - mkdir -p $BASEINSTALLDIR_VAR/openssl/private - mkdir -p $BASEINSTALLDIR_VAR/openssl/misc - mkdir -p $BASEINSTALLDIR_VAR/openssl/certs - mkdir -p $BASEINSTALLDIR_ETC/openldap - mkdir -p $BASEINSTALLDIR_VAR/pgsql + mkdir -p "$BASEINSTALLDIR_OPT/share/doc" + mkdir -p "$BASEINSTALLDIR_OPT/gehttpd/conf" + mkdir -p "$BASEINSTALLDIR_OPT/gehttpd/htdocs/shared_assets/images" + mkdir -p "$BASEINSTALLDIR_OPT/search" + mkdir -p "$BASEINSTALLDIR_VAR/openssl/private" + mkdir -p "$BASEINSTALLDIR_VAR/openssl/misc" + mkdir -p "$BASEINSTALLDIR_VAR/openssl/certs" + mkdir -p "$BASEINSTALLDIR_ETC/openldap" + mkdir -p "$BASEINSTALLDIR_VAR/pgsql" local error_on_copy=0 - cp -rf $TMPINSTALLDIR/common/opt/google/bin $BASEINSTALLDIR_OPT + cp -rf "$TMPINSTALLDIR/common/opt/google/bin" "$BASEINSTALLDIR_OPT" if [ $? -ne 0 ]; then error_on_copy=1; fi - cp -rf $TMPINSTALLDIR/common/opt/google/share $BASEINSTALLDIR_OPT + cp -rf "$TMPINSTALLDIR/common/opt/google/share" "$BASEINSTALLDIR_OPT" if [ $? -ne 0 ]; then error_on_copy=1; fi - cp -rf $TMPINSTALLDIR/common/opt/google/qt $BASEINSTALLDIR_OPT + cp -rf "$TMPINSTALLDIR/common/opt/google/qt" "$BASEINSTALLDIR_OPT" if [ $? -ne 0 ]; then error_on_copy=1; fi - cp -rf $TMPINSTALLDIR/common/opt/google/qt/lib $BASEINSTALLDIR_OPT + cp -rf "$TMPINSTALLDIR/common/opt/google/qt/lib" "$BASEINSTALLDIR_OPT" if [ $? -ne 0 ]; then error_on_copy=1; fi - cp -rf $TMPINSTALLDIR/common/opt/google/lib $BASEINSTALLDIR_OPT + cp -rf "$TMPINSTALLDIR/common/opt/google/lib" "$BASEINSTALLDIR_OPT" if [ $? -ne 0 ]; then error_on_copy=1; fi - cp -rf $TMPINSTALLDIR/common/opt/google/gepython $BASEINSTALLDIR_OPT + cp -rf "$TMPINSTALLDIR/common/opt/google/gepython" "$BASEINSTALLDIR_OPT" if [ $? -ne 0 ]; then error_on_copy=1; fi - cp -rf $TMPINSTALLDIR/server/opt/google/share $BASEINSTALLDIR_OPT + cp -rf "$TMPINSTALLDIR/server/opt/google/share" "$BASEINSTALLDIR_OPT" if [ $? -ne 0 ]; then error_on_copy=1; fi - cp -rf $TMPINSTALLDIR/server/opt/google/bin $BASEINSTALLDIR_OPT + cp -rf "$TMPINSTALLDIR/server/opt/google/bin" "$BASEINSTALLDIR_OPT" if [ $? -ne 0 ]; then error_on_copy=1; fi - cp -rf $TMPINSTALLDIR/server/opt/google/lib $BASEINSTALLDIR_OPT + cp -rf "$TMPINSTALLDIR/server/opt/google/lib" "$BASEINSTALLDIR_OPT" if [ $? -ne 0 ]; then error_on_copy=1; fi - cp -rf $TMPINSTALLDIR/server/opt/google/gehttpd $BASEINSTALLDIR_OPT + cp -rf "$TMPINSTALLDIR/server/opt/google/gehttpd" "$BASEINSTALLDIR_OPT" if [ $? -ne 0 ]; then error_on_copy=1; fi - cp -rf $TMPINSTALLDIR/server/opt/google/search $BASEINSTALLDIR_OPT + cp -rf "$TMPINSTALLDIR/server/opt/google/search" "$BASEINSTALLDIR_OPT" if [ $? -ne 0 ]; then error_on_copy=1; fi - cp -rf $TMPINSTALLDIR/searchexample/opt/google/share $BASEINSTALLDIR_OPT + cp -rf "$TMPINSTALLDIR/searchexample/opt/google/share" "$BASEINSTALLDIR_OPT" if [ $? -ne 0 ]; then error_on_copy=1; fi - cp -rf $TMPINSTALLDIR/geplaces/opt/google/share $BASEINSTALLDIR_OPT + cp -rf "$TMPINSTALLDIR/geplaces/opt/google/share" "$BASEINSTALLDIR_OPT" if [ $? -ne 0 ]; then error_on_copy=1; fi - cp -rf $TMPINSTALLDIR/server/AppacheSupport/opt/google/gehttpd $BASEINSTALLDIR_OPT + cp -rf "$TMPINSTALLDIR/server/AppacheSupport/opt/google/gehttpd" "$BASEINSTALLDIR_OPT" if [ $? -ne 0 ]; then error_on_copy=1; fi - cp -rf $TMPINSTALLDIR/server/etc/init.d/geserver $BININSTALLROOTDIR + cp -rf "$TMPINSTALLDIR/server/etc/init.d/geserver" "$BININSTALLROOTDIR" if [ $? -ne 0 ]; then error_on_copy=1; fi - cp -rf $TMPINSTALLDIR/server/etc/profile.d/ge-server.sh $BININSTALLPROFILEDIR + cp -rf "$TMPINSTALLDIR/server/etc/profile.d/ge-server.sh" "$BININSTALLPROFILEDIR" if [ $? -ne 0 ]; then error_on_copy=1; fi - cp -rf $TMPINSTALLDIR/server/etc/profile.d/ge-server.csh $BININSTALLPROFILEDIR + cp -rf "$TMPINSTALLDIR/server/etc/profile.d/ge-server.csh" "$BININSTALLPROFILEDIR" if [ $? -ne 0 ]; then error_on_copy=1; fi - cp -rf $TMPINSTALLDIR/server/user_magic/etc/logrotate.d/gehttpd $BASEINSTALLLOGROTATEDIR + cp -rf "$TMPINSTALLDIR/server/user_magic/etc/logrotate.d/gehttpd" "$BASEINSTALLLOGROTATEDIR" if [ $? -ne 0 ]; then error_on_copy=1; fi - cp -rf $TMPINSTALLDIR/server/user_magic/var/opt/google/pgsql/logs/ $BASEINSTALLDIR_VAR/pgsql + cp -rf "$TMPINSTALLDIR/server/user_magic/var/opt/google/pgsql/logs/" "$BASEINSTALLDIR_VAR/pgsql" if [ $? -ne 0 ]; then error_on_copy=1; fi - cp -rf $TMPINSTALLDIR/manual/opt/google/share/doc/manual $BASEINSTALLDIR_OPT/share/doc + cp -rf "$TMPINSTALLDIR/manual/opt/google/share/doc/manual" "$BASEINSTALLDIR_OPT/share/doc" if [ $? -ne 0 ]; then error_on_copy=1; fi - cp -rf $TMPINSTALLDIR/server/opt/google/gehttpd/conf/gehttpd.conf $BASEINSTALLDIR_OPT/gehttpd/conf + cp -rf "$TMPINSTALLDIR/server/opt/google/gehttpd/conf/gehttpd.conf" "$BASEINSTALLDIR_OPT/gehttpd/conf" if [ $? -ne 0 ]; then error_on_copy=1; fi - cp -rf $TMPINSTALLDIR/server/opt/google/gehttpd/htdocs/shared_assets/images/location_pin.png $BASEINSTALLDIR_OPT/gehttpd/htdocs/shared_assets/images + cp -rf "$TMPINSTALLDIR/server/opt/google/gehttpd/htdocs/shared_assets/images/location_pin.png" "$BASEINSTALLDIR_OPT/gehttpd/htdocs/shared_assets/images" if [ $? -ne 0 ]; then error_on_copy=1; fi TMPOPENSSLPATH=$TMPINSTALLDIR/common/user_magic/var/opt/google/openssl - cp -f $TMPOPENSSLPATH/openssl.cnf $BASEINSTALLDIR_VAR/openssl + cp -f "$TMPOPENSSLPATH/openssl.cnf" "$BASEINSTALLDIR_VAR/openssl" if [ $? -ne 0 ]; then error_on_copy=1; fi - cp -rf $TMPOPENSSLPATH/private $BASEINSTALLDIR_VAR/openssl + cp -rf "$TMPOPENSSLPATH/private" "$BASEINSTALLDIR_VAR/openssl" if [ $? -ne 0 ]; then error_on_copy=1; fi - cp -f $TMPOPENSSLPATH/misc/CA.sh $BASEINSTALLDIR_VAR/openssl/misc + cp -f "$TMPOPENSSLPATH/misc/CA.sh" "$BASEINSTALLDIR_VAR/openssl/misc" if [ $? -ne 0 ]; then error_on_copy=1; fi - cp -f $TMPOPENSSLPATH/misc/tsget $BASEINSTALLDIR_VAR/openssl/misc + cp -f "$TMPOPENSSLPATH/misc/tsget" "$BASEINSTALLDIR_VAR/openssl/misc" if [ $? -ne 0 ]; then error_on_copy=1; fi - cp -f $TMPOPENSSLPATH/misc/c_name $BASEINSTALLDIR_VAR/openssl/misc + cp -f "$TMPOPENSSLPATH/misc/c_name" "$BASEINSTALLDIR_VAR/openssl/misc" if [ $? -ne 0 ]; then error_on_copy=1; fi - cp -f $TMPOPENSSLPATH/misc/CA.pl $BASEINSTALLDIR_VAR/openssl/misc + cp -f "$TMPOPENSSLPATH/misc/CA.pl" "$BASEINSTALLDIR_VAR/openssl/misc" if [ $? -ne 0 ]; then error_on_copy=1; fi - cp -f $TMPOPENSSLPATH/misc/c_issuer $BASEINSTALLDIR_VAR/openssl/misc + cp -f "$TMPOPENSSLPATH/misc/c_issuer" "$BASEINSTALLDIR_VAR/openssl/misc" if [ $? -ne 0 ]; then error_on_copy=1; fi - cp -f $TMPOPENSSLPATH/misc/c_info $BASEINSTALLDIR_VAR/openssl/misc + cp -f "$TMPOPENSSLPATH/misc/c_info" "$BASEINSTALLDIR_VAR/openssl/misc" if [ $? -ne 0 ]; then error_on_copy=1; fi - cp -f $TMPOPENSSLPATH/misc/c_hash $BASEINSTALLDIR_VAR/openssl/misc + cp -f "$TMPOPENSSLPATH/misc/c_hash" "$BASEINSTALLDIR_VAR/openssl/misc" if [ $? -ne 0 ]; then error_on_copy=1; fi - cp -rf $TMPOPENSSLPATH/certs $BASEINSTALLDIR_VAR/openssl + cp -rf "$TMPOPENSSLPATH/certs" "$BASEINSTALLDIR_VAR/openssl" if [ $? -ne 0 ]; then error_on_copy=1; fi TMPOPENLDAPPATH=$TMPINSTALLDIR/common/user_magic/etc/opt/google/openldap - cp -f $TMPOPENLDAPPATH/ldap.conf $BASEINSTALLDIR_ETC/openldap + cp -f "$TMPOPENLDAPPATH/ldap.conf" "$BASEINSTALLDIR_ETC/openldap" if [ $? -ne 0 ]; then error_on_copy=1; fi - cp -f $TMPOPENLDAPPATH/ldap.conf.default $BASEINSTALLDIR_ETC/openldap + cp -f "$TMPOPENLDAPPATH/ldap.conf.default" "$BASEINSTALLDIR_ETC/openldap" if [ $? -ne 0 ]; then error_on_copy=1; fi # TODO: final step: copy uninstall script # cp -f $TMPOPENLDAPPATH/<........> $INSTALL_LOG_DIR - if [ $error_on_copy -ne 0 ] + if [ "$error_on_copy" -ne 0 ] then - show_corrupt_tmp_dir_message $TMPINSTALLDIR $INSTALL_LOG + show_corrupt_tmp_dir_message "$TMPINSTALLDIR" "$INSTALL_LOG" exit 1 fi @@ -388,7 +407,7 @@ postgres_db_config() { # a) PostGres folders and configuration chmod -R 700 /var/opt/google/pgsql/ - chown -R $GEPGUSER_NAME:$GRPNAME /var/opt/google/pgsql/ + chown -R "$GEPGUSER_NAME:$GRPNAME" /var/opt/google/pgsql/ reset_pgdb } @@ -396,14 +415,14 @@ reset_pgdb() { # TODO check if correct # a) Always do an upgrade of the psql db - echo 2 | run_as_user $GEPGUSER_NAME "/opt/google/bin/geresetpgdb upgrade" + echo 2 | run_as_user "$GEPGUSER_NAME" "/opt/google/bin/geresetpgdb upgrade $(printf '%q' "$BACKUP_DATA_DIR")" echo -e "upgrade done" # b) Check for Success of PostGresDb # If file ‘/var/opt/google/pgsql/data’ doesn’t exist: - echo "pgsql_data" - echo $PGSQL_DATA + echo "pgsql_data" + echo "$PGSQL_DATA" if [ -d "$PGSQL_DATA" ]; then # PostgreSQL install Success. echo -e "The PostgreSQL component is successfully installed." @@ -421,9 +440,9 @@ setup_geserver_daemon() # setup geserver daemon # For Ubuntu printf "Setting up the geserver daemon...\n" - test -f $CHKCONFIG && $CHKCONFIG --add geserver - test -f $INITSCRIPTUPDATE && $INITSCRIPTUPDATE -f geserver remove - test -f $INITSCRIPTUPDATE && $INITSCRIPTUPDATE geserver start 90 2 3 4 5 . stop 10 0 1 6 . + test -f "$CHKCONFIG" && "$CHKCONFIG" --add geserver + test -f "$INITSCRIPTUPDATE" && "$INITSCRIPTUPDATE" -f geserver remove + test -f "$INITSCRIPTUPDATE" && "$INITSCRIPTUPDATE" geserver start 90 2 3 4 5 . stop 10 0 1 6 . printf "GEE Server daemon setup ... DONE\n" } @@ -432,19 +451,19 @@ install_search_databases() { # a) Start the PSQL Server echo "# a) Start the PSQL Server " - run_as_user $GEPGUSER_NAME "$PGSQL_PROGRAM -D $PGSQL_DATA -l $PGSQL_LOGS/pg.log start -w" + run_as_user "$GEPGUSER_NAME" "$(printf '%q' "$PGSQL_PROGRAM") -D $(printf '%q' "$PGSQL_DATA") -l $(printf '%q' "$PGSQL_LOGS/pg.log") start -w" echo "# b) Install GEPlaces Database" # b) Install GEPlaces Database - run_as_user $GEPGUSER_NAME "/opt/google/share/geplaces/geplaces create" + run_as_user "$GEPGUSER_NAME" "/opt/google/share/geplaces/geplaces create" echo "# c) Install SearchExample Database " # c) Install SearchExample Database - run_as_user $GEPGUSER_NAME "/opt/google/share/searchexample/searchexample create" + run_as_user "$GEPGUSER_NAME" "/opt/google/share/searchexample/searchexample create" # d) Stop the PSQL Server echo "# d) Stop the PSQL Server" - run_as_user $GEPGUSER_NAME "$PGSQL_PROGRAM -D $PGSQL_DATA stop" + run_as_user "$GEPGUSER_NAME" "$PGSQL_PROGRAM -D $PGSQL_DATA stop" } modify_files() @@ -454,8 +473,8 @@ modify_files() # if there are non-OSS installs in the system, it might help cleanup those. # a) Search and replace the below variables in /etc/init.d/geserver. - sed -i "s/IA_GEAPACHE_USER/$GEAPACHEUSER_NAME/" $BININSTALLROOTDIR/geserver - sed -i "s/IA_GEPGUSER/$GEPGUSER_NAME/" $BININSTALLROOTDIR/geserver + sed -i "s/IA_GEAPACHE_USER/$GEAPACHEUSER_NAME/" "$BININSTALLROOTDIR/geserver" + sed -i "s/IA_GEPGUSER/$GEPGUSER_NAME/" "$BININSTALLROOTDIR/geserver" # b) Search and replace the file ‘/opt/google/gehttpd/conf/gehttpd.conf’ sed -i "s/IA_GEAPACHE_USER/$GEAPACHEUSER_NAME/" /opt/google/gehttpd/conf/gehttpd.conf @@ -464,7 +483,7 @@ modify_files() # c) Create a new file ‘/etc/opt/google/fusion_server_version’ and # add the below text to it. - echo $LONG_VERSION > /etc/opt/google/fusion_server_version + echo "$LONG_VERSION" > /etc/opt/google/fusion_server_version # d) Create a new file ‘/etc/init.d/gevars.sh’ and prepend the below lines. echo -e "GEAPACHEUSER=$GEAPACHEUSER_NAME\nGEPGUSER=$GEPGUSER_NAME\nGEFUSIONUSER=$GEFUSIONUSER_NAME\nGEGROUP=$GRPNAME" > $BININSTALLROOTDIR/gevars.sh @@ -473,48 +492,48 @@ modify_files() fix_postinstall_filepermissions() { # PostGres - chown -R $GEPGUSER_NAME:$GRPNAME $BASEINSTALLDIR_VAR/pgsql/ + chown -R "$GEPGUSER_NAME:$GRPNAME" "$BASEINSTALLDIR_VAR/pgsql/" # Apache - mkdir -p $BASEINSTALLDIR_OPT/gehttpd/conf.d/virtual_servers/runtime - chmod -R 755 $BASEINSTALLDIR_OPT/gehttpd - chmod -R 775 $BASEINSTALLDIR_OPT/gehttpd/conf.d/virtual_servers/runtime/ - chown -R $GEAPACHEUSER_NAME:$GRPNAME $BASEINSTALLDIR_OPT/gehttpd/conf.d/virtual_servers/ - chown -R $GEAPACHEUSER_NAME:$GRPNAME $BASEINSTALLDIR_OPT/gehttpd/htdocs/cutter/ - chmod -R 700 $BASEINSTALLDIR_OPT/gehttpd/htdocs/cutter/globes/ - chown $GEAPACHEUSER_NAME:$GRPNAME $BASEINSTALLDIR_OPT/gehttpd/htdocs/.htaccess - chown -R $GEAPACHEUSER_NAME:$GRPNAME $BASEINSTALLDIR_OPT/gehttpd/logs + mkdir -p "$BASEINSTALLDIR_OPT/gehttpd/conf.d/virtual_servers/runtime" + chmod -R 755 "$BASEINSTALLDIR_OPT/gehttpd" + chmod -R 775 "$BASEINSTALLDIR_OPT/gehttpd/conf.d/virtual_servers/runtime/" + chown -R "$GEAPACHEUSER_NAME:$GRPNAME" "$BASEINSTALLDIR_OPT/gehttpd/conf.d/virtual_servers/" + chown -R "$GEAPACHEUSER_NAME:$GRPNAME" "$BASEINSTALLDIR_OPT/gehttpd/htdocs/cutter/" + chmod -R 700 "$BASEINSTALLDIR_OPT/gehttpd/htdocs/cutter/globes/" + chown "$GEAPACHEUSER_NAME:$GRPNAME" "$BASEINSTALLDIR_OPT/gehttpd/htdocs/.htaccess" + chown -R "$GEAPACHEUSER_NAME:$GRPNAME" "$BASEINSTALLDIR_OPT/gehttpd/logs" # Publish Root - chmod 775 $PUBLISHER_ROOT/stream_space + chmod 775 "$PUBLISHER_ROOT/stream_space" # TODO - Not Found # chmod 644 $PUBLISHER_ROOT/stream_space/.config - chmod 644 $PUBLISHER_ROOT/.config - chmod 755 $PUBLISHER_ROOT - chown -R $GEAPACHEUSER_NAME:$GRPNAME $PUBLISHER_ROOT/stream_space - chown -R $GEAPACHEUSER_NAME:$GRPNAME $PUBLISHER_ROOT/search_space + chmod 644 "$PUBLISHER_ROOT/.config" + chmod 755 "$PUBLISHER_ROOT" + chown -R "$GEAPACHEUSER_NAME:$GRPNAME" "$PUBLISHER_ROOT/stream_space" + chown -R "$GEAPACHEUSER_NAME:$GRPNAME" "$PUBLISHER_ROOT/search_space" # Etc chmod 755 /etc/opt/google/ - chmod 755 $BASEINSTALLDIR_OPT/etc/ - chmod 755 $BININSTALLROOTDIR/gevars.sh - chmod 755 $BININSTALLROOTDIR/geserver + chmod 755 "$BASEINSTALLDIR_OPT/etc/" + chmod 755 "$BININSTALLROOTDIR/gevars.sh" + chmod 755 "$BININSTALLROOTDIR/geserver" # Run - chmod 775 $BASEINSTALLDIR_OPT/run/ - chmod 775 $BASEINSTALLDIR_VAR/run/ - chown root:$GRPNAME $BASEINSTALLDIR_OPT/run/ - chown root:$GRPNAME $BASEINSTALLDIR_VAR/run/ + chmod 775 "$BASEINSTALLDIR_OPT/run/" + chmod 775 "$BASEINSTALLDIR_VAR/run/" + chown "root:$GRPNAME" "$BASEINSTALLDIR_OPT/run/" + chown "root:$GRPNAME" "$BASEINSTALLDIR_VAR/run/" # Logs - chmod 775 $BASEINSTALLDIR_VAR/log/ - chmod 775 $BASEINSTALLDIR_OPT/log/ - chown root:$GRPNAME $BASEINSTALLDIR_VAR/log - chown root:$GRPNAME $BASEINSTALLDIR_OPT/log + chmod 775 "$BASEINSTALLDIR_VAR/log/" + chmod 775 "$BASEINSTALLDIR_OPT/log/" + chown "root:$GRPNAME" "$BASEINSTALLDIR_VAR/log" + chown "root:$GRPNAME" "$BASEINSTALLDIR_OPT/log" # Other folders - chmod 755 $BASEINSTALLDIR_OPT - chmod 755 $BASEINSTALLDIR_VAR + chmod 755 "$BASEINSTALLDIR_OPT" + chmod 755 "$BASEINSTALLDIR_VAR" chmod -R 755 /opt/google/lib/ chmod -R 555 /opt/google/bin/ chmod 755 /opt/google/bin @@ -534,7 +553,7 @@ fix_postinstall_filepermissions() chmod ugo+x /opt/google/share/support/geecheck/find_terrain_pixel.pl chmod ugo+x /opt/google/share/support/geecheck/pg_check.pl # Note: this is installed in install_fusion.sh, but needs setting here too. - chmod ugo+x $BASEINSTALLDIR_OPT/share/tutorials/fusion/download_tutorial.sh + chmod ugo+x "$BASEINSTALLDIR_OPT/share/tutorials/fusion/download_tutorial.sh" chown -R root:root /opt/google/share #TODO @@ -547,7 +566,7 @@ fix_postinstall_filepermissions() /opt/google/bin/geserveradmin --disable_cutter # Restrict permissions to uninstaller and installer logs - chmod -R go-rwx $INSTALL_LOG_DIR + chmod -R go-rwx "$INSTALL_LOG_DIR" } show_final_success_message(){ @@ -563,9 +582,9 @@ show_final_success_message(){ while true; do echo -e "Do you want to start the $GEES Service(y/n)?" read PROMPT_FOR_START - case $PROMPT_FOR_START in + case "$PROMPT_FOR_START" in [Yy]* ) - $BININSTALLROOTDIR/geserver start + "$BININSTALLROOTDIR/geserver" start check_server_running; break;; [Nn]* ) echo -e "Congratulations! $PRODUCT_NAME has been successfully $INSTALLED_OR_UPGRADED in the following directory: @@ -602,8 +621,8 @@ check_server_running() #----------------------------------------------------------------- # Pre-Install Main #----------------------------------------------------------------- -mkdir -p $INSTALL_LOG_DIR -exec 2> $INSTALL_LOG +mkdir -p "$INSTALL_LOG_DIR" +exec 2> "$INSTALL_LOG" main_preinstall "$@" diff --git a/earth_enterprise/src/installer/lib/Users.pm b/earth_enterprise/src/installer/lib/Users.pm deleted file mode 100644 index 6211c16c5f..0000000000 --- a/earth_enterprise/src/installer/lib/Users.pm +++ /dev/null @@ -1,155 +0,0 @@ -# -# Copyright 2017 Google Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -package Users; - -use strict; -use warnings; - -our $FusionUser = ['gefusionuser', 'gegroup']; -our $ApacheUser = ['geapacheuser', 'gegroup']; -our $TomcatUser = ['getomcatuser', 'gegroup']; -our $PostgresUser = ['gepguser', 'gegroup']; -our $PrefsFile = "/tmp/fusion.prefs"; - -sub BEGIN { - our $PrefsFile = "/tmp/fusion.prefs"; - if (-e $Users::PrefsFile) { - my $fh; - open($fh, "<$Users::PrefsFile") or die "Problem opening $PrefsFile - are you running as root?"; - my $userprefs_tab = {}; - while (my $line = <$fh>) { - chomp $line; - my ($varname, $user, $group) = split(":", $line); - $Users::userprefs_tab{$varname} = [$user, $group]; - } - if (exists($Users::userprefs_tab{"FusionUser"})) { - $FusionUser = $Users::userprefs_tab{"FusionUser"}; - } - if (exists($Users::userprefs_tab{"ApacheUser"})) { - $ApacheUser = $Users::userprefs_tab{"ApacheUser"}; - } - if (exists($Users::userprefs_tab{"TomcatUser"})) { - $TomcatUser = $Users::userprefs_tab{"TomcatUser"}; - } - if (exists($Users::userprefs_tab{"PostgresUser"})) { - $PostgresUser = $Users::userprefs_tab{"PostgresUser"}; - } - } -} - -sub SaveUserPrefs { - my $fh; - open($fh, ">$Users::PrefsFile") or die "Problem writing $Users::PrefsFile - are you running as root?"; - printf $fh ("FusionUser:" . join(":", @$FusionUser) . "\n"); - printf $fh ("ApacheUser:" . join(":", @$ApacheUser) . "\n"); - printf $fh ("TomcatUser:" . join(":", @$TomcatUser) . "\n"); - printf $fh ("PostgresUser:" . join(":", @$PostgresUser) . "\n"); -} - -sub GetUserAndGroupId { - my $user = shift; - my ($name,$passwd,$uid,$gid, - $quota,$comment,$gcos,$dir,$shell,$expire) = getpwnam($user); - if (defined $uid) { - return ($uid,$gid); - } else { - return (); - } -} - -sub GetGroupId { - my $group = shift; - return scalar(getgrnam($group)); -} - -sub GetGroupName { - my $gid = shift; - return getgrgid($gid); -} - -sub GroupExists -{ - my $group = shift; - return defined(GetGroupId($group)); -} - -sub CreateGroup { - my ($groupname, $gid) = @_; - - my $extra = ''; - if (defined $gid) { - $extra .= " -g $gid"; - } - - system("/usr/sbin/groupadd $extra $groupname"); - - # sometimes the create succeeds, but the check immediately after fails. - # just wait a little bit - sleep(2); - - return GroupExists($groupname); -} - -sub CreateUser { - my ($username, $groupname, $uid) = @_; - - my $extra = ''; - if (defined $uid) { - $extra .= " -u $uid"; - } - if (-f '/etc/redhat-release') { - $extra .= " -n"; - } - my $gid = GetGroupId($groupname); - if (!defined($gid)) { - warn "No such group: $groupname\n"; - return 0; - } - - system("/usr/sbin/useradd $extra -d / -s /bin/false -g $gid $username"); - - # sometimes the create succeeds, but the check immediately after fails. - # just wait a little bit - sleep(2); - - my ($newuid, $newgid) = GetUserAndGroupId($username); - return (defined($newuid) && - defined($newgid) && - ($newgid == $gid)); -} - -sub FixUserGroup { - my ($username, $groupname) = @_; - - my $extra = ''; - my $gid = GetGroupId($groupname); - if (!defined($gid)) { - warn "No such group: $groupname\n"; - return 0; - } - - system("/usr/sbin/usermod $extra -g $gid $username"); - - # sometimes the create succeeds, but the check immediately after fails. - # just wait a little bit - sleep(2); - - my ($newuid, $newgid) = GetUserAndGroupId($username); - return (defined($newuid) && - defined($newgid) && - ($newgid == $gid)); -} diff --git a/earth_enterprise/src/installer/products/server/GEServerBase.pm b/earth_enterprise/src/installer/products/server/GEServerBase.pm deleted file mode 100644 index c288896541..0000000000 --- a/earth_enterprise/src/installer/products/server/GEServerBase.pm +++ /dev/null @@ -1,358 +0,0 @@ -# -# Copyright 2017 Google Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -#-*-perl-*- - -package GEServerBase; - -use strict; -use Product; -use Users; -use RPMHelps; -use InstallUtils; -use TermHelps; -use prompt; - -our( @ISA ); -@ISA = ("Product"); - -our $ServerRPM = "GoogleEarthServer"; -our $ApachePidFile = '/opt/google/gehttpd/logs/httpd.pid'; -our $TomcatPidFile = '/var/opt/google/run/getomcat.pid'; -our $PostgresPidFile = '/var/opt/google/pgsql/data/postmaster.pid'; -our $TomcatEnvFile = '/opt/google/getomcat/bin/setenv.sh'; -our $ApacheEnvFile = '/opt/google/gehttpd/bin/envvars'; -our $RequiredJavaVersion = '1.6'; - - - -sub new { - my ($class, $prettyname) = @_; - my $self = $class->SUPER::new(); - $self->{prettyname} = $prettyname; - $self->{opensslver} = '0.9.8'; - $self->{openssltoonewver} = '0.9.9'; - return $self; -} - -sub StartStopCommand { - return '/etc/init.d/geserver'; -} - -sub SortPrimaryKey { - return 20; -} - -sub RequiredUsers { - return ($Users::ApacheUser, - $Users::TomcatUser, - $Users::PostgresUser); -} - -sub SetUsers { - my $group = "gegroup"; - $group = prompt::GetString("Group name for all servers", $group); - my $apacheuser = "geapacheuser"; - $apacheuser = prompt::GetString("Apache User", $apacheuser); - my $tomcatuser = "getomcatuser"; - $tomcatuser = prompt::GetString("Tomcat User", $tomcatuser); - my $pguser = "gepguser"; - $pguser = prompt::GetString("Postgres User", $pguser); - $Users::ApacheUser = [$apacheuser, $group]; - $Users::TomcatUser = [$tomcatuser, $group]; - $Users::PostgresUser = [$pguser, $group]; -} - -sub PrimaryRPM { - my $self = shift; - return $ServerRPM; -} - -sub IsRunning { - return - InstallUtils::ActivePidFile($ApachePidFile) || - InstallUtils::ActivePidFile($TomcatPidFile) || - InstallUtils::ActivePidFile($PostgresPidFile); - -} - -sub ExclusiveList { - return ('GEServer', 'GEServerGoogle'); -} - -sub DeprecatesList { - return ('KeyholeServer'); -} - -sub RPMList { - my $self = shift; - return ('GoogleEarthCommon', - 'gcc-ge-runtime', - 'expat-ge', - 'proj-ge', - 'openssl-ge', - 'openldap-ge', - 'apache-ge', - 'tomcat-ge', - 'geos-ge', - 'postgresql-ge', - 'postgis-ge', - $ServerRPM, - ); -} - -sub PreActionHandler { - # Remove the webapp dirs manually. If tomcat did the right thing - # (auto-update the ebapps from newer wars) then wouldn't have to do this. - system("rm -Rf /opt/google/getomcat/webapps/SearchPublisher"); - system("rm -Rf /opt/google/getomcat/webapps/SearchServlet"); - system("rm -Rf /opt/google/getomcat/webapps/StreamPublisher"); - - # tomcat can leave it's PID file around - # an older version ran as root so the pidfile was owned by root - # we know tomcat isn't running now, so clean the pidfile just in case - unlink($TomcatPidFile); -} - -sub CreateDirectories { - # Create directories given as parameters if they don't already exist - foreach my $dir (@_) { - if (! -d $dir ) - { - mkdir($dir, 755); - } - } -} - -sub PreInstallHandler { - # Disable stock apache if it exists - # It can either be called 'apache' (on RH) or 'httpd' (on SuSe/SLES). - # We can simply disable both - foreach my $alt ('apache', 'apache2', 'httpd') { - my $script = "/etc/init.d/$alt"; - if (-e $script) { - print "Disabling $script ... "; - system("$script stop >/dev/null 2>&1"); - InstallUtils::RemoveScript($alt); - } - } -} - -sub SetServerFilePerms { - - my $tomcatusername = $Users::TomcatUser->[0]; - my $gegroup = $Users::TomcatUser->[1]; - - for my $dir ('/opt/google/getomcat/webapps/StreamPublisher.war', - '/opt/google/getomcat/webapps/SearchPublisher.war', - '/opt/google/getomcat/webapps/SearchServlet.war', - '/opt/google/getomcat/lib/GEJniWrapper.jar', - '/opt/google/search/plugins/CoordinatePlugin.jar', - '/opt/google/search/plugins/ExamplePlugin.jar', - '/opt/google/search/plugins/GeocodingFederatedPlugin.jar', - '/opt/google/search/plugins/GEPlacesPlugin.jar', - '/opt/google/search/plugins/PoiPlugin.jar', - '/opt/google/search/plugins/GSAPlugin.jar', - '/opt/google/search/plugins/CoordinatePlugin.properties', - '/opt/google/search/plugins/ExamplePlugin.properties', - '/opt/google/search/plugins/GEPlacesPlugin.properties', - '/opt/google/search/plugins/GSAPlugin.properties', - '/opt/google/search/plugins/GeocodingFederatedPlugin.properties', - '/opt/google/search/plugins/POIPlugin.properties', - '/opt/google/search/plugins/postgres.properties', - '/opt/google/search/tabs/Coordinates.gestd', - '/opt/google/search/tabs/Example_Plugin.gestd', - '/opt/google/search/tabs/GeocodingFederated.gestd', - '/opt/google/search/tabs/Places.gestd', - '/opt/google/search/api/SearchAPI.jar') { - if (-d $dir) { - if (system("chown -R root:$gegroup $dir") != 0) { - die "Unable to chown $dir\n"; - } - } - } -} - -sub PostInstallHandler { - # Post install steps are now included in the Installer script instead of - # the RPM spec file. - my $ge_root = "/opt/google"; - my $httpd_root = "$ge_root/gehttpd"; - my $tomcat_root = "$ge_root/getomcat"; - - my $apacheusername = $Users::ApacheUser->[0]; - my $tomcatusername = $Users::TomcatUser->[0]; - my $pgusername = $Users::PostgresUser->[0]; - my $gegroup = $Users::ApacheUser->[1]; - - # Replace IA_JAVA_HOME_VAR with JAVA_HOME value in geserver. - InstallUtils::ReplaceTokenInFile(StartStopCommand(), 'IA_GEAPACHE_USER', $apacheusername); - InstallUtils::ReplaceTokenInFile(StartStopCommand(), 'IA_GETOMCAT_USER', $tomcatusername); - InstallUtils::ReplaceTokenInFile(StartStopCommand(), 'IA_GEPGUSER', $pgusername); - - # Write the users file into /etc/init.d/gevars.sh - my $varsfile = '/etc/init.d/gevars.sh'; - open(VARSFILE, '>', $varsfile) || die "Unable to create $varsfile: $!\n"; - print VARSFILE "GEAPACHEUSER=$apacheusername\n"; - print VARSFILE "GETOMCATUSER=$tomcatusername\n"; - print VARSFILE "GEPGUSER=$pgusername\n"; - print VARSFILE "GEGROUP=$gegroup\n"; - close(VARSFILE); - - InstallUtils::systemordie("mkdir -p $httpd_root/conf.d/virtual_servers/runtime"); - InstallUtils::systemordie("touch $httpd_root/conf.d/virtual_servers/runtime/default_ge_runtime"); - InstallUtils::systemordie("touch $httpd_root/conf.d/virtual_servers/runtime/default_map_runtime"); - InstallUtils::systemordie("chown -R $apacheusername:$gegroup $httpd_root/conf.d/virtual_servers/runtime"); - InstallUtils::systemordie("chmod -R 775 $httpd_root/conf.d/virtual_servers/runtime"); - SetServerFilePerms(); - - # Remove the old location for postgres database. - system("rm -Rf $ge_root/share/pgsql"); - - # Make sure needed directories exist(some .rpms are not correctly - # imported into .debs, and some of the directories seem to not get created. - CreateDirectories("$tomcat_root/temp", "$tomcat_root/webapps", "$tomcat_root/work", "/var/opt/google/pgsql", "/var/opt/google/log" ); - - # change the ownership of the postgres directory because postgres needs to write to it - InstallUtils::systemordie("chown -R $pgusername:$gegroup /var/opt/google/pgsql"); - - # Make getomcatuser the owner of certain tomcat dirs coz it needs write - # to those dirs. - InstallUtils::systemordie("chown -R $tomcatusername:$gegroup $tomcat_root/logs $tomcat_root/temp $tomcat_root/webapps $tomcat_root/work"); - - # geresetpgdb will now be called only if pg data dir does not exist. - my $pg_data_dir = '/var/opt/google/pgsql/data'; - if (! -e $pg_data_dir) { - print "\nCreating postgres db...\n"; - if (system("cd / ; sudo -u $pgusername $ge_root/bin/geresetpgdb") != 0) { - die "Unable to create postgres db\n"; - } - } - - # Prompt for publishroot location - if (system("$ge_root/bin/geconfigurepublishroot") != 0) { - die "Unable to create publish root.\n"; - } - - InstallUtils::InstallScriptOrDie("geserver"); -} - - -sub ExtractPreviousJavaHome { - my ($self) = @_; - my $envfile = $TomcatEnvFile; - if (-f $envfile) { - open(ENVFILE, '<', $envfile) || die "Unable to open $envfile: $!\n"; - while () { - chomp; - if (/JAVA_HOME=(.+)/) { - close(ENVFILE); - return $1; - } - } - close(ENVFILE); - } - return undef; -} - -sub SetJavaHome { - my ($self, $java_home) = @_; - - my $envfile = $TomcatEnvFile; - open(ENVFILE, '>', $envfile) || die "Unable to open $envfile: $!\n"; - print ENVFILE "export JAVA_HOME=$java_home\n"; - print ENVFILE "export JRE_HOME=$java_home\n"; - print ENVFILE "unset JAVA_OPTS\n"; - print ENVFILE "export CATALINA_PID=$TomcatPidFile\n"; - close(ENVFILE); - - # Replace IA_JAVA_HOME_VAR with JAVA_HOME value in geserver. - InstallUtils::ReplaceTokenInFile(StartStopCommand(), 'IA_JAVA_HOME_VAR', $java_home); -} - - -sub FindJavaHome { - my ($self, $disallow_hash) = @_; - - my $java_home = $self->ExtractPreviousJavaHome(); - - if (defined($java_home) && - !$self->ValidateJavaHome($java_home, $disallow_hash, 0)) { - undef $java_home; - } - - TermHelps::Clear(); - $java_home = $self->PromptUserForJavaHome($java_home, $disallow_hash); - return $java_home; -} - -sub ValidateJavaHome { - my ($self, $java_home, $disallow_hash, $emitmsg) = @_; - - if (defined($disallow_hash) && exists $disallow_hash->{$java_home}) { - warn "You may not specify $java_home.\n" if $emitmsg; - return 0; - } - - my $java_path = "$java_home/bin/java"; - - if (! -f $java_path) { - warn "Cannot find java under $java_home.\n" if $emitmsg; - return 0; - } - - # We only care about the major and minor version - my $output=`$java_path -version 2>&1`; - if ($output !~ /java version "(\d\.\d)\..*"/) { - warn "Cannot detect java version for $java_path.\n" if $emitmsg; - return 0; - } - my $ver = $1; - my $req = $RequiredJavaVersion; - - if ($ver ne $req) { - warn "$java_path is wrong version ($ver). Must be $req.\n" if $emitmsg; - return 0; - } - - return 1; -} - -sub PromptUserForJavaHome { - my ($self, $default, $disallow_hash) = @_; - my $java_home; - - print "Google Earth Enterprise Server requires Java Runtime Environment\n", - "version $RequiredJavaVersion.\n\n"; - - my $prompt = "Please enter directory for \$JAVA_HOME"; - - TermHelps::PushWarnState(); - while (1) { - $java_home = prompt::GetDirectory($prompt, $default); - if ($self->ValidateJavaHome($java_home, $disallow_hash, 1)) { - last; - } else { - TermHelps::Beep(); - } - } - TermHelps::PopWarnState(); - return $java_home; -} - - - -1; diff --git a/earth_enterprise/src/server/SConscript b/earth_enterprise/src/server/SConscript index 40c1963cdf..c12b26a0ce 100644 --- a/earth_enterprise/src/server/SConscript +++ b/earth_enterprise/src/server/SConscript @@ -27,7 +27,8 @@ env.Append(CPPPATH = ['#server']) env.install('httpdconf', ['.htpasswd']) # Install the postgres init script along with the sql files. -env.install('server_bin', ['geresetpgdb', 'gestream_tables.sql', +env.install('server_bin', ['geresetpgdb', 'gepgcommon']) +env.install('server_sql', ['gestream_tables.sql', 'gestream_tables_upgrade_to_3_1.sql', 'gesearch_tables.sql', 'geendsnippet_tables.sql']) env.install('httpd', ['gehttpd_init'], 'bin') diff --git a/earth_enterprise/src/server/gepgcommon b/earth_enterprise/src/server/gepgcommon new file mode 100644 index 0000000000..ee75e31f90 --- /dev/null +++ b/earth_enterprise/src/server/gepgcommon @@ -0,0 +1,96 @@ +#! /bin/bash +# +# Copyright 2017 Open GEE Developers. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +BINDIR=/opt/google/bin +VARPGDIR=/var/opt/google/pgsql +GEPGUSER=gepguser + +# Runs a command a specific user +# If it's the same user, then just execute directly, otherwise use su or sudo +function run_as_user +{ + if [ "$( whoami )" = "$1" ]; then + >&2 echo "sh -c \"$2\"" + sh -c "$2" + else + if su "$1" -c 'echo 1' >/dev/null 2>&1; then + >&2 echo "cd / ;su \"$1\" -c \"$2\"" + ( cd / ;su "$1" -c "$2" ) + else + >&2 echo "cd / ;sudo -u \"$1\" -- \"$2\"" + ( cd / ;sudo -u "$1" -- "$2" ) + fi + fi +} + +# Dumps a single database +function dump_db +{ + echo "dumping $1" + + # Check to make sure the database is valid + myres=$( run_as_user "$GEPGUSER" "$(printf '%q' "$BINDIR/psql") -lqt" ) + myres=$( echo "$myres" | cut -d \| -f 1 | grep -w "$1" | wc -l ) + if [ "$myres" == 1 ]; then + # Do dump operation + run_as_user "$GEPGUSER" "$(printf '%q' "$BINDIR/pg_dump") $(printf '%q' "$1") > $(printf '%q' "$BACKUP_DIR/$1.dump")" + + # Special case for gepoi database + if [ "$1" == "gepoi" ]; then + # Now backup just the gepoi tables, not the schema and postgis tables + for table in $( get_gepoi_tables ) + do + run_as_user "$GEPGUSER" "$(printf '%q' "$BINDIR/pg_dump") gepoi -t $(printf '%q' "$table") > $(printf '%q' "$BACKUP_DIR/gepoi.$table.dump")" + done + fi + fi +} + +# Retrieves the gepoi table names from the gepoi database +function get_gepoi_tables { + echo $( run_as_user "$GEPGUSER" "$(printf '%q' "$BINDIR/psql") gepoi -c \"\dt gepoi*\" | grep table | awk -F\| '{ print \$2 }'" ) +} + +# Dumps geserve-databases. +function do_dump { + # Start postmaster. + if [ ! -f "$VARPGDIR/data/postmaster.pid" ]; then + echo $( run_as_user "$GEPGUSER" "$(printf '%q' "$BINDIR/pg_ctl") -D $(printf '%q' "$VARPGDIR/data") -l $(printf '%q' "$VARPGDIR/logs/pg.log") start -w" ) + fi + + # Dump databases. + BACKUP_DIR=$VARPGDIR/data.backup_dump.$$ + if [ "$dump_path" != "" ]; then + BACKUP_DIR=$dump_path + fi + + echo "Keeping a backup of old geserve-databases at $BACKUP_DIR ..." + echo "After verifying that the database is good, you may delete it to recover disk space." + + run_as_user "$GEPGUSER" "mkdir $(printf '%q' "$BACKUP_DIR")" + + dump_db gestream + dump_db geendsnippet + dump_db gesearch + dump_db gepoi + + # Stop postmaster. + if [ -f "$VARPGDIR/data/postmaster.pid" ]; then + echo $( run_as_user "$GEPGUSER" "$(printf '%q' "$BINDIR/pg_ctl") -D $(printf '%q' "$VARPGDIR/data") -l $(printf '%q' "$VARPGDIR/logs/pg.log") stop -w" ) + fi + +} diff --git a/earth_enterprise/src/server/geresetpgdb b/earth_enterprise/src/server/geresetpgdb index 22e8594eeb..32d675eb36 100755 --- a/earth_enterprise/src/server/geresetpgdb +++ b/earth_enterprise/src/server/geresetpgdb @@ -1,4 +1,4 @@ -#!/bin/bash +#! /bin/bash # # Copyright 2017 Google Inc. # @@ -27,8 +27,12 @@ # - recreate geserve-databases in their initial state of GEE system; # # Dumps geserve-databases -# 'geresetpgdb backup' +# 'geresetpgdb backup [path_to_dump_directory]' # - back up (dump) current geserve-databases; +# - if path_to_dump_directory is specified, the files will be dumped to +# that directory. The user running the script (usually gepguser) must +# have write permissions to that directory already or to the parent +# directory; # # Restores geserve-databases from specified dump directory. # 'geresetpgdb restore path_to_dump_directory' @@ -41,8 +45,9 @@ # Implements 'upgrade'-reset with restoring database state we have before # running reset. # Used by installer in upgrade procedure for GEE 5.0 and later versions. -# 'geresetpgdb upgrade' -# - back up(dump) current geserve-databases; +# 'geresetpgdb upgrade [path_to_dump_directory]' +# - back up(dump) current geserve-databases (unless path_to_dump_directory +# is specified); # - delete data directory; # - recreate postgres db instance; # - recreate superuser; @@ -70,11 +75,35 @@ # /opt/google/share/geplaces/geplaces create # /opt/google/share/searchexample/searchexample create -set -e - VARPGDIR=/var/opt/google/pgsql SHAREDIR=/opt/google/share/postgresql/contrib BINDIR=/opt/google/bin +SQLDIR=/opt/google/share/opengee-server/sql +SCRIPTDIR=`dirname "$0"` + +# Import utility functions +. "$SCRIPTDIR/gepgcommon" + +# Handles errors - prints out error code, command, and line number; shuts down +# PostgreSQL if running +on_error () { + errcode=$? # save the exit code as the first thing done in the trap function + echo "error $errorcode" + echo "the command executing at the time of the error was" + echo "$BASH_COMMAND" + echo "on line ${BASH_LINENO[0]}" + # $BASH_COMMAND contains the command that was being executed at the time of the trap + # ${BASH_LINENO[0]} contains the line number in the script of that command + + # Shut down database if running + if [ -f "$VARPGDIR/data/postmaster.pid" ]; then + "$BINDIR/pg_ctl" -D "$VARPGDIR/data" -l "$VARPGDIR/logs/pg.log" stop -w + fi + + exit $errcode +} + +trap on_error ERR if [ ! -n "$1" ]; then type="soft"; @@ -82,9 +111,9 @@ else type="$1"; fi -if [ $type == "hard" ]; then - echo " WARNING: 'geresetpgdb $type' will completely delete postgresql data" - echo "directory, and then recreate the gestream, gesearch, gepoi, gesnippets" +if [ "$type" == "hard" ]; then + echo " WARNING: 'geresetpgdb $type' will completely delete all GEE postgresql" + echo "databases, and then recreate the gestream, gesearch, gepoi, gesnippets" echo "databases in their initial state." echo "It does not perform backup." echo "All the information about pushed/published databases, snippets profiles" @@ -112,7 +141,7 @@ if [ $type == "hard" ]; then exit ;; esac -elif [ $type == "soft" ]; then +elif [ "$type" == "soft" ]; then echo " WARNING: 'geresetpgdb $type' will back up the gestream, gesearch," echo "gepoi and gesnippets databases, and then recreate them in their initial" echo "state." @@ -137,186 +166,205 @@ elif [ $type == "soft" ]; then exit ;; esac -elif [ $type == "restore" ]; then - if [ ! -n "$2" ]; then +elif [ "$type" == "restore" ] || [ "$type" == "upgrade" ] || [ "$type" == "backup" ]; then + if [ "$type" == "restore" ] && [ ! -n "$2" ]; then echo "WARNING: Path to dump directory is not specified." echo "Usage: $0 restore path_to_dump_dir" exit else - dump_path="$2" + if [ -n "$2" ]; then + dump_path="$2" + fi fi fi +# Deletes old database instances +function do_reset { -# Dumps geserve-databases. -function do_dump { - # Start postmaster. - if [ ! -f $VARPGDIR/data/postmaster.pid ]; then - $BINDIR/pg_ctl -D $VARPGDIR/data -l $VARPGDIR/logs/pg.log start -w - fi - - # Dump databases. - echo "Keeping a backup of old geserve-databases at $VARPGDIR/data.backup_dump.$$ ..." - echo "After verifying that the database is good, you may delete it to recover disk space." - mkdir $VARPGDIR/data.backup_dump.$$ - - if [ `$BINDIR/psql -lqt | cut -d \| -f 1 | grep -w gestream | wc -l` == 1 ]; then - $BINDIR/pg_dump gestream > $VARPGDIR/data.backup_dump.$$/gestream.dump + # Drop gee databases + if [ `"$BINDIR/psql" -lqt | cut -d \| -f 1 | grep -w gestream | wc -l` == 1 ]; then + "$BINDIR/dropdb" -U geuser gestream fi - if [ `$BINDIR/psql -lqt | cut -d \| -f 1 | grep -w geendsnippet | wc -l` == 1 ]; then - $BINDIR/pg_dump geendsnippet > $VARPGDIR/data.backup_dump.$$/geendsnippet.dump + if [ `"$BINDIR/psql" -lqt | cut -d \| -f 1 | grep -w geendsnippet | wc -l` == 1 ]; then + "$BINDIR/dropdb" -U geuser geendsnippet fi - if [ `$BINDIR/psql -lqt | cut -d \| -f 1 | grep -w gesearch | wc -l` == 1 ]; then - $BINDIR/pg_dump gesearch > $VARPGDIR/data.backup_dump.$$/gesearch.dump + if [ `"$BINDIR/psql" -lqt | cut -d \| -f 1 | grep -w gesearch | wc -l` == 1 ]; then + "$BINDIR/dropdb" -U geuser gesearch fi - if [ `$BINDIR/psql -lqt | cut -d \| -f 1 | grep -w gepoi | wc -l` == 1 ]; then - $BINDIR/pg_dump gepoi > $VARPGDIR/data.backup_dump.$$/gepoi.dump + if [ `"$BINDIR/psql" -lqt | cut -d \| -f 1 | grep -w gepoi | wc -l` == 1 ]; then + "$BINDIR/dropdb" -U geuser gepoi fi - echo "Done." - - # Stop postmaster. - $BINDIR/pg_ctl -D $VARPGDIR/data -l $VARPGDIR/logs/pg.log stop } # Deletes old data and recreates db instance. -function do_reset { - if [ -f $VARPGDIR/data/postmaster.pid ]; then - $BINDIR/pg_ctl -D $VARPGDIR/data -l $VARPGDIR/logs/pg.log stop +function do_hard_reset { + # Do hard reset and init DB + # Deletes old data and recreates db instance. + + if [ -f "$VARPGDIR/data/postmaster.pid" ]; then + "$BINDIR/pg_ctl" -D "$VARPGDIR/data" -l "$VARPGDIR/logs/pg.log" stop fi # delete all the db files. not sure if we should do this. - rm -Rf $VARPGDIR/data + rm -Rf "$VARPGDIR/data" # create a new db instance from scratch - $BINDIR/initdb --auth=trust -D $VARPGDIR/data >/dev/null + "$BINDIR/initdb" --auth=trust -D "$VARPGDIR/data" >/dev/null } # Check if postmaster is running. If it is then prompt the user to stop the # server -if [ -e $VARPGDIR/data/postmaster.pid ]; then - echo "Please stop the server first using the following command"; - echo "/etc/init.d/geserver stop"; - exit 1; -fi - -if [ $type == "backup" ]; then - if [ ! -e $VARPGDIR/data ]; then - echo "WARNING: There is no data to back up." - else - do_dump - fi - exit +if [ -e "$VARPGDIR/data/postmaster.pid" ]; then + echo "Please stop the server first using the following command" + echo "/etc/init.d/geserver stop" + exit 1 fi # if the data dir does not exist then this has to be a hard reset. -if [ ! -e $VARPGDIR/data ]; then - type="hard"; +# TODO: This will need to be removed when we unbundle PostgreSQL +if [ ! -e "$VARPGDIR/data" ]; then + type="hard" fi -if [ $type == "hard" ]; then - # Do reset and recreate database instance. - do_reset -else - # Do backup for any reset except 'hard'. + +if [ "$type" == "backup" ]; then do_dump +elif [ "$type" == "hard" ]; then + if [ ! -e "$VARPGDIR/data" ]; then + # create a new db instance from scratch + # TODO: This will need to be removed when we unbundle PostgreSQL + "$BINDIR/initdb" --auth=trust -D "$VARPGDIR/data" >/dev/null + else + # Start postmaster. + if [ ! -f "$VARPGDIR/data/postmaster.pid" ]; then + "$BINDIR/pg_ctl" -D "$VARPGDIR/data" -l "$VARPGDIR/logs/pg.log" start -w + fi + + # Do reset and recreate database instance. + echo Removing geserve-databases... + do_reset + + # Also drop example databases + if [ `"$BINDIR/psql" -lqt | cut -d \| -f 1 | grep -w geplaces | wc -l` == 1 ]; then + "$BINDIR/dropdb" -U geuser geplaces + fi + if [ `"$BINDIR/psql" -lqt | cut -d \| -f 1 | grep -w searchexample | wc -l` == 1 ]; then + "$BINDIR/dropdb" -U geuser searchexample + fi + + # Remove geuser + echo Removing geuser... + "$BINDIR/psql" postgres -q -c "DROP USER IF EXISTS geuser" + fi +else # Check if PostgreSQL version have been changed. - old_version=`cat $VARPGDIR/data/PG_VERSION | cut -c1-3` - new_version=`$BINDIR/psql --version | cut -f3 -d' ' | cut -c1-3` + # TODO: this will need to be updated to work with unbundled versions of PostgreSQL and to detect and migrate data + # from bundled versions to unbundled versions + old_version=`cat "$VARPGDIR/data/PG_VERSION" | cut -c1-3` + new_version=`"$BINDIR/psql" --version | cut -f3 -d' ' | cut -c1-3` if [ "$old_version" != "$new_version" ]; then # PostgreSQL version have been changed - the case of upgrade. - if [ $type != "upgrade" ]; then - echo "WARNING: PostgresSQL have been updated, please, run 'upgrade' reset first." - exit + if [ "$type" != "upgrade" ]; then + echo "WARNING: PostgresSQL have been updated. Please, run 'upgrade' reset first." + exit 1 + fi + if [ "$dump_path" == "" ]; then + echo "WARNING: PostgresSQL have been updated. You must indicate the path to the backup data." + exit 1 fi + else + # Do backup for any reset except 'hard' or if we are upgrading to a new database version. In that case, + # it must have been done with the previous version of the PostgreSQL binaries + do_dump fi - if [ $type == "upgrade" ]; then - # Do reset and recreate database instance. - do_reset + if [ "$type" == "upgrade" ]; then + do_hard_reset fi fi -# Start postmaster. -if [ ! -f $VARPGDIR/data/postmaster.pid ]; then - $BINDIR/pg_ctl -D $VARPGDIR/data -l $VARPGDIR/logs/pg.log start -w +# Start postmaster +if [ ! -f "$VARPGDIR/data/postmaster.pid" ]; then + echo Starting server + "$BINDIR/pg_ctl" -D "$VARPGDIR/data" -l "$VARPGDIR/logs/pg.log" start -w fi # Soft reset -if [ $type == "soft" -o $type == "restore" ]; then - if [ `$BINDIR/psql -lqt | cut -d \| -f 1 | grep -w gestream | wc -l` == 1 ]; then - $BINDIR/dropdb -U geuser gestream - fi - if [ `$BINDIR/psql -lqt | cut -d \| -f 1 | grep -w geendsnippet | wc -l` == 1 ]; then - $BINDIR/dropdb -U geuser geendsnippet - fi - if [ `$BINDIR/psql -lqt | cut -d \| -f 1 | grep -w gesearch | wc -l` == 1 ]; then - $BINDIR/dropdb -U geuser gesearch - fi - if [ `$BINDIR/psql -lqt | cut -d \| -f 1 | grep -w gepoi | wc -l` == 1 ]; then - $BINDIR/dropdb -U geuser gepoi - fi -else - $BINDIR/createuser --superuser geuser +if [ "$type" == "soft" -o "$type" == "restore" ]; then + do_reset +elif [ "$type" != "backup" ]; then + "$BINDIR/createuser" --superuser geuser fi -if [ $type == "upgrade" -o $type == "restore" ]; then +if [ "$type" == "upgrade" -o "$type" == "restore" ]; then echo "Creating geserve-databases..." - $BINDIR/createdb -T template0 gestream - $BINDIR/createdb -T template0 geendsnippet - $BINDIR/createdb -T template0 gesearch - $BINDIR/createdb -T template0 gepoi + "$BINDIR/createdb" -T template0 gestream + "$BINDIR/createdb" -T template0 geendsnippet + "$BINDIR/createdb" -T template0 gesearch + "$BINDIR/createdb" -T template0 gepoi echo "Done." -else +elif [ "$type" != "backup" ]; then echo "Creating geserve-databases..." - $BINDIR/createdb --owner=geuser -U geuser gestream - $BINDIR/psql -q -d gestream geuser -f $BINDIR/gestream_tables.sql + "$BINDIR/createdb" --owner=geuser -U geuser gestream + "$BINDIR/psql" -q -d gestream geuser -f "$SQLDIR/gestream_tables.sql" - $BINDIR/createdb --owner=geuser -U geuser geendsnippet - $BINDIR/psql -q -d geendsnippet geuser -f $BINDIR/geendsnippet_tables.sql + "$BINDIR/createdb" --owner=geuser -U geuser geendsnippet + "$BINDIR/psql" -q -d geendsnippet geuser -f "$SQLDIR/geendsnippet_tables.sql" - $BINDIR/createdb --owner=geuser -U geuser gesearch - $BINDIR/psql -q -d gesearch geuser -f $BINDIR/gesearch_tables.sql + "$BINDIR/createdb" --owner=geuser -U geuser gesearch + "$BINDIR/psql" -q -d gesearch geuser -f "$SQLDIR/gesearch_tables.sql" + + "$BINDIR/createdb" -U geuser --owner=geuser gepoi + "$BINDIR/psql" -U geuser -d gepoi -c "CREATE EXTENSION postgis" - $BINDIR/createdb -U geuser --owner=geuser gepoi - $BINDIR/createlang -U geuser plpgsql gepoi - # read -p "wating for you..." - $BINDIR/psql -q -U geuser -d gepoi -f $SHAREDIR/postgis.sql 2>/dev/null >/dev/null - #$BINDIR/psql -q -U geuser -d gepoi -f $SHAREDIR/postgis_upgrade.sql 2>/dev/null >/dev/null - $BINDIR/psql -q -U geuser -d gepoi -f $SHAREDIR/spatial_ref_sys.sql 2>/dev/null >/dev/null echo "Done." fi -if [ $type == "upgrade" -o $type == "restore" ]; then -# cd "$VARPGDIR"/data.backup.$$ -# test -f geplaces.dump && /opt/google/share/geplaces/geplaces create -# test -f searchexample.dump && /opt/google/share/searchexample/searchexample create +if [ "$type" == "upgrade" -o "$type" == "restore" ]; then shopt -s nullglob # set nullglob so that bash allows patterns which match no files # to expand to a null string, rather than themselves. - if [ $type == "upgrade" ]; then - echo "Restoring geserve-databases from dump $VARPGDIR/data.backup_dump.$$ ..." - cd $VARPGDIR/data.backup_dump.$$ - else + if [ "$dump_path" != "" ]; then echo "Restoring geserve-databases from dump $dump_path ..." - cd $dump_path + cd "$dump_path" + elif [ "$type" == "upgrade" ]; then + echo "Restoring geserve-databases from dump $VARPGDIR/data.backup_dump.$$ ..." + cd "$VARPGDIR/data.backup_dump.$$" + fi + + # Check to see if the individual tables from gepoi were dumped + gepoi_dump_files=`ls gepoi* | wc | awk '{ print $1 }'` + + # If gepoi tables have been dumped individually, create gepoi database and install postgis extension + if [ "$gepoi_dump_files" -gt 1 ]; then + echo Adding PostGIS extension + "$BINDIR/psql" -U geuser -d gepoi -c "CREATE EXTENSION postgis" fi for DB in *.dump; do - if [ -s $DB ]; then - $BINDIR/psql -q -d ${DB%?????} -f $DB + if [ -s "$DB" ]; then + if [ "$gepoi_dump_files" == 1 ] || [ "$DB" != "gepoi.dump" ]; then + echo "Restoring $DB..." + if [ "${DB:0:6}" == "gepoi." ]; then + # The dump is a single table for the gepoi database, not the full database, restore to the correct db + "$BINDIR/psql" -q -d gepoi -f "$DB" + else + "$BINDIR/psql" -q -d "${DB%?????}" -f "$DB" + fi + fi fi done # Update tables/records of gesearch databases. - $BINDIR/psql -q -d gesearch geuser -f $BINDIR/gesearch_tables.sql + "$BINDIR/psql" -q -d gesearch geuser -f "$SQLDIR/gesearch_tables.sql" # Update tables/records of gestream databases. - $BINDIR/psql -q -d gestream geuser -f $BINDIR/gestream_tables.sql + "$BINDIR/psql" -q -d gestream geuser -f "$SQLDIR/gestream_tables.sql" echo "Done." fi # Stop postmaster -$BINDIR/pg_ctl -D $VARPGDIR/data -l $VARPGDIR/logs/pg.log stop +"$BINDIR/pg_ctl" -D "$VARPGDIR/data" -l "$VARPGDIR/logs/pg.log" stop diff --git a/earth_enterprise/src/server/gesearch_tables.sql b/earth_enterprise/src/server/gesearch_tables.sql index 9e1a4784e0..45afc42540 100644 --- a/earth_enterprise/src/server/gesearch_tables.sql +++ b/earth_enterprise/src/server/gesearch_tables.sql @@ -1,5 +1,5 @@ -- --- Copyright 2017 Google Inc. +-- Copyright 2018 Google Inc. -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. @@ -16,10 +16,6 @@ SET CLIENT_MIN_MESSAGES TO WARNING; ---Add "plpgsql" to the list of existing languages. -CREATE LANGUAGE plpgsql; - - --Check if the table already exists. --Return TRUE/FALSE based on whether tables exists or not. CREATE OR REPLACE FUNCTION check_table_exists(table_name varchar) @@ -163,5 +159,3 @@ SELECT create_tables(); --insert/update system search services. SELECT run_searchdef_upsert(); - -DROP LANGUAGE IF EXISTS plpgsql CASCADE; diff --git a/earth_enterprise/src/server/gestream_tables.sql b/earth_enterprise/src/server/gestream_tables.sql index f73f2c0ed1..6706426140 100644 --- a/earth_enterprise/src/server/gestream_tables.sql +++ b/earth_enterprise/src/server/gestream_tables.sql @@ -1,4 +1,4 @@ --- Copyright 2017 Google Inc. +-- Copyright 2018 Google Inc. -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. @@ -16,9 +16,6 @@ SET CLIENT_MIN_MESSAGES = WARNING; ---Add "plpgsql" to the list of existing languages. -CREATE LANGUAGE plpgsql; - --Check if the table already exists. --Return TRUE/FALSE based on whether tables exists or not. CREATE OR REPLACE FUNCTION check_table_exists(table_name varchar) @@ -144,4 +141,3 @@ END; $$ LANGUAGE plpgsql; SELECT create_or_update_tables(); -DROP LANGUAGE IF EXISTS plpgsql CASCADE; diff --git a/earth_enterprise/src/server/wsgi/search/common/geconstants.py b/earth_enterprise/src/server/wsgi/search/common/geconstants.py index 4689caef30..8ed5ae7dcd 100644 --- a/earth_enterprise/src/server/wsgi/search/common/geconstants.py +++ b/earth_enterprise/src/server/wsgi/search/common/geconstants.py @@ -22,7 +22,7 @@ class Constants(object): - """Class contains Contants used in search implementations.""" + """Class contains Constants used in search implementations.""" def __init__(self): """Inits constants used in search implementation.""" @@ -75,7 +75,7 @@ def __init__(self): # city = result[city_query_indexes["city"]] self.city_query = ( - "SELECT ${FUNC}(ST_Force_3DZ(the_geom)) AS the_geom,city,country_name," + "SELECT ${FUNC}(ST_Force3DZ(the_geom)) AS the_geom,city,country_name," "population, subnational_name, GeometryType(the_geom) AS geom_type " "FROM ${CITY_VIEW} " "WHERE " @@ -84,7 +84,7 @@ def __init__(self): self.country_query = ( "SELECT country_name, country_code, " - "${FUNC}(ST_Force_3DZ(the_geom)) AS the_geom, capital, areainsqkm, " + "${FUNC}(ST_Force3DZ(the_geom)) AS the_geom, capital, areainsqkm, " "population, continent_name, languages, " "GeometryType(the_geom) AS geom_type " "FROM countries " @@ -93,7 +93,7 @@ def __init__(self): "ORDER BY population DESC") self.city_and_country_name_query = ( - "SELECT ${FUNC}(ST_Force_3DZ(the_geom)) AS the_geom, population, city," + "SELECT ${FUNC}(ST_Force3DZ(the_geom)) AS the_geom, population, city," "country_name, subnational_name, GeometryType(the_geom) AS geom_type " "FROM ${CITY_VIEW} " "WHERE " @@ -101,14 +101,14 @@ def __init__(self): "lower(country_name) = %s") self.city_and_country_code_query = ( - "SELECT ${FUNC}(ST_Force_3DZ(the_geom)) AS the_geom, population, city," + "SELECT ${FUNC}(ST_Force3DZ(the_geom)) AS the_geom, population, city," "country_name, subnational_name, GeometryType(the_geom) AS geom_type " "FROM ${CITY_VIEW} " "WHERE " "lower(city) = %s AND lower(country_code) = %s") self.city_and_subnational_name_query = ( - "SELECT ${FUNC}(ST_Force_3DZ(the_geom)) AS the_geom," + "SELECT ${FUNC}(ST_Force3DZ(the_geom)) AS the_geom," "population, city, country_name, subnational_name, " "GeometryType(the_geom) AS geom_type " "FROM ${CITY_VIEW} " @@ -116,7 +116,7 @@ def __init__(self): "lower(city) = %s AND lower(subnational_name) = %s") self.city_and_subnational_code_query = ( - "SELECT ${FUNC}(ST_Force_3DZ(the_geom)) AS the_geom, " + "SELECT ${FUNC}(ST_Force3DZ(the_geom)) AS the_geom, " "population, city, country_name, subnational_name, " "GeometryType(the_geom) AS geom_type " "FROM ${CITY_VIEW} " @@ -124,8 +124,8 @@ def __init__(self): "lower(city) = %s AND lower(subnational_code) = %s") self.example_query = ( - "SELECT ${FUNC}(ST_Force_3DZ(the_geom)) AS the_geom,Area(the_geom)," - "Perimeter(the_geom),sfar_distr,nbrhood, " + "SELECT ${FUNC}(ST_Force3DZ(the_geom)) AS the_geom,ST_Area(the_geom)," + "ST_Perimeter(the_geom),sfar_distr,nbrhood, " "GeometryType(the_geom) AS geom_type " "FROM san_francisco_neighborhoods " "WHERE " diff --git a/earth_enterprise/src/server/wsgi/search/plugin/poi_search_handler.py b/earth_enterprise/src/server/wsgi/search/plugin/poi_search_handler.py index 4efc4f6576..3599a8342d 100755 --- a/earth_enterprise/src/server/wsgi/search/plugin/poi_search_handler.py +++ b/earth_enterprise/src/server/wsgi/search/plugin/poi_search_handler.py @@ -824,7 +824,7 @@ def __CreateBboxFromParameters(self, latcenter, loncenter, latspan, lonspan): """ (xmin, xmax, ymin, ymax) = self.__GetBBoxBounds( latcenter, loncenter, latspan, lonspan) - bbox = "SetSRID('BOX3D(%s %s,%s %s)'::box3d,%s)" %( + bbox = "ST_SetSRID('BOX3D(%s %s,%s %s)'::box3d,%s)" %( xmin, ymin, xmax, ymax, self.srid) return bbox @@ -879,7 +879,7 @@ def __del__(self): def main(): poiobj = POISearch() - bbox = "SetSRID('BOX3D(-180.0 -90.0,180.0 90.0)'::box3d,4326)" + bbox = "ST_SetSRID('BOX3D(-180.0 -90.0,180.0 90.0)'::box3d,4326)" poiobj.DoSearch("US Route 101", 7, "KML", bbox) if __name__ == "__main__": diff --git a/earth_enterprise/src/server/wsgi/serve/push/search/util/search_schema_parser.py b/earth_enterprise/src/server/wsgi/serve/push/search/util/search_schema_parser.py index e9e1bc08eb..d7839d1331 100755 --- a/earth_enterprise/src/server/wsgi/serve/push/search/util/search_schema_parser.py +++ b/earth_enterprise/src/server/wsgi/serve/push/search/util/search_schema_parser.py @@ -203,7 +203,7 @@ def __StartElementHeader(self, elem): # TODO: seems we do not retrieve geometry as binary, can be # refactored. self._sql_search += ( - "SELECT Encode(AsBinary(the_geom, 'XDR'), 'base64') AS the_geom, ") + "SELECT Encode(ST_AsBinary(the_geom, 'XDR'), 'base64') AS the_geom, ") elif self._current_tag == SearchSchemaParser.SEARCH_TABLE_VALUES_TAG: self._element_start = self.__StartElementData self._element_end = self.__EndElementData diff --git a/earth_enterprise/src/support/geecheck/lib/FusionUtils.pm b/earth_enterprise/src/support/geecheck/lib/FusionUtils.pm index f33ff12a87..5e2e9afdb4 100644 --- a/earth_enterprise/src/support/geecheck/lib/FusionUtils.pm +++ b/earth_enterprise/src/support/geecheck/lib/FusionUtils.pm @@ -454,7 +454,9 @@ sub check_httpd_services() { # Check the postgres installation. sub check_postgres() { - my $max_stack_depth = readpipe "grep max_stack_depth /var/opt/google/pgsql/data/postgresql.conf"; + my @max_stack_depth_list = readpipe "sudo -u gepguser /opt/google/bin/psql postgres -c \"show max_stack_depth\""; + my $max_stack_depth = $max_stack_depth_list[2]; + chomp $max_stack_depth; my @result = (); if ($max_stack_depth eq "") { diff --git a/earth_enterprise/src/third_party/postgis/README.txt b/earth_enterprise/src/third_party/postgis/README.txt index 6f58aa8e0c..658b0268e1 100644 --- a/earth_enterprise/src/third_party/postgis/README.txt +++ b/earth_enterprise/src/third_party/postgis/README.txt @@ -5,17 +5,6 @@ This project builds a custom/sandboxed version of PostGIS for Google Earth Enterprise Fusion. It is a standard build of PostGIS, only sandboxed. -Source Files: //depot/googleclient/third_party/postgis +Source Files: earth_enterprise/third_party/postgis -Install Location: /opt/google/{bin,lib,share} - -Build Info: -For Fusion 3.2 and earlier, we build postgis-ge-1.1.7-1.x86_64.rpm which is a -sandboxed version of PostGIS. - -As of 2008-10-23: -postgis-ge-1.1.7-1.x86_64.rpm was built using rpmbuild postgis-ge.spec -on a SLES 9 box (compatible with SLES 9,10, RHEL 4,5 and Ubuntu 6,8) - -To Build, you will need to build on a SLES 9 box using the scripts found in -//depot/googleclient/geo/fusion/RPMS/build_scripts +Install Location: /opt/google/{bin,lib,share} \ No newline at end of file diff --git a/earth_enterprise/src/third_party/postgis/SConscript b/earth_enterprise/src/third_party/postgis/SConscript index d32cc494d0..a86b090cfc 100644 --- a/earth_enterprise/src/third_party/postgis/SConscript +++ b/earth_enterprise/src/third_party/postgis/SConscript @@ -18,8 +18,8 @@ Import('third_party_env') -postgis_major_version = 'postgis-1.5' -postgis_version = 'postgis-1.5.8' +postgis_major_version = 'postgis-2.3' +postgis_version = 'postgis-2.3.4' postgis_source = File('#/../../earth_enterprise/third_party/postgis/' '%s.tar.gz' % postgis_version).abspath @@ -108,6 +108,8 @@ postgis_install = postgis_env.Command( 'rm -rf %s/lib\n' 'mkdir -p %s/share/doc/packages/%s\n' 'cp -pr COPYING CREDITS README.postgis %s/share/doc/packages/%s\n' + 'mkdir -p %s/share/postgresql/extension\n' + 'cp -pr %s/liblwgeom/.libs/*.so* %s/share/postgresql/extension\n' 'cd %s%s\n' 'tar cf - * | (cd %s; tar xf -)\n' 'cd %s/share/postgresql/contrib\n' @@ -119,6 +121,8 @@ postgis_install = postgis_env.Command( install_root_opt, install_root_opt, ge_version, install_root_opt, ge_version, + install_root_opt, + build_root, install_root_opt, install_root, root_dir, install_root_opt, install_root_opt, diff --git a/earth_enterprise/src/third_party/postgis/postgis-ge.spec b/earth_enterprise/src/third_party/postgis/postgis-ge.spec deleted file mode 100644 index 458110bda4..0000000000 --- a/earth_enterprise/src/third_party/postgis/postgis-ge.spec +++ /dev/null @@ -1,89 +0,0 @@ -%define PACKAGE_NAME postgis-ge -%define _prefix /opt/google -%define _defaultdocdir %_prefix/share/doc/packages -%define _mandir %_prefix/share/man -%define buildpath %_prefix/bin:/bin:/usr/bin -%define debug_package %{nil} - -%define REQ_PROJ_VER 4.5.0 - -Summary: PostGIS extention to the PostgreSQL databse -Name: %PACKAGE_NAME -Version: 1.1.7 -Release: 1 -License: GPL -Group: Development/Libraries/C and C++ -Source0: postgis-%{version}.tar.gz -# Patch0: expat-DESTDIR.patch -BuildRoot: %{_tmppath}/%{name}-%{version}-build -URL: http://postgis.refractions.net/ -AutoReqProv: no - -BuildRequires: proj-ge-devel >= %REQ_PROJ_VER -Requires: proj-ge >= %REQ_PROJ_VER -BuildRequires: geos-ge-devel -Requires: geos-ge -BuildRequires: postgresql-ge-devel -Requires: postgresql-ge -BuildRequires: gcc-ge >= 4.1.1 -Requires: gcc-ge-runtime >= 4.1.1 -BuildRequires: libtool -BuildConflicts: libtool-32bit - -ExclusiveArch: i686 -ExclusiveArch: x86_64 - -%ifarch i686 -%define optflags -march=i686 -O2 -%define ldrunpath %_prefix/lib -%endif - -%ifarch x86_64 -%define optflags -O2 -%define ldrunpath %_prefix/lib64:%_prefix/lib -%endif - -%description -PostGIS extention to the PostgreSQL databse - -%prep -%setup -q -n postgis-%{version} -# %patch0 -p1 - -%build -if [ -x /usr/bin/getconf ] ; then - NRPROC=$(/usr/bin/getconf _NPROCESSORS_ONLN) - if [ $NRPROC -eq 0 ] ; then - NRPROC=1 - fi -else - NRPROC=1 -fi -NRPROC=$(($NRPROC*2)) -export PATH=%buildpath -export LD_RUN_PATH=%ldrunpath -# grhat's ssl needs kerberos -CFLAGS='%{optflags}' CXXFLAGS='%{optflags}' ./configure \ - --prefix=%{_prefix} \ - --mandir=%{_mandir} \ - --with-pgsql=%{_prefix}/bin/pg_config \ - --with-proj=%{_prefix} \ - --with-geos=%{_prefix}/bin/geos-config -make -j $NRPROC - -%install -[ "$RPM_BUILD_ROOT" != "/" ] && [ -d $RPM_BUILD_ROOT ] && rm -rf $RPM_BUILD_ROOT -export PATH=%buildpath -export LD_RUN_PATH=%ldrunpath -make DESTDIR=$RPM_BUILD_ROOT install -rm $RPM_BUILD_ROOT%{_prefix}/lib/*.so - -%clean -[ "$RPM_BUILD_ROOT" != "/" ] && [ -d $RPM_BUILD_ROOT ] && rm -rf $RPM_BUILD_ROOT - -%files -%defattr(-, root, root) -%doc COPYING CREDITS README.postgis -%{_prefix}/lib/*.so.* -%{_prefix}/bin/* -%{_prefix}/share/*.sql diff --git a/earth_enterprise/src/third_party/postgresql/README.txt b/earth_enterprise/src/third_party/postgresql/README.txt index 0ebc6430d9..5e83f1b5a5 100644 --- a/earth_enterprise/src/third_party/postgresql/README.txt +++ b/earth_enterprise/src/third_party/postgresql/README.txt @@ -5,19 +5,7 @@ This project builds a custom/sandboxed version of PostGreSQL for Google Earth Enterprise Fusion. It is a normal build of PostGreSQL. -Source Files: //depot/googleclient/third_party/postgresql +Source Files: earth_enterprise/third_party/postgresql Install Location: /opt/google/bin, /var/opt/google/pgsql/ -Build Info: -For Fusion 3.2 and earlier, we build postgresql-ge-8.1.8-4.x86_64.rpm which is a -sandboxed version of PostGreSQL. -A development RPM is built as well, necessary for build/dev machines to compile -against. - -As of 2008-10-23: -postgresql-ge-8.1.8-4.x86_64.rpm was built using rpmbuild postgresql-ge.spec -on a SLES 9 box (compatible with SLES 9,10, RHEL 4,5 and Ubuntu 6,8) - -To Build, you will need to build on a SLES 9 box using the scripts found in -//depot/googleclient/geo/fusion/RPMS/build_scripts diff --git a/earth_enterprise/src/third_party/postgresql/SConscript b/earth_enterprise/src/third_party/postgresql/SConscript index 9349078a06..b2eef26760 100644 --- a/earth_enterprise/src/third_party/postgresql/SConscript +++ b/earth_enterprise/src/third_party/postgresql/SConscript @@ -18,7 +18,7 @@ Import('third_party_env') -postgresql_version = 'postgresql-8.4.22' +postgresql_version = 'postgresql-9.6.5' postgresql_source = File('#/../../earth_enterprise/third_party/postgresql/%s.tar.bz2' % postgresql_version).abspath diff --git a/earth_enterprise/src/third_party/postgresql/postgresql-ge.spec b/earth_enterprise/src/third_party/postgresql/postgresql-ge.spec deleted file mode 100644 index e7f1ff9e1e..0000000000 --- a/earth_enterprise/src/third_party/postgresql/postgresql-ge.spec +++ /dev/null @@ -1,122 +0,0 @@ -%define PACKAGE_NAME postgresql-ge -%define _prefix /opt/google -%define _defaultdocdir %_prefix/share/doc/packages -%define _mandir %_prefix/share/man -%define buildpath %_prefix/bin:/bin:/usr/bin -%define debug_package %{nil} - - -Summary: PostgreSQL database -Name: %PACKAGE_NAME -Version: 8.1.8 -Release: 4 -License: BSD -Group: Development/Libraries/C and C++ -Source0: postgresql-base-%{version}.tar.bz2 -Source1: postgresql-opt-%{version}.tar.bz2 -# Patch0: expat-DESTDIR.patch -BuildRoot: %{_tmppath}/%{name}-%{version}-build -URL: http://www.postgresql.org/ -AutoReqProv: no - -BuildRequires: zlib-devel -Requires: zlib -BuildRequires: gcc-ge >= 4.1.1 -Requires: gcc-ge-runtime >= 4.1.1 -BuildRequires: libtool -BuildConflicts: libtool-32bit -Requires: python -BuildRequires: python-devel - -BuildRequires: openssl-ge-devel >= 0.9.8 -BuildConflicts: openssl-devel - -ExclusiveArch: i686 -ExclusiveArch: x86_64 - -%ifarch i686 -%define optflags -march=i686 -O2 -%define ldrunpath %_prefix/lib -%endif - -%ifarch x86_64 -%define optflags -O2 -%define ldrunpath %_prefix/lib64:%_prefix/lib -%endif - -%description -The worlds most advanced open source database. - -%package devel -Summary: PostgeSQL - Development files -Group: Development/Libraries/C and C++ -License: BSD -Requires: %{name} = %{version} -Requires: openssl-ge-devel >= 0.9.8 -Requires: zlib-devel -AutoReqProv: no - -%description devel -postgresql development files - - - -%prep -%setup -q -n postgresql-%{version} -%setup -q -T -D -b 1 -n postgresql-%{version} -# %patch0 -p1 - -%build -if [ -x /usr/bin/getconf ] ; then - NRPROC=$(/usr/bin/getconf _NPROCESSORS_ONLN) - if [ $NRPROC -eq 0 ] ; then - NRPROC=1 - fi -else - NRPROC=1 -fi -NRPROC=$(($NRPROC*2)) -export PATH=%buildpath -export LD_RUN_PATH=%ldrunpath -export INCLUDES='-I%{_prefix}/include' -CFLAGS='%{optflags}' CXXFLAGS='%{optflags}' ./configure \ - --prefix=%{_prefix} \ - --mandir=%{_mandir} \ - --disable-rpath \ - --enable-thread-safety \ - --with-openssl \ - --with-python \ - --without-perl \ - --without-readline \ - --without-pam \ - --without-krb5 -make -j $NRPROC - -%install -[ "$RPM_BUILD_ROOT" != "/" ] && [ -d $RPM_BUILD_ROOT ] && rm -rf $RPM_BUILD_ROOT -export PATH=%buildpath -export LD_RUN_PATH=%ldrunpath -make DESTDIR=$RPM_BUILD_ROOT install - -# This is where the data and log files live -mkdir -p $RPM_BUILD_ROOT/var/opt/google/pgsql/logs - -%clean -[ "$RPM_BUILD_ROOT" != "/" ] && [ -d $RPM_BUILD_ROOT ] && rm -rf $RPM_BUILD_ROOT - -%files -%defattr(-, root, root) -%doc COPYRIGHT HISTORY README -%{_prefix}/lib/*.so.* -%{_prefix}/lib/postgresql/* -%{_mandir}/man1/* -%{_prefix}/share/postgresql/* -%{_prefix}/bin/* -%attr(0700, gepguser, gegroup) /var/opt/google/pgsql - -%files devel -%defattr(-, root, root) -%{_prefix}/include/* -%{_prefix}/lib/*.a -%{_prefix}/lib/*.so -%{_mandir}/man7/* diff --git a/earth_enterprise/third_party/postgis/README.google b/earth_enterprise/third_party/postgis/README.google index d7f837c938..bfa3091052 100644 --- a/earth_enterprise/third_party/postgis/README.google +++ b/earth_enterprise/third_party/postgis/README.google @@ -1,10 +1,10 @@ URL: http://postgis.refractions.net -Version: 1.5.8 +Version: 2.3.4 License: GNU v2 License File: COPYING Description: -PostGIS - Geographic Information Systems Extensions to PostgreSQL +PostGIS - Geographic Information Systems Extension to PostgreSQL Local Modifications: None diff --git a/earth_enterprise/third_party/postgis/postgis-1.5.8.tar.gz b/earth_enterprise/third_party/postgis/postgis-1.5.8.tar.gz deleted file mode 100644 index f381fb90d5..0000000000 --- a/earth_enterprise/third_party/postgis/postgis-1.5.8.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4896fdae2f814b88c3ca458b7d01d7eca7e9aca021599c817919f131a1b0d804 -size 3948219 diff --git a/earth_enterprise/third_party/postgis/postgis-2.3.4.tar.gz b/earth_enterprise/third_party/postgis/postgis-2.3.4.tar.gz new file mode 100644 index 0000000000..81a2909816 --- /dev/null +++ b/earth_enterprise/third_party/postgis/postgis-2.3.4.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7ee1b1db94186420c4f311ab3395ee803815eabbcced6b3dd41e586fe24a7a3a +size 11236040 diff --git a/earth_enterprise/third_party/postgresql/README.google b/earth_enterprise/third_party/postgresql/README.google index 3bb69f6c98..d9df35809b 100644 --- a/earth_enterprise/third_party/postgresql/README.google +++ b/earth_enterprise/third_party/postgresql/README.google @@ -1,5 +1,5 @@ URL: http://www.postgresql.org/developer/ -Version: 8.4.22 +Version: 9.6.5 License: BSD License File: COPYRIGHT @@ -9,7 +9,7 @@ traditional commercial database systems with enhancements to be found in next-generation DBMS systems. PostgreSQL is free and the complete source code is available. -The PostgreSQL source, postgresql-8.4.22.tar.bz2, +The PostgreSQL source, postgresql-9.6.5.tar.bz2, is downloadable from http://www.postgresql.org/ftp/source/ Local Modifications: diff --git a/earth_enterprise/third_party/postgresql/postgresql-8.4.22.tar.bz2 b/earth_enterprise/third_party/postgresql/postgresql-9.6.5.tar.bz2 similarity index 55% rename from earth_enterprise/third_party/postgresql/postgresql-8.4.22.tar.bz2 rename to earth_enterprise/third_party/postgresql/postgresql-9.6.5.tar.bz2 index 373b4aa58c..de4007bbb8 100644 Binary files a/earth_enterprise/third_party/postgresql/postgresql-8.4.22.tar.bz2 and b/earth_enterprise/third_party/postgresql/postgresql-9.6.5.tar.bz2 differ