2014-01-27 22:39:59 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
2016-02-01 19:35:45 +08:00
|
|
|
# Prepare proper amount of shared memory
|
|
|
|
umount /dev/shm
|
|
|
|
mount -t tmpfs -o rw,nosuid,nodev,noexec,relatime,size=2048M tmpfs /dev/shm
|
|
|
|
|
2014-01-27 22:39:59 +08:00
|
|
|
# Start MySQL
|
|
|
|
/usr/bin/mysqld_safe &
|
2014-04-18 14:41:18 +08:00
|
|
|
|
|
|
|
# Give MySQL time to wake up
|
|
|
|
SECONDS_LEFT=120
|
|
|
|
while true; do
|
|
|
|
sleep 1
|
|
|
|
mysqladmin ping
|
|
|
|
if [ $? -eq 0 ];then
|
|
|
|
break; # Success
|
|
|
|
fi
|
|
|
|
let SECONDS_LEFT=SECONDS_LEFT-1
|
|
|
|
|
|
|
|
# If we have waited >120 seconds, give up
|
|
|
|
# ZM should never have a database that large!
|
|
|
|
# if $COUNTER -lt 120
|
|
|
|
if [ $SECONDS_LEFT -eq 0 ];then
|
|
|
|
return -1;
|
|
|
|
fi
|
|
|
|
done
|
2014-01-27 22:39:59 +08:00
|
|
|
|
|
|
|
# Create the ZoneMinder database
|
|
|
|
mysql -u root < db/zm_create.sql
|
|
|
|
|
|
|
|
# Add the ZoneMinder DB user
|
2014-01-27 23:20:20 +08:00
|
|
|
mysql -u root -e "grant insert,select,update,delete,lock tables,alter on zm.* to 'zm'@'localhost' identified by 'zm'"
|
2014-01-27 22:39:59 +08:00
|
|
|
|
2016-02-01 19:35:45 +08:00
|
|
|
# Activate CGI
|
|
|
|
a2enmod cgi
|
|
|
|
|
2014-01-27 22:39:59 +08:00
|
|
|
# Restart apache
|
|
|
|
service apache2 restart
|
|
|
|
|
|
|
|
# Start ZoneMinder
|
|
|
|
/usr/local/bin/zmpkg.pl start
|
2014-01-28 03:03:51 +08:00
|
|
|
|
|
|
|
# Start SSHD
|
|
|
|
/usr/sbin/sshd -D
|