mirror of
https://github.com/motioneye-project/motioneyeos.git
synced 2025-07-29 06:06:32 +00:00
Add postgresql init script
This commit is contained in:
parent
ccaf32fe2a
commit
29541688bf
@ -208,6 +208,7 @@ rm -f ${TARGET}/etc/init.d/S20urandom
|
|||||||
rm -f ${TARGET}/etc/init.d/S49ntp
|
rm -f ${TARGET}/etc/init.d/S49ntp
|
||||||
rm -f ${TARGET}/etc/init.d/S50sshd
|
rm -f ${TARGET}/etc/init.d/S50sshd
|
||||||
rm -f ${TARGET}/etc/init.d/S50proftpd
|
rm -f ${TARGET}/etc/init.d/S50proftpd
|
||||||
|
rm -f ${TARGET}/etc/init.d/S50postgresql
|
||||||
rm -f ${TARGET}/etc/init.d/S50redis
|
rm -f ${TARGET}/etc/init.d/S50redis
|
||||||
rm -f ${TARGET}/etc/init.d/S80dhcp-relay
|
rm -f ${TARGET}/etc/init.d/S80dhcp-relay
|
||||||
rm -f ${TARGET}/etc/init.d/S80dhcp-server
|
rm -f ${TARGET}/etc/init.d/S80dhcp-server
|
||||||
|
69
board/common/overlay/etc/init.d/S72postgresql
Executable file
69
board/common/overlay/etc/init.d/S72postgresql
Executable file
@ -0,0 +1,69 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
BOOT_CONF="/boot/postgresql.conf"
|
||||||
|
SYS_CONF="/etc/postgresql.conf"
|
||||||
|
CONF="/data/etc/postgresql.conf"
|
||||||
|
|
||||||
|
PROG="/usr/bin/pg_ctl"
|
||||||
|
|
||||||
|
DB_DIR="/var/lib/postgresql"
|
||||||
|
USER="postgres"
|
||||||
|
LOG="/var/log/postgresql.log"
|
||||||
|
|
||||||
|
|
||||||
|
function run_pg_ctl() {
|
||||||
|
su ${USER} -c "pg_ctl $*"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
test -x ${PROG} || exit 0
|
||||||
|
|
||||||
|
test -n "${OS_VERSION}" || source /etc/init.d/base
|
||||||
|
|
||||||
|
prepare_conf ${CONF} ${SYS_CONF} ${BOOT_CONF}
|
||||||
|
|
||||||
|
|
||||||
|
start() {
|
||||||
|
mkdir -p ${DB_DIR}
|
||||||
|
chown -R ${USER} ${DB_DIR}
|
||||||
|
touch ${LOG}
|
||||||
|
chown ${USER} ${LOG}
|
||||||
|
|
||||||
|
if [[ ! -f ${DB_DIR}/PG_VERSION ]]; then
|
||||||
|
msg_begin "Initializing postgresql db"
|
||||||
|
run_pg_ctl initdb -s -D ${DB_DIR} &>> ${LOG}
|
||||||
|
test $? == 0 && msg_done || msg_fail
|
||||||
|
|
||||||
|
echo "include_if_exists = '/data/etc/postgresql.conf'" >> ${DB_DIR}/postgresql.conf
|
||||||
|
fi
|
||||||
|
|
||||||
|
msg_begin "Starting postgresql"
|
||||||
|
run_pg_ctl start -s -D ${DB_DIR} -l ${LOG}
|
||||||
|
test $? == 0 && msg_done || msg_fail
|
||||||
|
}
|
||||||
|
|
||||||
|
stop() {
|
||||||
|
msg_begin "Stopping postgresql"
|
||||||
|
run_pg_ctl stop -s -D ${DB_DIR} -m fast &>> ${LOG}
|
||||||
|
test $? == 0 && msg_done || msg_fail
|
||||||
|
}
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
start)
|
||||||
|
start
|
||||||
|
;;
|
||||||
|
|
||||||
|
stop)
|
||||||
|
stop
|
||||||
|
;;
|
||||||
|
|
||||||
|
restart)
|
||||||
|
stop
|
||||||
|
start
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
echo "Usage: $0 {start|stop|restart}"
|
||||||
|
exit 1
|
||||||
|
esac
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user