Commit 34aef8a5 authored by gerd's avatar gerd

fixes


git-svn-id: https://gps.dynxs.de/private/svn/app-plasma/trunk@265 55289a75-7b90-4627-9e07-ffb4263930b2
parent 955adef8
......@@ -3,23 +3,36 @@
# This script builds and installs Plasma via GODI, i.e. the latest
# version that is available in GODI. A few important remarks:
#
# - The script creates a directory /opt/plasma and installs GODI
# - You can run the script in three modes:
# -build: Builds the software (default)
# -namenode: Prepares the namenode
# -datanode: Prepares the datanode
# The build is done on the build host (which can be a distinct
# node but also one of the namenodes or datanodes).
# - If a node has several roles, you should run the script several
# times, e.g. once with -namenode and once with -datanode.
# - Build mode:
# The script creates a directory /opt/plasma and installs GODI
# there. It is not possible to use an existing GODI. It is also
# not possible to use another existing Ocaml installation (like
# the one coming with the OS distribution). There is no need
# to deinstall these - just put /opt/plasma/bin before them in
# PATH.
# - The script installs missing system packages. So far this works
# - All modes:
# The script installs missing system packages. So far this works
# only for a few Linux distributions. Users of other OS are on
# their own here.
# - The script needs to run a few commands as root. It knows several
# their own here. (Tested distros: Debian, Ubuntu, Fedora, Opensuse.
# Please avoid Fedora 13 for now.)
# - All modes:
# The script needs to run a few commands as root. It knows several
# methods of becoming root (su, sudo, ssh root@localhost). You can
# select the right one on the command line.
# - The script builds Plasma. This is only required on one machine,
# the buildhost. Once this is done you can deploy from there (see
# manual). On the namenodes and datanodes it may be nevertheless
# required to install OS packages. For this reason, there is a
# -namenode and -datanode mode.
# select the right one on the command line. Do not start the script
# as root. You should start it as the "file owner" of the installation.
# - On namenodes the script also installs PostgreSQL, and configures
# it. Again, this only works for the few known Linux distros.
# - Once you have built the software and prepared all namenodes and
# datanodes, look into the manual ($root/doc/godi-plasma) for
# how to go on. There is a chapter about deploying Plasma.
#
# DO NOT RUN THIS SCRIPT AS ROOT!
......@@ -38,9 +51,15 @@ List of options:
-noroot Skip root stuff
-namenode Only install packages for namenode
-datanode Only install packages for datanode
-build Build
EOF
}
uid=`id -u`
if [ $uid = 0 ]; then
echo "This script cannot be run as root."
fi
root=/opt/plasma
os=""
rootmeth=""
......@@ -64,6 +83,8 @@ while [ $# -gt 0 ]; do
mode="namenode"; shift ;;
-datanode)
mode="datanode"; shift ;;
-build)
mode="build"; shift ;;
*)
usage >&2; exit 2 ;;
esac
......@@ -77,11 +98,15 @@ if [ -f /etc/debian_version ]; then
os="debian"
if [ -f /etc/apt/sources.list ]; then
if grep /ubuntu /etc/apt/sources.list >/dev/null; then
rootmeth=sudo
if [ -z "$rootmeth" ]; then
rootmeth=sudo
fi
fi
fi
elif [ -f /etc/redhat-release ]; then
os="redhat"
elif [ -f /etc/SuSE-release ]; then
os="suse"
fi
if [ -z "$rootmeth" ]; then
......@@ -93,15 +118,20 @@ fi
######################################################################
debian_build_pkgs="build-essential wget gzip bzip2 patch m4 libpq-dev \
libpcre3-dev postgresql"
libpcre3-dev"
debian_namenode_pkgs="libpq5 libpcre3 postgresql"
debian_datanode_pkgs="libpq5 libpcre3"
redhat_build_pkgs="gcc wget gzip bzip2 patch m4 pcre make postgresql \
postgresql-server pcre-devel postgresql-devel"
pcre-devel postgresql-devel"
redhat_namenode_pkgs="pcre postgresql postgresql-server"
redhat_datanode_pkgs="pcre postgresql"
suse_build_pkgs="gcc wget gzip bzip2 patch m4 pcre make postgresql \
pcre-devel postgresql-devel"
suse_namenode_pkgs="pcre postgresql postgresql-server"
suse_datanode_pkgs="pcre postgresql"
pkgs=""
case "$os,$mode" in
debian,build)
......@@ -116,6 +146,12 @@ case "$os,$mode" in
pkgs="$redhat_namenode_pkgs" ;;
redhat,datanode)
pkgs="$redhat_datanode_pkgs" ;;
suse,build)
pkgs="$suse_build_pkgs" ;;
suse,namenode)
pkgs="$suse_namenode_pkgs" ;;
suse,datanode)
pkgs="$suse_datanode_pkgs" ;;
esac
pscript=""
......@@ -127,6 +163,11 @@ case "$os" in
redhat)
pscript="yum install $pkgs"
pmsg="installing packages" ;;
suse)
pscript="zypper install $pkgs"
pmsg="installing packages" ;;
*)
echo "OS not recognized - not installing packages" ;;
esac
######################################################################
......@@ -176,6 +217,121 @@ if [ -n "$pscript" -o -n "$rscript" ]; then
esac
fi
######################################################################
# Check PostgreSQL
######################################################################
pgscript=""
if [ $mode = namenode ]; then
# Some OS initialize PG automatically at package install time,
# some don't. Also, we have to set the max_prepared_transactions
# parameter to at least 1 (we use 5 here to have some room).
pgversion="$(psql --version | head -1 | sed -e 's/psql (PostgreSQL) //')"
# something like 8.4.4. This is the version we are building for (some
# OS allow it to have several PG versions in parallel).
pgversion2="$(echo "$pgversion" | sed -e 's/^\([0-9]\+\.[0-9]\+\).*$/\1/')"
# something like 8.4
pgdir=""
pgname="postgresql"
pginit=""
case "$os" in
debian)
pgname="postgresql-$pgversion2"
pgdir="/etc/postgresql/$pgversion2/main"
pginit="pg_createcluster $pgversion2 main"
;;
redhat)
pgdir="/var/lib/pgsql/data"
pginit="/sbin/service postgresql initdb"
;;
suse)
pgdir="/var/lib/pgsql/data"
pginit="/sbin/service postgresql start"
# suse initializes on first start automatically
;;
esac
# How to start/stop services:
pgstart="/etc/init.d/$pgname start"
pgstop="/etc/init.d/$pgname stop"
if [ -x /sbin/service ]; then
pgstart="/sbin/service $pgname start"
pgstop="/sbin/service $pgname stop"
fi
user="$(id -un)"
# The script to run as root:
pgscript1="pgdir='$pgdir'; user='$user'"
pgscript2="pgstart='$pgstart'; pgstop='$pgstop'; pginit='$pginit'"
pgscript3=$(cat <<'EOF'
PATH=/sbin:/usr/sbin:$PATH
export PATH
if [ ! -f "$pgdir/postgresql.conf" ]; then
echo "postgresql.conf not found. Need to initialize PostgreSQL first."
$pginit
if [ ! -f "$pgdir/postgresql.conf" ]; then
echo "FAILURE"
exit 1
fi
fi
max_prepared_transactions=0
mptline="$(grep '^max_prepared_transactions' "$pgdir/postgresql.conf")"
if [ -n "$mptline" ]; then
max_prepared_transactions="$(echo "$mptline" | sed -e 's/^max_prepared_transactions[ \t]*=[ \t]*\([0-9]\+\).*$/\1/')"
fi
if [ $max_prepared_transactions -lt 5 ]; then
echo "PostgreSQL parameter max_prepared_transactions is too low."
echo "Changing postgresql.conf"
if [ -n "$mptline" ]; then
f=/tmp/plasmainstall.$$
sed -e 's/^max_prepared_transactions[ \t]*=[ \t]*[0-9]\+\(.*\)$/max_prepared_transactions = 5\1/' "$pgdir/postgresql.conf" >$f
cp $f "$pgdir/postgresql.conf"
rm -f $f
else
echo "max_prepared_transactions = 5" >>"$pgdir/postgresql.conf"
fi
$pgstop
fi
$pgstart
su postgres -c "createuser -S -d -R '$user'"
EOF
)
pgscript="$pgscript1; $pgscript2; $pgscript3"
fi
######################################################################
# Do stuff as root
######################################################################
if [ -n "$pgscript" ]; then
if [ "$rootmeth" != none ]; then
echo "*******************************************************************"
echo "* Doing as root: checking, reconfiguring, starting PostgreSQL"
echo "*******************************************************************"
echo "Method to become root: $rootmeth"
echo " (if this does not work for you, restart the script with the"
echo " right option: -su, -sudo, or -ssh)"
fi
case "$rootmeth" in
su)
su -c "$pgscript" ;;
sudo)
sudo sh -c "$pgscript" ;;
ssh)
ssh root@localhost "$pgscript" ;;
none)
true ;;
esac
fi
######################################################################
if [ "$mode" != "build" ]; then
echo "*******************************************************************"
echo "* Done with system preparation."
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment