Changeset 10222


Ignore:
Timestamp:
2008-01-18T19:16:08+01:00 (10 years ago)
Author:
pavlov
Message:

clean up postgresql init script to their recommended practices

File:
1 edited

Legend:

Unmodified
Added
Removed
  • packages/libs/postgresql/files/postgresql.init

    r7518 r10222  
    22# Copyright (C) 2006 OpenWrt.org 
    33START=50 
     4 
     5EXTRA_COMMANDS="status reload" 
    46 
    57config_load "postgresql" 
     
    79config_get pguser config PGUSER 
    810config_get pgctl config PG_CTL 
     11config_get pglog config PGLOG 
    912 
    1013start() { 
     
    1922    fi 
    2023 
     24    echo "starting postgres..." 
    2125    # make sure localhost (without a dot) is in /etc/hosts 
    2226    grep -q 'localhost$' /etc/hosts || echo '127.0.0.1 localhost' >> /etc/hosts 
     
    2933    fi 
    3034 
    31     config_get pglog config PGLOG 
    3235    config_get pgopts config PGOPTS 
    3336    if [ -n "${pgopts}" ]; then 
    3437        pgopts="-o ${pgopts}" 
    3538    fi 
    36     /bin/su ${pguser} -c "${pgctl} start -D ${pgdata} -s -l ${pglog} ${pgopts}" 
     39    /bin/su ${pguser} -c "/usr/bin/postgres -D '${pgdata}' &" >> ${pglog} 2>&1 
    3740 
    3841    while : 
     
    4245            ret=0 
    4346            break 
    44         fi 
     47        fi 
    4548 
    4649        if [ ${cnt} -eq 30 ]; then 
     
    5255    done 
    5356 
     57    echo "ok" 
    5458    return ${ret} 
    5559} 
    5660 
    5761stop() { 
     62    echo "stopping postgres..." 
     63    /bin/su ${pguser} -c "${pgctl} stop -D '${pgdata}' -s -m fast" 
     64    ret=$? 
     65    if [ -f ${pgdata}/postmaster.pid ]; then 
     66        rm ${pgdata}/postmaster.pid 
     67    fi 
     68    echo "ok" 
     69    return ${ret} 
     70} 
    5871 
    59     /bin/su ${pguser} -c "${pgctl} stop -D '${pgdata}'" 
     72restart() { 
     73    echo "restarting postgres..." 
     74    /bin/su ${pguser} -c "${pgctl} stop -D '${pgdata}' -s -m fast -w" 
     75    if [ -f ${pgdata}/postmaster.pid ]; then 
     76        rm ${pgdata}/postmaster.pid 
     77    fi 
     78    /bin/su ${pguser} -c "/usr/bin/postgres -D '${pgdata}' &" >> ${pglog} 2>&1 
     79    echo "ok" 
    6080    return $? 
    6181} 
     82 
     83reload() { 
     84    echo "reloading postgres..." 
     85    /bin/su ${pguser} -c "${pgctl} reload -D '${pgdata}' -s" 
     86    echo "ok" 
     87} 
     88 
     89status() { 
     90    echo "status postgres..." 
     91    /bin/su ${pguser} -c "${pgctl} status -D '${pgdata}'" 
     92    echo "ok" 
     93} 
Note: See TracChangeset for help on using the changeset viewer.