#!/bin/bash -e # This script runs on the Qemu image "WooTaler.img" to create a WooTaler installation. # update Debian from repos (not upgrade) echo echo '## Updating (not upgrading) Debian repos ...' apt update # upgrade system on user input echo read -e -r -p "Do you want to upgrade Debian (and do you know what you're doing)? ['y' Upgrades Debian] " -i "y" upgradeDebian if [[ -z $upgradeDebian ]] then upgradeDebian="y" fi if [[ $upgradeDebian == "y" ]] then echo echo '## Performing Debian upgrade...' apt -y upgrade else echo echo '** Good safe choice. Proceeding with installation without upgrading Debian...' fi # install some basic software echo read -e -r -p "Do you want to install imagemagick? ['y' Installs imagemagick] " -i "y" installImagemagick if [[ -z $installImagemagick ]] then installImagemagick="y" fi if [[ $installImagemagick == "y" ]] then echo echo '## Installing imagemagick...' apt install imagemagick -y else echo echo '** imagemagick not installed. You can install it later with "apt install imagemagick php-imagick"' fi # install mariaDB echo echo '## Installing mariaDB...' apt install -y mariadb-server # install software for apache2/php echo read -e -p "What minor (x.x) version of PHP are you using? " -i "7.3" phpVersion if [[ -z $phpVersion ]] then phpVersion="7.3" fi echo echo '## Installing apache2/php'$phpVersion'...' apt install -y sendmail curl apache2 php${phpVersion} php-pear php-fpm php-dev php-zip php-curl php-xmlrpc php-gd php-mysql php-mbstring php-xml libapache2-mod-php # apache2 customization echo echo "## Customizing apache2 with php ${phpVersion} for WordPress..." echo echo '--- installing apache2 modules' echo a2enmod rewrite alias proxy_fcgi php${phpVersion} proxy_fcgi setenvif echo echo '--- setting up apache2 .conf file' cp woocommerce-taler/server-build/QEMU-autobuild/wootaler-qemu.conf /etc/apache2/sites-available # enable wootaler-qemu a2ensite wootaler-qemu # remove the default apache2 config a2dissite 000-default echo echo '--- restarting apache2 now: systemctl restart apache2' systemctl restart apache2 echo echo '***** WordPress Installation *****' echo read -e -p "-- What version of WordPress will you install? " -i "5.4" wordpressVersion if [[ -z $wordpressVersion ]] then wordpressVersion="5.4" fi echo echo '-- Downloading and installing WordPress v.' $wordpressVersion' now.' wget https://wordpress.org/wordpress-$wordpressVersion.tar.gz tar -xf wordpress-$wordpressVersion.tar.gz -C /var/www chmod -R 755 /var/www/wordpress chown -R www-data:www-data /var/www/wordpress rm wordpress-$wordpressVersion.tar.gz echo echo '-- Please set some terms to use for the WordPress database (mariaDB):' echo read -e -p "---- What name will you give the WP DATABASE? " -i "wordpress" WPdbName if [[ -z $WPdbName ]] then WPdbName="wordpress" fi echo read -e -p "---- What should be the WP database USER? " -i "wordpress" WPdbUser if [[ -z $WPdbUser ]] then WPdbUser="wordpress" fi echo read -e -p "---- What should be the WP database user's PASSWORD? " -i "wordpress-pass" WPdbUserPass if [[ -z $WPdbUserPass ]] then WPdbUserPass="wordpress-pass" fi echo echo '-- Setting wp-config.php with the parameters set above.' # borrowed from https://gist.github.com/bgallagh3r/2853221 cd /var/www/wordpress #create wp config cp wp-config-sample.php wp-config.php #set database details with perl find and replace perl -pi -e "s/database_name_here/$WPdbName/g" wp-config.php perl -pi -e "s/username_here/$WPdbUser/g" wp-config.php perl -pi -e "s/password_here/$WPdbUserPass/g" wp-config.php echo echo '** wp-config.php has the DB variables' echo echo '** WordPress is installed.' echo echo '***** mariaDB Configuration *****' echo read -e -r -p "Do you want to secure the mariaDB installation? ['y' runs mysql_secure_installation] " -i "n" secureMariaDB if [[ -z $secureMariaDB ]] then secureMariaDB="n" fi if [[ $secureMariaDB == "y" ]] then mysql_secure_installation -p "" else echo echo '** Okay. Your mariaDB installtion is not secure.' fi # Create the mariaDB DB DBEXISTS=$(mysql --batch --skip-column-names -e "SHOW DATABASES LIKE '"$WPdbName"';" | grep "$WPdbName" > /dev/null; echo "$?") if [ $DBEXISTS -eq 0 ];then echo "A database with the name $WPdbName already exists. Skipping mariaDB database creation." else echo echo '-- Creating new mariaDB database '$WPdbName'...' mysql -e "CREATE DATABASE $WPdbName /*\!40100 DEFAULT CHARACTER SET utf8 */;" echo echo '** Database successfully created!' echo echo '-- Creating new user '$WPdbUser'...' mysql -e "CREATE USER $WPdbUser@localhost IDENTIFIED BY '$WPdbUserPass';" echo echo '** User successfully created!' echo echo '-- Granting ALL privileges on '$WPdbName' to '$WPdbUser'...' mysql -e "GRANT ALL PRIVILEGES ON $WPdbName.* TO '$WPdbUser'@'localhost';" mysql -e "FLUSH PRIVILEGES;" echo echo '** The mariaDB database is created.' fi # Stop to test the config so far echo echo 'Now is a good time to test your WordPress installation.' echo ' You should be able to view it at http://127.0.0.1:9999 of your host system.' echo read -e -r -p "Press 'y' when you are ready to continue. " -i "y" doContinue if [[ -z $doContinue ]] then doContinue="y" fi if ! [[ $doContinue == "y" ]] then echo echo 'Oh. I guess something is wrong. Exiting. (Re-start the script when ready.)' exit 1 fi # Continuing... echo echo 'Continuing with installation...' echo read -e -r -p "Ready to build the webstore with buildWebstore.sh? ['y' continues] " -i "n" doBuildWebstore if [[ -z $doBuildWebstore ]] then doBuildWebstore="n" fi if [[ $doBuildWebstore == "y" ]] then woocommerce-taler/server-build/QEMU-autobuild/buildWebstore.sh fi echo read -e -r -p "Ready to setup Re:claim? ['y' continues] " -i "n" doReClaim if [[ -z $doReClaim ]] then doReClaim="n" fi if [[ $doReclaim == "y" ]] then woocommerce-taler/server-build/QEMU-autobuild/buildReclaim.sh fi exit 0