install_db() { . /etc/systemconfig if [ $SystemType = Master_backend -o $SystemType = Standalone ] then mysql -e "use zm" > /dev/null rc=$? if [ $rc = 1 ] then echo "Installing zoneminder database zm" cat /usr/share/zoneminder/db/zm_create.sql | mysql echo 'grant lock tables, alter,select,insert,update,delete on zm.* to 'zmuser'@localhost identified by "zmpass";' | mysql fi else echo "Will only init the database for StandAlone or Master_backend LinHES systems" fi } pre_install() { set -e abort=false if [ -L /data/srv/http/zoneminder/events ]; then l=$(readlink /data/srv/http/zoneminder/events) if [ $l != /var/cache/zoneminder/events ]; then abort=true fi fi if [ -L /data/srv/http/zoneminder/images ]; then l=$(readlink /data/srv/http/zoneminder/images) if [ $l != /var/cache/zoneminder/images ]; then abort=true fi fi if [ $abort = true ]; then cat >&2 << EOF Aborting installation of zoneminder due to non-default symlinks in /data/srv/http/zoneminder for the images and/or events directory, which could result in loss of data. Please move your data in each of these directories to /var/cache/zoneminder before installing zoneminder from the package. EOF exit 1 fi exit 0 } post_install() { if [[ -d /var/log/zoneminder ]]; then chmod 0755 /var/log/zoneminder chown http.http /var/log/zoneminder else mkdir -m 0755 /var/log/zoneminder chown http.http /var/log/zoneminder fi if [[ -d /tmp/zm ]]; then chmod 0700 /tmp/zm chown http.http /tmp/zm else mkdir -m 0700 /tmp/zm chown http.http /tmp/zm fi #---LinHES Stuff usermod -G video http install_db gen_light_include.py /sbin/sv hup /service/lighttpd #--- } post_upgrade() { post_install /usr/bin/zmupdate.pl -f >/dev/null } post_remove() { if [[ -d /tmp/zoneminder ]]; then rm -vr /tmp/zoneminder fi #---LinHES Stuff gen_light_include.py /sbin/sv hup /service/lighttpd #-- }