server/misc/install.sh
2013-10-26 02:49:59 +02:00

69 lines
1.4 KiB
Bash
Executable File

#! /bin/sh
# Install FIC 2014 server
# Depends:
#
# nginx 1.4.3
# openssh 6.3p1-1
# iptables 1.4.19.1-1
# mariadb 5.5.33.a-1
# Exit values
# 0 Everything is good
# 1
# 2 File not found
# 3 Service not running
# By default the config dir is ..
DIR=${PWD%/*}
CONF="server.conf"
BASENAME=`basename $0`
FULL_INSTALL=false
display_help()
{
# By default install only config files
# --full: install package, enable services, install config
echo "Usage: $BASENAME [--full] (alpha|beta)"
exit 1
}
HTTP_DIR=""
DB_TYPE=""
DB_NAME=""
DB_USER=""
DB_PASS=""
parse_conf()
{
if ! [ -f $CONF ]; then
echo "The configuration file: " $CONF " not found"
exit 2
fi
HTTP_DIR=$(sed -n 's/[ \t]*http_root[ \t]*=[ \t]*\(.*\)[ \t]*/\1/p' $CONF)
DB_TYPE=$(sed -n 's/[ \t]*db_type[ \t]*=[ \t]*\(.*\)[ \t]*/\1/p' $CONF)
DB_NAME=$(sed -n 's/[ \t]*db_name[ \t]*=[ \t]*\(.*\)[ \t]*/\1/p' $CONF)
DB_USER=$(sed -n 's/[ \t]*db_user[ \t]*=[ \t]*\(.*\)[ \t]*/\1/p' $CONF)
DB_PASS=$(sed -n 's/[ \t]*db_pass[ \t]*=[ \t]*\(.*\)[ \t]*/\1/p' $CONF)
}
INIT_DB="init_db.sql"
init_db()
{
if ! [ -f $INIT_DB ]; then
echo "The configuration file " $INIT_DB " not found"
exit 2
fi
if ! [ -S /var/run/mysqld/mysqld.sock ]; then
echo "The mysqld service is not running"
exit 3
fi
}
[ $# -ne 1 ] && display_help
parse_conf