diff options
Diffstat (limited to 'zoneminder.install')
-rw-r--r-- | zoneminder.install | 104 |
1 files changed, 56 insertions, 48 deletions
diff --git a/zoneminder.install b/zoneminder.install index 2bb7e8be126f..4777e2d90a2a 100644 --- a/zoneminder.install +++ b/zoneminder.install @@ -1,25 +1,61 @@ post_install() { - systemctl daemon-reload echo + systemctl daemon-reload + + + ### Nginx ### + + # Configure it with the folder structure used in Debian-based distributions + if [ -f /etc/nginx/nginx.conf ] + then + if ( ! grep -q 'sites-enabled' /etc/nginx/nginx.conf ) + then + sed -i 's|http {|http {\'$'\n include sites-enabled/*.conf;|g' /etc/nginx/nginx.conf + fi + systemctl is-active --quiet nginx && systemctl stop nginx + systemctl start nginx + fi + + + ### PHP-FPM ### + + # Set local timezone in /etc/php/conf.d/zoneminder.ini + sed -i 's|PLACEHOLDER|'`timedatectl | grep "Time zone" | tr -s ' ' | cut -f4 -d ' '`'|g' /etc/php/conf.d/zoneminder.ini + systemctl is-active --quiet php-fpm && systemctl stop php-fpm + systemctl start php-fpm + + + ### fcgiwrap ### + + systemctl is-active --quiet fcgiwrap.socket && systemctl stop fcgiwrap.socket + systemctl is-active --quiet fcgiwrap && systemctl stop fcgiwrap + systemctl start fcgiwrap.socket + + ### MariaDB ### + systemctl is-active --quiet mariadb && systemctl stop mariadb + # Initialize MariaDB's default database if it's not already initialized if [ ! -d /var/lib/mysql/mysql ] then - systemctl is-active --quiet mariadb && systemctl stop mariadb # NOTE: This will need to be changed when MariaDB 10.2 hits the repos, as mysql_install_db has been deprecated in favor of mysqld mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql 2> /dev/null fi - systemctl is-active --quiet mariadb || systemctl start mariadb + systemctl start mariadb + + + ### ZoneMinder ### # Create ZoneMinder's database & user if they do not exist if [ ! -d /var/lib/mysql/zm ] then - # If a database root password is set + # Check for database root password if [[ "$(mysql -uroot -e "select * from mysql.user;" 2>&1)" = *"Access denied"* ]] then + # If a database root password is set echo \* Secure MariaDB installation found, please enter the database root password when prompted. echo mysql -uroot -p < /usr/share/zoneminder/db/zm_create.sql @@ -28,50 +64,19 @@ post_install() { echo mysql -uroot -p -e "grant select,insert,update,delete,create,alter,index,lock tables on zm.* to 'zmuser'@localhost identified by 'zmpass';" echo - # If a database root password is not set else + # If a database root password is not set mysql -uroot < /usr/share/zoneminder/db/zm_create.sql mysql -uroot -e "grant select,insert,update,delete,create,alter,index,lock tables on zm.* to 'zmuser'@localhost identified by 'zmpass';" fi fi - - ### PHP-FPM ### - - # Set local timezone in /etc/php/conf.d/zoneminder.ini - sed -i 's|PLACEHOLDER|'`timedatectl | grep "Time zone" | tr -s ' ' | cut -f4 -d ' '`'|g' /etc/php/conf.d/zoneminder.ini - systemctl is-active --quiet php-fpm && systemctl stop php-fpm - systemctl start php-fpm - - - ### fcgiwrap ### - - systemctl is-active --quiet fcgiwrap.socket && systemctl stop fcgiwrap.socket && systemctl stop fcgiwrap - systemctl start fcgiwrap.socket - - - ### Nginx ### - - # Configure it with the folder structure used in Debian-based distributions - if [ -f /etc/nginx/nginx.conf ] - then - if ( ! grep -q 'sites-enabled' /etc/nginx/nginx.conf ) - then - sed -i 's|http {|http {\'$'\n include sites-enabled/*.conf;|g' /etc/nginx/nginx.conf - fi - systemctl is-active --quiet nginx && systemctl stop nginx - systemctl start nginx - fi - - - ### ZoneMinder - - # Also activate the tmpfile to create runtime directories systemctl is-active --quiet zoneminder && systemctl stop zoneminder systemd-tmpfiles --create systemctl start zoneminder - echo Done! + + echo --------------- echo echo ZoneMinder is listening at http://localhost:8095 echo @@ -80,20 +85,23 @@ post_install() { post_upgrade() { post_install - # Make sure ZoneMinder is running before we attempt to use its updater - if ( systemctl is-active --quiet zoneminder ) - then - /usr/bin/zmupdate.pl -f 1> /dev/null - else - echo --------------- - echo - echo Error performing database update, zoneminder.service could not be started. Please fix any issues and manually run \'/usr/bin/zmupdater.pl -f\' - echo - fi + echo --------------- + echo + echo The ZoneMinder updater will now run. + + # Make sure ZoneMinder is *not* running before we attempt to use its updater + systemctl is-active --quiet zoneminder && systemctl stop zoneminder + /usr/bin/zmupdate.pl -f + systemctl start zoneminder + + echo + echo Update complete. + echo } post_remove() { systemctl daemon-reload && systemctl is-active --quiet zoneminder && systemctl stop zoneminder + echo echo ZoneMinder\'s database and user have been left intact. You can remove them by running the following: echo |