summaryrefslogtreecommitdiffstats
path: root/postgresql-setup.in
Commit message (Collapse)AuthorAgeFilesLines
* Move the repo to github.HEADmasterPavel Raiskup2016-07-221-826/+0
|
* postgresql-setup: reflect pg_upgrade movementPavel Raiskup2016-01-071-2/+2
| | | | | | | | | | | | | | | The pg_upgrade binary is not in postgresql-upgrade package now. In some upgrade scenarios, postgresql-upgrade is redundant package (SCLs/PGRPMSs). Hack the code so postgresql-setup is able to correctly advice which package should be installed to make the "old" engine available. * postgresql-setup.in (upgrade): Don't check for pg_upgrade binary existence but rather for postgres binary, and warn user with proper package name if missing. * share/postgresql-setup/library.sh.in (parse_upgrade_setup): White-list also 'package' constant name. * configure.ac: Bump version.
* postgresql-setup: postgres's $HOME must be writeablePavel Raiskup2015-11-301-0/+7
| | | | | | | | | | The pg_upgrade fails with confusing error message if there are wrong /var/lib/pgsql permissions. It's not very obvious what is the pg_upgrade's work-dir (we use 'runuser' -l) -- for this reason exit rather early with understandable error message. * postgresql-setup.in: Exit if postgres user is not able to write into $POSTGRES_HOMEDIR.
* * postgresql-setup.in: Fix the 'mountpoint' warning,Pavel Raiskup2015-09-251-1/+1
| | | | spotted by Tom Lane.
* postgresql-setup: warn for $PGDATA mountpointsPavel Raiskup2015-09-251-0/+10
| | | | | | | | | | Resolves: rhbz#1247477 * configure.ac (MOUNTPOINT): New configure-time variable. * postgresql-setup.in: Warn if $pgdata or `dirname $pgdata` is a mountpoint. * NEWS: Document. * README: Document that its better to have util-linux in BR.
* postgresql-setup: don't use .service suffix for sysvinitPavel Raiskup2015-09-221-1/+1
| | | | * postgresql-setup.in: Reuse $srvsuff in error msg.
* postgresql-setup: better error messagePavel Raiskup2015-09-221-1/+2
| | | | | * postgresql-setup.in: Give better hint about wrongly selected --upgrade-from argument.
* postgresql-setup: fix upgrade bug with non-default unit namesPavel Raiskup2015-09-221-6/+38
| | | | | | | | | | | | | | | | | | | | | | | | We can't always use '$upgradefrom_id' as "default" previous service name. This broken in-place upgrades with '--unit postgresqlPORT' (old style service files layout) or 'postgresql@port'. Now, by default, use the same service name for both older and newer PG stack. While we are on it, make it a bit more automatic and pick 'postgresql92@second' as "older stack" if upgrading into unit 'postgresql93@second'. Add new option --upgrade-from-unit which allows us to override default decision. * postgresql-setup.in: Set 'option_upgradefrom_unit' to hopefully correct default. Add new info message in case we are not upgrading from differently named unit. (USAGE_STRING): Document new --upgrade-from-unit option. (service_configuration): Don't fork based on $mode and simply use fourth parameter as 'service'. Fix the debug message a bit. (long_opts): Add new option upgrade-from-unit. * NEWS: Document.
* setup: enhance --new-systemd-unitv3.2Pavel Raiskup2015-03-201-0/+13
| | | | | | | | | | | | | | | Do not left created dropin directory in case of some initdb failure, or so. This allow user run the same --new-systemd-unit repeatedly without changing the command-line. * postgresql-setup.in (exit_handler): New exit callback wrapper. ($cleanup_dropin): Code to be executed to clean drop-in directory. (generate_systemd_dropin): Fill $cleanup_dropin callback. (initdb): Clean $cleanup_dropin in case of successful initdb. This is not needed for upgrade() because we never create drop-ins there. * NEWS: Document changes.
* setup: fix typos in commentPavel Raiskup2015-03-201-2/+2
| | | | | | * postgresql-setup.in (service_configuration): Fix commente and use @NAME_SERVICE@ instead of @SERVICE_NAME@. This would break testsuite.
* setup: don't set default pgdata blindlyPavel Raiskup2015-03-201-7/+24
| | | | | | | * postgresql-setup.in (service_configuration): Move the setting of pgdata into sysvinit-only branch. * NEWS: Document fixed bug. * configure.ac: Bump version to 3.2.
* postgresql-setup: upgrade & avoid running old serverv3.1Pavel Raiskup2015-03-191-5/+17
| | | | | | | | * postgresql-setup.in (upgrade): Call old_data_in_use to ensure that the old database server is not running. (old_data_in_use): New function. ($cleaup): Rename to $failure_cleanup. * NEWS: Document.
* postgresql-setup: keep old-dir usable with pg_upgradePavel Raiskup2015-03-191-1/+3
| | | | | | | * postgresql-setup.in (upgrade): Don't use --link option if we are not doing in-place upgrade. * NEWS: Document. * configure.ac: Bump minor version.
* sysvinit: initscript & postgresql-setup fixesPavel Raiskup2015-03-181-13/+23
| | | | | | | | | | * postgresql-setup.in($USAGE_STRING): Don't output sysvinit not-relevant options. Generalize the help a bit to match sysvinit. Throw a better warning if user runs 'service initdb postgresql@blah', and, the --port was not passed. In this case, postgresql.conf can't be used. * postgresql.init.in (initdb, upgrade): Add --unit option to postgresql-setup call.
* bunch of rhel{6,7} & scl fixesPavel Raiskup2015-03-181-1/+1
| | | | | | | | | | | | * postgresql.init.in (initdb, upgrade): Use full path to postgresql-setup, this is mostly for proper documentation purposes in case of failure. * legacy-sysv-script.in: Pass --unit before actual unit name. * postgresql-ctl.in: Handle better the $port option passed to pg_ctl. * postgresql-setup.in: Use full path to postgresql-setup, mostly for documentation purposes. * README: Add elinks to BuildRequires.
* postgresql-setup: better error handlingPavel Raiskup2015-03-171-24/+30
| | | | | | | | | | | | | | Fix the bug in handling with already initialized data directory. Now, when doing --upgrade, postgresql-setup does not try to re-initialize already initialized PGDATA directory and, after "this" unsuccessful initdb, the datadir is not removed. * postgresql-setup.in (check_not_initialized): New function. (perform_initdb): Simplify return value handling. (initdb): Use check_not_initialized function. (upgrade): Use check_not_initialized to avoid PGDATA removal. When $cleanup is false, don't remove $PGDATA.
* sysvinit: transform for SCL & RHEL6 usagePavel Raiskup2015-03-171-30/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is mostly about simplification of intiscript and postgresql-setup script reuse. Still WIP, however (some options are not applicable for sysvinit system). * share/postgresql-setup/library.sh.in (parse_upgrade_setup): Parse new variable "pghost_override". (run_cmd_as_dbadmin): New wrapper function to run something under "postgres" user. Cut from postgresql-setup. * postgresql-setup.in: Optionally source software collections. Call new check_daemon_reload instead of in-place checking. (upgrade): Use new library function run_cmd_as_dbadmin. Add new hack for $PGHOST overriding via $pghost_override. Add more verbose output to make clear what tool failed. (check_daemon_reload): New function to make the systemd daemon reload conditionally on one dedicated place. (handle_envfile): New function to abstract environment file parsing, works both for systemd & sysvinit env-files. (handle_service_envfiles): Use handle_envfile instead of in-place parsing. (service_configuration): For sysvinit supported configuration, we support only one env file per service - take this into account and don't try to detect many from systemctl output. * postgresql.init.in: Switch to bash script. Parametrize metadata by configure results. Source software collections when needed. Source project library. Don't set PGDATA if admin uses non-default service naem. Do not define PGPORT as PGPORT should be defined in postgresql.conf. Allow passing parameters into initdb/upgrade targets. ($PREVMAJORVERSION, $PREVPGENGINE): Remove unused variables. ($PGENGINE): This is @bindir@ equivalent. ($PGLOG): Spell it so it will not clash with system default PostgreSQL installation. ($pidfile): Use $NAME instead of $PID to distinguish multiple postmaster scenarios (mainly because we do not know the PGPORT yet). (start): Drop the checking logic and use postgresql-check-db-dir instead. Reuse run_cmd_as_dbadmin instead of $SU_POSTGRES. (stop): Use run_cmd_as_dbadmin instead of $SU_POSTGRES. (reload): Just coding style fix. (perform_initdb): Drop unused function, done in postgresql-setup. (__single_comand): Mostly postgresql-setup wrapper with success/failure sugar around the call itself. (initdb): Substitute the function body with postgresql-setup call. (upgrade): Likewise. * postgresql-check-db-dir.in: Fix the hint for admin about where the service should be initialized. Do not warn about systemd-only unsupported configuration. Add @bindir@ into "you need --initdb" hint. Re-style the warning a bit. * etc/postgresql-setup/upgrade/postgresql.conf: Mention new configuration option pghost_override. * configure.ac (initscriptsconfdir): New configuration directory. (PGMAJORVERSION): Use sed and regexp for MAJOR version mining. It failed for micro versions of length >= 2. (SCL_SOURCE): Define to be empty by default. * README: Document what's needed to bootstrap from git source. WIP. * Makefile.am (initscripts_DATA): Use noinst_DATA. Firstly, having initscripts_DATA installs only non-executable files. So we needed something with _SCRIPTS primary. But initscripts_SCRIPTS would face the automake's limitation that it must be "static" list of files. So make the installation of initscript (of dynamically generated name) via automake's install/uninstall. ($(initscript)): Use $(INSTANTIATE_SCRIPT) instead of $(INSTANTIATE). (install-data-hook): Call 'systemctl daemon-reload' only for non-sysvinit systems. * .gitignore: Ignore 'initscript' filename.
* postgresql-setup: better work with @SCLS@Pavel Raiskup2015-03-021-9/+2
| | | | | | | | | * configure.ac (SCL_SOURCE): New variable sourcing needed scls. * postgresql-setup.in (initdb): Use @SCL_SOURCE@ instead of runtime generated $scls_initdb_hacks. (upgrade): Use @SCL_SOURCE@. For this we don't need to specify default "current" SCL when upgrading from other SCL in upgrade-configuration 'scls' option.
* move library functions into library.shPavel Raiskup2015-03-021-22/+0
| | | | | | * postgresql-setup.in (die, error, error_q, warn, warn_q, info) (info_q, debug, set_var, root_prereq): Move to .. * share/postgresql-setup/library.sh.in: .. here.
* postgresql-check-db-dir: match configuration approachPavel Raiskup2015-03-021-97/+2
| | | | | | | | | | | | | | | | | | | * configure.ac (PGDATADIR): Use /var/lib/pgsql/data when prefix is set to /usr. (rawpkgdatadir): New directory. Its different from pkgdatadir, because thats often set to /usr/share/postgresql. * Makefile.am: Include new rawpkgdatadir Makefile.inc. Fix distcheck by mentioning legacyscripts_SCRIPTS in GENERATED_FILES. * postgresql-check-db-dir.in: Use library.sh to give user better advice. Use @NAME_BINARYBASE@ prefix. (bad_version): New function. (PREVMAJORVERSION): Removed unused variable. * postgresql-setup.in: Cut out the config-parsing routines into library.sh. * share/postgresql-setup/library.sh.in: New library file. Added new option 'list' for parse_upgrade_setup. * share/postgresql-setup/Makefile.inc: New file. * share/postgresql-setup/.gitignore: Ignore library.sh.
* configury: another scl-izing commitPavel Raiskup2015-02-271-3/+3
| | | | | | | | | | | | | | | | | | | | | | | * Makefile.am: Move systemd directory definitions into configure.ac. This is then easily configurable via config.site. * configure.ac (PGENGINE, PG_CTL_BIN): Remove, bindir is sufficient. (PREVMAJORVERSION, PREVPGENGINE): Removed. It si configurable now. (INIDB_SCLS): Generalize into SCLS variable. (SCLS): Moved from INIDB_SCLS. (PGDATADIR): Default changed to have ${prefix} inside. (SED_RULES): Remove unused variables (or to not be used, TODO for next commit). (conf_dir): New macro to define config.site friendly directory variable. (SCL_SHELL_WRAPPER): Convenient macro to generate appropriate call to scl binary (only when building for software collections). * postgresql-check-db-dir.in: Use new variable layout. * postgresql-ctl.in: Likewise. * postgresql-setup.in: Likewise. * postgresql.service.in: Likewise. This fixes regression of not using ${bindir} properly.
* configury: add INITDB_SCLS variablePavel Raiskup2015-02-271-1/+10
| | | | | | | | | | This brings space separated list of Software Collections to be enabled with call to 'initdb' binary. * configure.ac (INITDB_SCLS): New variable. * postgresql-setup.in ($initdb_scls): New global. (perform_initdb): Source appropriate environment based on $initdb_scls content.
* configury: add NAME_DEFAULT_PREV_SERVICE variablePavel Raiskup2015-02-271-1/+1
| | | | | | | | | | We may want to configure postgresql-setup to upgrade from SCL version of PostgreSQL, which needs to read 'postgresql92-postgresq' service files. Defaults to 'postgresql'. * configure.ac (NAME_DEFAULT_PREV_SERVICE): New configure var. * postgresql-setup.in ($option_upgradefrom): Default to NAME_DEFAULT_PREV_SERVICE contents.
* configuration: SCL hacksPavel Raiskup2015-02-261-2/+38
| | | | | | | | | | | | | | | Its now configurable what software collections will be enabled for pg_upgrade run, in case it is needed (new 'scls' option). Similarly, pg_upgrade needs to be told to send unix_socket_directories instead of unix_socket_directory to PostgreSQL server built for RHEL. * etc/postgresql-setup/upgrade/postgresql.conf: Add configuration examples for new options. * postgresql-setup.in (parse_upgrade_setup): Parse 'scls' and 'redhat_sockets_hack' options. (upgrade): Adjust the environment of 'su - postgres' call to pg_upgrade, optionally.
* configuration: define upgrade-config directoryPavel Raiskup2015-02-261-37/+60
| | | | | | | | | | | | | | | | | | | | Currently under /etc/postgresql-setup/upgrade. All '*.conf' files are going to be loaded run-time by postgresql-setup. * postgresql-setup.in (read_config_file): New helper to safely read configuration files. (set_var): Remove comment. (parse_upgrade_setup): Use new read_config_file(). (parse_configuration): Rename to service_configuration(). * Makefile.am: Don't include share/Makefile.inc. Indent fixes. Add install-data-hook helper to install config directory. * build-helpers/Makefile.inc: Removed. * build-helpers/build-config: Likewise. * upgrade_config.template: Removed. * etc/postgresql-setup/upgrade/postgresql.conf: New template. * configure.ac: Remove --with-upgrade-config. Package maintainers are supposed to provide those for now. * share/postgresql-setup/Makefile.inc: Removed.
* configury: remove DISTSUFF variable completelyPavel Raiskup2015-02-261-11/+12
| | | | | | | | | | | | | | | | | | | | | And add NAME_SERVICE, NAME_PACKAGE and NAME_BINARYBASE on its place. This allows packager fine-tune how the files are going to be generated. * Makefile.am: Better work with variables. * .gitignore: Ignore any (generated) service file. * configure.ac (DISTSUFF): Remove. (NAME_BIN_PFX, NAME_BIN_SFX, NAME_PKG_PFX, NAME_PKG_SFX) (NAME_SRV_PFX, NAME_SRV_SFX, NAME_SERVICE, NAME_PACKAGE) (NAME_BINARYBASE): New variables * doc/.gitignore: Ignore any man(1) page. * doc/Makefile.am (HELP2MAN_RUN): Fix the call to work also with various prefixes/suffixes. * README.rpm-dist.in: Use new variables. * legacy-sysv-script.in: Likewise. * postgresql-setup.in: Likewise. * m4/packaging.m4 (PGSETUP_SUBST_OPT): New macro, defines, substitutes and also fixes sed-rules.
* postgresql-setup: multi-upgrade configurationPavel Raiskup2015-02-251-55/+165
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Turns out we need to support upgrade from more than one previous database versions. The plan is to make this as general as easily possible, "run-time" configurable without need to recompile. * postgresql-setup.in: Add options --upgrade-from and --upgrade-ids. Require root access (as late as possible). ($USAGE_STRING): Adjust help output accordingly. ($PGMAJORVERSION, $PREVMAJORVERSION) ($PREVPGENGINE): Remove newly useless globals. ($option_upgradefrom): New option default. (set_var, root_prereq): New helper functions. (parse_upgrade_setup): Helper function to parse upgrade configuration. (print_version): Don't print PREVMAJORVERSION as it is (with configuration) useless. (upgrade): Create new $inplace local to handle in-place and copy-like migrations differently. Use the variable set generated by parse_upgrade_setup() function. Small err message fixes. (handle_service_env, handle_pgconf): Remove the MODE argument. (parse_configuration): Generalize operations which needed to be done on two places. * upgrade_config.template: Example of ./configure time config file. Based on files like this the run-time is generated. * share/postgresql-setup/.gitignore: New file. * share/postgresql-setup/Makefile.inc: New file. * build-helpers/build-config: New file, generator of configuration files. * build-helpers/Makefile.inc: New file. * Makefile.am: Distribute upgrade_config.template. Start the conversion to flat Makefile and include two new Makefile.inc snippets. * configure.ac: New --with-upgrade-config option. Propagate the rawpkgdatadir and UPGRADE_CONFIG_LIST variables into Makefile. (INSTANTIATE): Enhance to create the leading path also. (INSTANTIATE_CONV): Convenience helper for leading path of target creation. * auxdir/install_local: New (just-for-git) installation helper. * .gitignore: Don't hide share/postgresql-setup. * TODO: Mention that KDE folks would like to migrate somehow.
* postgresql-setup: fix version in --version outputPavel Raiskup2015-02-101-7/+4
| | | | | | | | | | | And better spell errors (to let user know that the initdb_log may not exist). * postgresql-setup.in (print_version): Use "full" @PGVERSION@ and @PREVMAJORVERSION@.X to better describe what the package is configured for. (initdb): Spell better the failure message. * postgresql-setup.in: Use $* instead of $@.
* configury: use one single variable SU_POSTGRESPavel Raiskup2015-02-101-5/+4
| | | | | | | | | | | | We use 'su' only for 'postgres' user purposes. So have one, configure-time-proven command. Also, in the previous commit I forgot to fix sysvinit file. * configure.ac (SU_POSTGRES): New variable. * postgresql-setup.in ($SU_POSTGRES): Use detected @SU_POSTGRES@. ($SU, $SU_L_POSTGRES): Avoid usage of those. * postgresql.init.in: Likewise. * .gitignore: Remove typoed ignore.
* postgresql-setup: mention login shell explicitlyPavel Raiskup2015-02-101-2/+4
| | | | | | | | | | | | | | The setup script was reported to not work if user 'postgres' has /sbin/nologin in /etc/passwd (explicitly set by administrator). This configuration does not seem to be terribly useful but there is no need to fail at all. Resolves: rhbz#1122143 * postgresql-setup.in ($SU_L_POSTGRES): New wrapping variable, using '-s /bin/sh' to bypass /sbin/nologin. This option should be supported both by 'su' and 'runuser'. * NEWS: Document.
* postgresql-setup: use --username for pg_upgrade 9.4+Pavel Raiskup2014-12-181-1/+1
| | | | | | | | | | | | | The --user option still works but we should be rather careful for the future. Master only. References: http://www.postgresql.org/docs/9.4/static/release-9-4.html * configure.ac (AC_INIT): Bump to 3.0~dev version. (PG_UPGRADE_BIN_USER_OPT): New variable carrying the right format of pg_upgrade's username option. * postgresql-setup.in (upgrade): Use @PG_UPGRADE_BIN_USER_OPT@.
* docs: fix typo in postgresql-setup --helpPavel Raiskup2014-09-221-1/+1
| | | | | * postgresql-setup.in (USAGE_STRING): Remove brackets around mandatory option argument.
* docs: adjust --help output and warning hintsPavel Raiskup2014-09-191-19/+27
| | | | | | * postgresql-check-db-dir.in: Just fix typos. * postgresql-setup.in: Reorganize --help. * TODO: Adjust after some time.
* postgresql-setup: opt --new-systemd-unit, --datadirPavel Raiskup2014-09-191-13/+91
| | | | | | | | | | | | | From now, admin may run single command to instantiate secondary PostgreSQL server. * postgresql-setup.in: Reorganize a little to avoid processing of port, datadir, etc. on different places. Process new options. Also make some warnings more clear. * postgresql-setup.in (warn_q, info_q): New echo wrappers. (generate_systemd_dropin): New function. (USAGE_STRING): Document new options. * NEWS: Document changes.
* postgresql-setup: detect systemd's NeedDaemonReloadprep-1Pavel Raiskup2014-09-181-0/+9
| | | | | | | | | | | Because we rely on parsing of `systemctl show -p` outuput heavily, we need to detect whether the service file or some dropin did not change (or was not added). So from now we rather instruct admin to do daemon-reload when something changed.. * postgresql-setup.in: Detect the NeedDaemonReload and warn if yes. * NEWS: Document.
* postgresql-setup: leftovers, user feelingPavel Raiskup2014-09-181-7/+10
| | | | | | | | * postgresql-setup.in (USAGE_STRING): Mention --port option. (initdb): Mention in info output the non-standard port, when used. * postgresql-setup.in: Do not throw the default-port message always, remved remaining sysconfig leftover. * NEWS: Mention that env files are now supported.
* postgresql-setup: don't expect /etc/postgresql/* existsPavel Raiskup2014-09-161-42/+57
| | | | | | | | That concept was against systemd intentions. From now we should stop using .include statement in service files and encourage people using the systemd's drop-in feature. That complicates things a little, at least until the rhbz#1139148 is not resolved somehow.
* postgresql-setup: --upgrade std{out,err} adjustedPavel Raiskup2014-07-031-12/+8
| | | | | | | | | | | | Use the echo wrappers also in --upgrade. Previously, e.g. when PGDATA pointed to directory without SELinux label, the output from postgresql-setup --upgrade was broken by warnings from restorecon: # postgresql-setup --upgrade --service postgresql@SUFFIX Upgrading database: /sbin/restorecon: Warning no default label for /tmp/data /sbin/restorecon: Warning no default label for /tmp/data/pg_log OK
* upgrade/initdb logs: diverge among service namesPavel Raiskup2014-07-031-20/+20
| | | | | | Generate separate log file for each service. Also, don't configure with INITDB_LOG or UPGRADE_LOG but rather with POSTGRES_HOME.
* postgresql-setup: expect '--port 5432' implictlyPavel Raiskup2014-07-031-15/+28
| | | | | | | | .. only when '--unit=postgresql'. When user specifies --unit=postgresql@unitname, the --port is still required. Also, don't adjust the 'port = ' configuration in postgresql.conf when not necessary.
* Generate postgresql.service and configuration filePavel Raiskup2014-07-011-1/+1
|
* postgresql-ctl, DISTSUFF: introducePavel Raiskup2014-07-011-1/+1
| | | | | | | | | | | | We need postgresql-ctl for to keep backward compatibility with clients setting "PGPORT" directly in service file. DISTSUFF variable (which is read by ./configure) may be used to generated namespaced binary names -- e.g. DISTSUFF=93 results in postgresql93-setup is generated instead of postgresql-setup. This commit also adjusts autotools build system to not generate scripts by ./configure, but rather by make.
* docs: update option documentation and generate manPavel Raiskup2014-07-011-10/+33
|
* postgresql-setup: code movementPavel Raiskup2014-07-011-224/+235
| | | | | | This commit just moves the function at the top of postgresqk.setup.in file. Sorry for breaking history a little, juse "git blame -C" for analysing.
* configury: prepare for autotoolsPavel Raiskup2014-07-011-0/+472