Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- post_install() {
- echo
- ### MariaDB
- # Initialize default database
- # 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
- systemctl is-active --quiet mariadb && systemctl stop mariadb
- mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
- systemctl enable --now mariadb
- echo
- echo ---------------
- echo
- echo MariaDB will now ask you *twice* for its root user\'s password.
- echo
- echo If this is a fresh MariaDB install and you do not have a root password,
- echo leave the \"Enter password:\" prompt empty and just press \'Enter\' to continue.
- echo
- echo After this setup is finished, you should run \'mysql_secure_installation\'
- echo in order to set a password for MariaDB\'s root user \(among other things\).
- echo
- # Create ZoneMinder's database & user
- # 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.
- # 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.
- mysql -uroot -p < /usr/share/zoneminder/db/zm_create.sql
- mysql -uroot -p -e "grant select,insert,update,delete,create,alter,index,lock tables on zm.* to 'zmuser'@localhost identified by 'zmpass';"
- ###PHP-FPM
- # Set local timezone in /etc/php/conf.d/zoneminder.ini
- sed -i 's|UTC|'`timedatectl | grep "Time zone" | tr -s ' ' | cut -f4 -d ' '`'|g' /etc/php/conf.d/zoneminder.ini
- systemctl is-active --quiet nginx && systemctl stop php-fpm
- systemctl enable --now php-fpm
- ### Nginx
- # Configure it with the folder structure used in Debian-based distributions
- sed -i 's|http {|http {\'$'\n include sites-enabled/*.conf;|g' /etc/nginx/nginx.conf
- systemctl is-active --quiet nginx && systemctl stop nginx
- systemctl enable --now nginx
- ### fcgiwrap
- systemctl is-active --quiet fcgiwrap.socket && systemctl stop fcgiwrap.socket && systemctl stop fcgiwrap
- systemctl enable --now fcgiwrap.socket
- ### ZoneMinder
- # Also activate the tmpfile to create runtime directories
- systemctl is-active --quiet zoneminder && systemctl stop zoneminder
- systemd-tmpfiles --create
- systemctl enable --now zoneminder
- echo
- echo Done!
- echo
- echo If all went as it should, you should now be able to visit http://localhost:8095 and start using ZoneMinder.
- echo
- }
- post_upgrade() {
- # Don't know if '-f /dev/null' is still needed or not...
- /usr/bin/zmupdate.pl -f /dev/null
- }
- post_remove() {
- echo
- echo The ZoneMinder database has been left intact. You can either manually delete the whole \'/var/lib/mysql\' directory or,
- echo if you still need MariaDB installed for other purposes, remove the ZoneMinder database and user by running the following:
- echo
- echo mysql -uroot -p -e \"drop database zm\;\"
- echo mysql -uroot -p -e \"drop user \'zmuser\'@localhost\;\"
- echo
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement