Update zoneminder-install.sh

Fix mysql crash
This commit is contained in:
connorjfarrell 2025-01-21 22:01:29 -06:00 committed by GitHub
parent 445baab1ef
commit 3b4b895361
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -26,25 +26,30 @@ $STD apt-get install -y \
libapache2-mod-php libapache2-mod-php
msg_ok "Installed Dependencies" msg_ok "Installed Dependencies"
# Install / set up MySQL # create a random password for root
msg_info "Install / set up MySQL" # create a random password for the 'zmuser'
APPLICATION="ZoneMinder" msg_info "Pre-seeding dbconfig-common for ZoneMinder"
APP_NAME="ZoneMinder"
DB_NAME="zm"
DB_USER="zmuser"
DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13)
$STD mysql -u root -e "CREATE DATABASE $DB_NAME;" ROOT_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13)
$STD mysql -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED WITH mysql_native_password AS PASSWORD('$DB_PASS');" ZMPASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13)
$STD mysql -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;"
export DEBIAN_FRONTEND=noninteractive
echo "zoneminder zoneminder/dbconfig-install boolean true" | debconf-set-selections
echo "zoneminder zoneminder/dbconfig-reinstall boolean false" | debconf-set-selections
echo "zoneminder zoneminder/mysql/admin-user string root" | debconf-set-selections
echo "zoneminder zoneminder/mysql/admin-pass password $ROOT_PASS" | debconf-set-selections
echo "zoneminder zoneminder/mysql/app-pass password $ZMPASS" | debconf-set-selections
echo "zoneminder zoneminder/app-password-confirm password $ZMPASS"| debconf-set-selections
{ {
echo "Database Credentials" echo "ZoneMinder Database Credentials"
echo "Database User: $DB_USER" echo "MySQL Root Password: $ROOT_PASS"
echo "Database Password: $DB_PASS" echo "ZoneMinder DB User: zmuser"
echo "Database Name: $DB_NAME" echo "ZoneMinder DB Pass: $ZMPASS"
} >> ~/$APP_NAME.creds echo "ZoneMinder DB Name: zm"
msg_ok "MySQL setup completed" } >> ~/zoneminder.creds
msg_ok "dbconfig pre-seeding complete"
# Enable the ZoneMinder PPA (iconnor/zoneminder-1.36) and install # Enable the ZoneMinder PPA (iconnor/zoneminder-1.36) and install
msg_info "Enabling ZoneMinder PPA and installing ZoneMinder" msg_info "Enabling ZoneMinder PPA and installing ZoneMinder"