Advertisement
Nocifer

zoneminder.install

Sep 16th, 2018
371
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.72 KB | None | 0 0
  1. post_install() {
  2.  
  3.     echo
  4.    
  5.     ### MariaDB
  6.    
  7.     # Initialize default database
  8.     # 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
  9.     systemctl is-active --quiet mariadb && systemctl stop mariadb
  10.     mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
  11.     systemctl enable --now mariadb
  12.    
  13.     echo
  14.     echo ---------------
  15.     echo
  16.     echo MariaDB will now ask you *twice* for its root user\'s password.
  17.     echo
  18.     echo If this is a fresh MariaDB install and you do not have a root password,
  19.     echo leave the \"Enter password:\" prompt empty and just press \'Enter\' to continue.
  20.     echo
  21.     echo After this setup is finished, you should run \'mysql_secure_installation\'
  22.     echo in order to set a password for MariaDB\'s root user \(among other things\).
  23.     echo
  24.    
  25.     # Create ZoneMinder's database & user
  26.     # NOTE: This should probably take into account the possibility of the database already being in place from a previous ZoneMinder install, and will need some way of upgrading it instead of trying to recreate it (which will possibly cause some issues). Until then, please do not upgrade an already existing database, rather, make a backup of the current database, delete the original and let this script create a new one from scratch. Or, if you so wish, you can let this script fail and then upgrade your database by hand.
  27.     # NOTE 2: I removed the post_install call that used to reside inside post_upgrade (nothing here should need to be run when upgrading, and apparently zmupdate.pl takes care of all the required internal legwork) so this step shouldn't cause any issues anymore because it simply won't run on subsequent upgrades.
  28.     mysql -uroot -p < /usr/share/zoneminder/db/zm_create.sql
  29.     mysql -uroot -p -e "grant select,insert,update,delete,create,alter,index,lock tables on zm.* to 'zmuser'@localhost identified by 'zmpass';"
  30.  
  31.    
  32.    
  33.     ###PHP-FPM
  34.    
  35.     # Set local timezone in /etc/php/conf.d/zoneminder.ini
  36.     sed -i 's|UTC|'`timedatectl | grep "Time zone" | tr -s ' ' | cut -f4 -d ' '`'|g' /etc/php/conf.d/zoneminder.ini
  37.     systemctl is-active --quiet nginx && systemctl stop php-fpm
  38.     systemctl enable --now php-fpm
  39.    
  40.    
  41.    
  42.     ### Nginx
  43.    
  44.     # Configure it with the folder structure used in Debian-based distributions
  45.     sed -i 's|http {|http {\'$'\n    include       sites-enabled/*.conf;|g' /etc/nginx/nginx.conf
  46.     systemctl is-active --quiet nginx && systemctl stop nginx
  47.     systemctl enable --now nginx
  48.    
  49.    
  50.    
  51.     ### fcgiwrap
  52.    
  53.     systemctl is-active --quiet fcgiwrap.socket && systemctl stop fcgiwrap.socket && systemctl stop fcgiwrap
  54.     systemctl enable --now fcgiwrap.socket
  55.    
  56.    
  57.    
  58.     ### ZoneMinder
  59.    
  60.     # Also activate the tmpfile to create runtime directories
  61.     systemctl is-active --quiet zoneminder && systemctl stop zoneminder
  62.     systemd-tmpfiles --create
  63.     systemctl enable --now zoneminder
  64.    
  65.     echo
  66.     echo Done!
  67.     echo
  68.     echo If all went as it should, you should now be able to visit http://localhost:8095 and start using ZoneMinder.
  69.     echo
  70. }
  71.  
  72. post_upgrade() {
  73.     # Don't know if '-f /dev/null' is still needed or not...
  74.     /usr/bin/zmupdate.pl -f /dev/null
  75. }
  76.  
  77. post_remove() {
  78.  
  79.     echo
  80.     echo The ZoneMinder database has been left intact. You can either manually delete the whole \'/var/lib/mysql\' directory or,
  81.     echo if you still need MariaDB installed for other purposes, remove the ZoneMinder database and user by running the following:
  82.     echo
  83.     echo mysql -uroot -p -e \"drop database zm\;\"
  84.     echo mysql -uroot -p -e \"drop user \'zmuser\'@localhost\;\"
  85.     echo
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement