#!/usr/bin/bash if [ $(whoami) != "root" ]; then echo "ERROR: must be run as root or with sudo as root" exit 1 fi if [ ! -f /usr/share/doc/firefly-logger/load.sql ]; then echo "ERROR: missing /usr/share/doc/firefly-logger/load.sql" exit 1 fi if [ -e /firefly-not-installed ]; then # this is to bail out for Pi image building where /firefly-not-installed # is touched at build time so that a firstboot script can # setup the database exit 0 fi NOTRERUN=false if [ -d /var/lib/mysql/ffdl ]; then echo "This process will create the default Firefly" echo "Logger database and create a user with a" echo "randomized password for the web application" echo "(configuring the password in the webapp)." echo "" echo "WARNING! You appear to already have a MySQL" echo "database named 'ffdl'. This database WILL BE" echo "erased and the 'ffdl' user password will" echo "be changed if you continue!!" echo "" read -p "DO YOU WANT TO CONTINUE (Y/N)?? " answer case ${answer:0:1} in y|Y) NOTRERUN=true ;; *) exit 0 ;; esac fi DBPASS=$(openssl rand -hex 6) mysql -u root <