Annotation of pkgsrc/databases/postgresql14-server/files/pgsql.sh, revision 1.1

1.1     ! adam        1: #!@RCD_SCRIPTS_SHELL@
        !             2: #
        !             3: # $NetBSD: pgsql.sh,v 1.1 2020/10/18 09:24:03 adam Exp $
        !             4: #
        !             5: # PostgreSQL database rc.d control script
        !             6: #
        !             7: # PROVIDE: pgsql
        !             8: # REQUIRE: DAEMON
        !             9: # KEYWORD: shutdown
        !            10: #
        !            11: # You will need to set some variables in /etc/rc.conf to start PostgreSQL:
        !            12: #
        !            13: # pgsql=YES
        !            14: #
        !            15: # Optionally, "pgsql_flags" contains options for the PostgreSQL postmaster, e.g.
        !            16: #      pgsql_flags="-i"                # allows TCP/IP connections
        !            17: #      pgsql_flags="-i -l"             # enables SSL connections
        !            18: #      pgsql_home="/path/to/home"      # path to pgsql database directory
        !            19: # See postmaster(1) for possible options.
        !            20: 
        !            21: if [ -f /etc/rc.subr ]; then
        !            22:        . /etc/rc.subr
        !            23: fi
        !            24: 
        !            25: name="pgsql"
        !            26: rcvar=${name}
        !            27: command="@PREFIX@/bin/pg_ctl"
        !            28: procname="@PREFIX@/bin/postgres"
        !            29: : ${pgsql_user:=@PGUSER@}
        !            30: : ${pgsql_group:=@PGGROUP@}
        !            31: : ${pgsql_home:=@PGHOME@}
        !            32: 
        !            33: extra_commands="initdb reload"
        !            34: initdb_cmd="pgsql_initdb"
        !            35: start_precmd="pgsql_precmd"
        !            36: start_cmd="pgsql_start"
        !            37: restart_precmd="pgsql_precmd"
        !            38: restart_cmd="pgsql_restart"
        !            39: stop_cmd="pgsql_stop"
        !            40: reload_cmd="pgsql_reload"
        !            41: 
        !            42: if [ -f /etc/rc.subr -a -d /etc/rc.d -a -f /etc/rc.d/DAEMON ]; then
        !            43:        load_rc_config $name
        !            44: elif [ -f /etc/rc.conf ]; then
        !            45:        . /etc/rc.conf
        !            46: fi
        !            47: 
        !            48: cd /
        !            49: 
        !            50: command_args="-w -s -D ${pgsql_home}/data -m fast -l ${pgsql_home}/errlog"
        !            51: if [ -n "${pgsql_flags}" ]; then
        !            52:        command_args="${command_args} -o \\\"${pgsql_flags}\\\""
        !            53: fi
        !            54: 
        !            55: pgsql_precmd()
        !            56: {
        !            57:        ulimit -n 4096
        !            58:        if [ ! -d ${pgsql_home}/data/base ]; then
        !            59:                pgsql_initdb
        !            60:        fi
        !            61: }
        !            62: 
        !            63: pgsql_initdb()
        !            64: {
        !            65:        if [ -d ${pgsql_home}/data/base ]; then
        !            66:                @ECHO@ "The PostgreSQL template databases have already been initialized."
        !            67:                @ECHO@ "Skipping database initialization."
        !            68:        else
        !            69:                @ECHO@ "Initializing PostgreSQL databases."
        !            70:                @MKDIR@ -p ${pgsql_home}
        !            71:                @CHOWN@ ${pgsql_user} ${pgsql_home}
        !            72:                @CHGRP@ ${pgsql_group} ${pgsql_home}
        !            73:                @CHMOD@ 0700 ${pgsql_home}
        !            74:                doit="@SU@ -m ${pgsql_user} -c '${command} init ${command_args}'"
        !            75:                eval $doit
        !            76:        fi
        !            77: }
        !            78: 
        !            79: pgsql_start()
        !            80: {
        !            81:        @ECHO@ "Starting ${name}."
        !            82:        doit="@SU@ -m ${pgsql_user} -c '${command} start ${command_args}'"
        !            83:        eval $doit
        !            84: }
        !            85: 
        !            86: pgsql_restart()
        !            87: {
        !            88:        @ECHO@ "Restarting ${name}."
        !            89:        doit="@SU@ -m ${pgsql_user} -c '${command} restart ${command_args}'"
        !            90:        eval $doit
        !            91: }
        !            92: 
        !            93: pgsql_stop()
        !            94: {
        !            95:        @ECHO@ "Stopping ${name}."
        !            96:        doit="@SU@ -m ${pgsql_user} -c '${command} stop ${command_args}'"
        !            97:        eval $doit
        !            98: }
        !            99: 
        !           100: pgsql_reload()
        !           101: {
        !           102:        @ECHO@ "Reloading ${name}."
        !           103:        doit="@SU@ -m ${pgsql_user} -c '${command} reload ${command_args}'"
        !           104:        eval $doit
        !           105: }
        !           106: 
        !           107: if [ -f /etc/rc.subr -a -d /etc/rc.d -a -f /etc/rc.d/DAEMON ]; then
        !           108:        run_rc_command "$1"
        !           109: else
        !           110:        pidfile="${pgsql_home}/data/postmaster.pid"
        !           111:        case "$1" in
        !           112:        initdb)
        !           113:                eval ${initdb_cmd}
        !           114:                ;;
        !           115:        restart)
        !           116:                eval ${restart_precmd}
        !           117:                eval ${restart_cmd}
        !           118:                ;;
        !           119:        stop)
        !           120:                if [ -r "${pidfile}" ]; then
        !           121:                        eval ${stop_cmd}
        !           122:                fi
        !           123:                ;;
        !           124:        reload)
        !           125:                eval ${reload_cmd}
        !           126:                ;;
        !           127:        *)
        !           128:                eval ${start_precmd}
        !           129:                eval ${start_cmd}
        !           130:                ;;
        !           131:        esac
        !           132: fi

CVSweb <webmaster@jp.NetBSD.org>