Skip to content

Update INSTALL #157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 22 additions & 59 deletions INSTALL
Original file line number Diff line number Diff line change
@@ -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 <install_directory> -u <mysql_user> -p <mysql_password> -s <mysql_schema>
Usage: $PROGNAME -d <install_directory> -u <mariadb_user> -p <mariadb_password> -s <mariadb_schema>

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

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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"
Expand All @@ -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}/.