Milí majitelé routerů Turris,
toto fórum bylo 9. 12. 2016 zmrazeno a nahrazeno naším novým Turris fórem. Ještě chvíli bude dostupné k prohlížení, ale již zde není možné přispívat. Více informací naleznete v oznámení o uzavření fóra.
Dear Turris routers users,
this forum has been frozen on Dec 9th, 2016 and replaced by our new Turris forum. It will be read-only accessible for some time after. For more information, read the announcement about closing the forum.
# /usr/bin/su ${pguser} -c "/usr/bin/postmaster -D '${pgdata}' &" >> ${pglog} 2>&1 start-stop-daemon -S -c postgres -x /usr/bin/postmaster >> ${pglog} 2>&1 -- -D "${pgdata}" & # /usr/bin/su ${pguser} -c "${pgctl} stop -D '${pgdata}' -s -m fast" start-stop-daemon -S -c postgres -x "${pgctl}" -- stop -D "${pgdata}" -s -m fast
#
# Check wheather proces ID and data directory found in pidfile
# is running. Return 0 if no postgres process working on ${pgdata} was found
#
checkNoActivePG() {
if [ -f ${pgdata}/postmaster.pid ]; then
PGFILEPID=$(head -1 ${pgdata}/postmaster.pid)
ps | grep $PGFILEPID | grep -v grep | grep -q "${pgdata}" && return 1
fi
# check for PG working on data directory regardless pidfile exists
ps | grep -v grep | grep -q "${pgdata}" && return 2
return 0
}
echo "starting postgres..."
date "+%Y%M%d %H:%M:%S%tStarting postgres" >> ${pglog}
chmod a+w /dev/null
# avoid attempt to start Postgres if it already runs, thus
# do not delete postmater.pid file so future shutdown command
# will not fail due to pid file absence
checkNoActivePG
if ! checkNoActivePG; then
echo "It seems that postgres is running, check it manually."
exit 1
fi
# /usr/bin/su ${pguser} -c "/usr/bin/postmaster -D '${pgdata}' &" >> ${pglog} 2>&1
start-stop-daemon -S -c postgres -x "${pgctl}" >> ${pglog} 2>&1 -- start -D "${pgdata}"
date "+%Y%M%d %H:%M:%S%tStarting postgres finished with ret: ${ret}" >> ${pglog}
date "+%Y%M%d %H:%M:%S%tStopping postgres" >> ${pglog}
/usr/bin/su ${pguser} -c "${pgctl} stop -D '${pgdata}' -s -m fast"
start-stop-daemon -S -c postgres -x "${pgctl}" >> ${pglog} 2>&1 -- start -D "${pgdata}"
date "+%Y%M%d %H:%M:%S%tStopping postgres finished with ret: ${ret}" >> ${pglog}
root@turris:/mnt/microSD/turris_backup# diff /etc/init.d/postgresql postgresql_default_init 13,26d12 < # < # Check wheather proces ID and data directory found in pidfile < # is running. Return 0 if no postgres process working on ${pgdata} was found < # < checkNoActivePG() { < if [ -f ${pgdata}/postmaster.pid ]; then < PGFILEPID=$(head -1 ${pgdata}/postmaster.pid) < ps | grep $PGFILEPID | grep -v grep | grep -q "${pgdata}" && return 1 < fi < # check for PG working on data directory regardless pidfile exists < ps | grep -v grep | grep -q "${pgdata}" && return 2 < return 0 < } < 39d24 < date "+%Y%M%d %H:%M:%S%tStarting postgres" >> ${pglog} 46,54d30 < # avoid attempt to start Postgres if it already runs, thus < # do not delete postmater.pid file so future shutdown command < # will not fail due to pid file absence < checkNoActivePG < if ! checkNoActivePG; then < echo "It seems that postgres is running, check it manually." < exit 1 < fi < 63,65c39 < # /usr/bin/su ${pguser} -c "/usr/bin/postmaster -D '${pgdata}' &" >> ${pglog} 2>&1 < # start-stop-daemon -S -c postgres -x /usr/bin/postmaster >> ${pglog} 2>&1 -- -D "${pgdata}" & < start-stop-daemon -S -c postgres -x "${pgctl}" >> ${pglog} 2>&1 -- start -D "${pgdata}" --- > /usr/bin/su ${pguser} -c "/usr/bin/postmaster -D '${pgdata}' &" >> ${pglog} 2>&1 84d57 < date "+%Y%M%d %H:%M:%S%tStarting postgres finished with ret: ${ret}" >> ${pglog} 90,92c63 < date "+%Y%M%d %H:%M:%S%tStopping postgres" >> ${pglog} < # /usr/bin/su ${pguser} -c "${pgctl} stop -D '${pgdata}' -s -m fast" < start-stop-daemon -S -c postgres -x "${pgctl}" >> ${pglog} 2>&1 -- stop -D "${pgdata}" -m fast --- > /usr/bin/su ${pguser} -c "${pgctl} stop -D '${pgdata}' -s -m fast" 98d68 < date "+%Y%M%d %H:%M:%S%tStopping postgres finished with ret: ${ret}" >> ${pglog} 104,106c74 < date "+%Y%M%d %H:%M:%S%tRestarting postgres - stop" >> ${pglog} < # /usr/bin/su ${pguser} -c "${pgctl} stop -D '${pgdata}' -s -m fast -w" < start-stop-daemon -S -c postgres -x "${pgctl}" >> ${pglog} 2>&1 -- stop -D "${pgdata}" -m fast --- > /usr/bin/su ${pguser} -c "${pgctl} stop -D '${pgdata}' -s -m fast -w" 110,112c78 < date "+%Y%M%d %H:%M:%S%tRestarting postgres - start" >> ${pglog} < # /usr/bin/su ${pguser} -c "/usr/bin/postmaster -D '${pgdata}' &" >> ${pglog} 2>&1 < start-stop-daemon -S -c postgres -x "${pgctl}" >> ${pglog} 2>&1 -- start -D "${pgdata}" --- > /usr/bin/su ${pguser} -c "/usr/bin/postmaster -D '${pgdata}' &" >> ${pglog} 2>&1 114,115c80 < date "+%Y%M%d %H:%M:%S%tRestarting postgres finished." >> ${pglog} < # return $? --- > return $? 120,123c85 < date "+%Y%M%d %H:%M:%S%tReloading postgres" >> ${pglog} < # /usr/bin/su ${pguser} -c "${pgctl} reload -D '${pgdata}' -s" < start-stop-daemon -S -c postgres -x "${pgctl}" >> ${pglog} 2>&1 -- reload -D "${pgdata}" < date "+%Y%M%d %H:%M:%S%tReloading postgres finished." >> ${pglog} --- > /usr/bin/su ${pguser} -c "${pgctl} reload -D '${pgdata}' -s" 129,132c91 < # date "+%Y%M%d %H:%M:%S%tStatus postgres" >> ${pglog} < # /usr/bin/su ${pguser} -c "${pgctl} status -D '${pgdata}'" < start-stop-daemon -S -c postgres -x "${pgctl}" -- status -D "${pgdata}" < checkNoActivePG || echo "Running postgres process with cluster ${pgdata} was found." --- > /usr/bin/su ${pguser} -c "${pgctl} status -D '${pgdata}'"
Powered by mwForum 2.29.3 © 1999-2013 Markus Wichitill