aboutsummaryrefslogblamecommitdiffstats
path: root/community/zoneminder/zoneminder.initd
blob: 95c61a8accb3b2820db70fa20e78f1e8c066804b (plain) (tree)
1
2
3
4
5
6
7
8
9
10
                  

                            
                                         


                         
                      

          
                     






                                             
                                                              














                                             
                                                              











                                                           
#!/sbin/openrc-run

# init.d file for zoneminder
# Copyright (c) 2013-2017 Kaarle Ritvanen

name=zoneminder
command=/usr/bin/zmpkg.pl
extra_commands="setup"

depend() {
	after mariadb
}

start() {
	ebegin "Starting $name"
	if status > /dev/null; then
		ewarn "$name already started"
	else
		zmlinkcontent.sh > /dev/null && $command start
	fi
	eend $?
}

stop() {
	ebegin "Stopping $name"
	if status > /dev/null; then
		$command stop
	else
		ewarn "$name already stopped"
	fi
	eend $?
}

status() {
	( . /etc/zm.conf && chgrp $ZM_WEB_GROUP /etc/zm.conf )
	status=$($command status)
	echo $status
	[ "$status" = running ]
}

setup() {
	. /etc/zm.conf
	ebegin "Initializing $name database"
	mysql -h $ZM_DB_HOST -u $ZM_DB_USER -p$ZM_DB_PASS \
		< $ZM_PATH_DATA/db/zm_create.sql
	eend $?
}