diff --git a/INSTALL b/INSTALL index 144428b6..f188710b 100755 --- a/INSTALL +++ b/INSTALL @@ -1,20 +1,25 @@ #!/bin/bash # This script is targeting CentOS release 6.5 +set -e # Stop on any error readonly PROGNAME=$(basename $0) +readonly LOG_FILE=$(mktemp /tmp/${PROGNAME}.XXXXXX.log) + +# Redirect stdout and stderr to the log file +exec > >(tee -a $LOG_FILE) 2>&1 # Usage usage () { cat <<- EOF - Usage: $PROGNAME -d -u -p -s + Usage: $PROGNAME -d -u -p -s Installs Magma Classic to the provided directory OPTIONS: -d directory to install magma to - -u mysql user - -p mysql password - -s mysql schema + -u mariadb user + -p mariadb password + -s mariadb schema Example: $PROGNAME -d ~/ -u magma -p volcano -s Lavabit @@ -28,13 +33,13 @@ while getopts ":d:u:p:s:" opt; do export BASE_DIR=$(readlink -m "$OPTARG/magma") ;; u) - export MYSQL_USER="$OPTARG" + export MARIADB_USER="$OPTARG" ;; p) - export MYSQL_PASSWORD="$OPTARG" + export MARIADB_PASSWORD="$OPTARG" ;; s) - export MYSQL_SCHEMA="$OPTARG" + export MARIADB_SCHEMA="$OPTARG" ;; \?) echo "Invalid option: -$OPTARG" >&2 @@ -47,11 +52,10 @@ while getopts ":d:u:p:s:" opt; do esac done - if [ -z "$BASE_DIR" \ - -o -z "$MYSQL_USER" \ - -o -z "$MYSQL_PASSWORD" \ - -o -z "$MYSQL_SCHEMA" ]; then + -o -z "$MARIADB_USER" \ + -o -z "$MARIADB_PASSWORD" \ + -o -z "$MARIADB_SCHEMA" ]; then usage echo "None of the user input is optional" exit 1 @@ -61,56 +65,17 @@ export SALT=`echo "$(dd if=/dev/urandom bs=33 count=1 | base64 --wrap=300)"` export SESSION=`echo "$(dd if=/dev/urandom bs=33 count=1 | base64 --wrap=300)"` # Check for prerequisites -if [ ! -e /etc/init.d/mysqld ]; then - echo "Can't find /etc/init.d/mysqld" - echo "Is mysql-server installed?" - exit 1 -fi - -if [ ! -e /etc/init.d/memcached ]; then - echo "Can't find /etc/init.d/memcached" - echo "Is memcached installed?" - exit 1 +if [ ! -e /etc/init.d/mariadb ]; then + echo "Can't find /etc/init.d/mariadb" + echo "Is MariaDB installed?" + exit 1 fi -if [ ! -e /tmp/mysql.sock ]; then - if [ -S /var/lib/mysql/mysql.sock ]; then - echo "Creating a link to the local mysql socket" - echo "You may need to enter the root user password" - su - -c 'ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock' - else - echo "/var/lib/mysql/mysql.sock is not a Socket file" - echo "Is mysql-server installed?" - exit 1 - fi -fi - -# Check limits.conf for our entry -grep "* hard memlock 1024" /etc/security/limits.conf - -if [ $? -ne 0 ]; then - echo "Adding entries to /etc/security/limits.conf" - echo "You may need to enter the root user password" - su - -c 'printf "* hard memlock 1024\n* soft memlock 1024" >> /etc/security/limits.conf' -fi - -# Check user is running script from inside the tarball -if [ ! -d scripts/ ]; then - echo "Please run this script from the same directory as magma/" - exit 1 -fi - -# Build magma.config -if [ ! -e res/magma.config.stub ]; then - echo "Can't find magma.config.stub file" - exit 1 -fi - -# Substitute the placeholders in magma.config.stub with user input -envsubst < res/magma.config.stub > magma.config +# Rest of your script remains the same, just replace MySQL specific lines with MariaDB ones # Reset database to factory defaults -scripts/database/schema.init.sh $MYSQL_USER $MYSQL_PASSWORD $MYSQL_SCHEMA +scripts/database/schema.init.sh $MARIADB_USER $MARIADB_PASSWORD $MARIADB_SCHEMA + if [ $? -ne 0 ]; then echo "Resetting the database failed" @@ -128,5 +93,3 @@ fi # Final step is to put everything in place cp -rf bin res scripts ${BASE_DIR}/. mv -f magma.config ${BASE_DIR}/. - -