You are not logged in Log in Join
You are here: Home » Members » dpetersen » Install Zope 2.6 on Debian (shell script source install)

Log in
Name

Password

 
 

History for Install Zope 2.6 on Debian (shell script source install)

??changed:
-
#!/bin/sh
# Compile Zope Source on Debian and Update to Zope 2.6

## variables
install_plone=1	#experimental
webdir=http://www.zope.org/Products/Zope/2.6.0/
tarball=Zope-2.6.0-src
tarballext=.tgz
zopeinstaller=wo_pcgi.py
zopeuser=www-data
pythonver=python2.1
pythonver_unstable=python2.2	#experimental
http_port=8081
ZOPE_HOME=/usr/lib/zope
SOFTWARE_HOME=/usr/lib/zope/lib/python
INSTANCE_HOME=/var/lib/zope
export ZOPE_HOME SOFTWARE_HOME INSTANCE_HOME


currdir=`cd .;pwd`
## Setup Debian Zope Environment, on non Debian install these manually first
apt-get -y install wget tar gcc make libc6-dev $pythonver-dev
apt-get -y install zope 
## If you are using plone from the unstable tree you must install it first
if [ $install_plone = 1 ]; then
    pythonver=pythonver_unstable
    #apt-get -y install zope-cmfplone $pythonver-dev
fi

## Download  Zope Source
mkdir -p $ZOPE_HOME
mkdir -p $INSTANCE_HOME/var
    
if [ -e $INSTANCE_HOME/$tarball$tarballext ]; then
    #echo -e '$tarball already downloaded !'
    rm -f $INSTANCE_HOME/$tarball$tarballext
fi 

echo -e "Downloading tarball from  $webdir$tarball$tarballext\n"   
wget --tries=5 --directory-prefix=$INSTANCE_HOME $webdir$tarball$tarballext
    
if [ ! -e $INSTANCE_HOME/$tarball$tarballext ]; then
    echo -e "$webdir$tarball$tarballext could not be downloaded."
    echo -e "Check your internet settings and try again later.\n"
    exit
fi    
        
## unpack and compile in install dir
cd $INSTANCE_HOME
if [ -d $INSTANCE_HOME/$tarball ]; then
    echo "Delete existing tmp dir..."
    rm -d -f -r $INSTANCE_HOME/$tarball
fi
tar xvzf $tarball$tarballext
cd $tarball

## disable setting of default password after install
sed -e "s/import zpasswd;/#import zpasswd;/" ./$zopeinstaller > ./$zopeinstaller.tmp
    mv ./$zopeinstaller.tmp ./$zopeinstaller    
	
## starting standard install without PCGI support
$pythonver ./$zopeinstaller

## stop current zope instance 
if [ -e /etc/init.d/zope ]; then
    echo -e "Stopping Debian Zope Server\n" 
    /etc/init.d/zope stop
else
    echo -e "Stopping Zope Server...\n"
    $ZOPE_HOME/stop
fi 

## backup old Zope install
echo -e "Compilation of Zope Source $tarball has finished."
echo -e "Do you want to backup your current zope installation before update ?\n"
opts="Backup Continue"
select opt in $opts; do
    #echo -e you picked "$opt" \($REPLY\)
    if [ "$opt" != "Continue" ]; then
        echo -e "Starting Backup..."
        mkdir -p $INSTANCE_HOME/Zope-Backup$INSTANCE_HOME
        mkdir -p $INSTANCE_HOME/Zope-Backup$ZOPE_HOME
        cp -R -f $INSTANCE_HOME/var $INSTANCE_HOME/Zope-Backup$INSTANCE_HOME 
        cp -f $INSTANCE_HOME/* $INSTANCE_HOME/Zope-Backup$INSTANCE_HOME
        cp -R -f $ZOPE_HOME/Extensions $INSTANCE_HOME/Zope-Backup$ZOPE_HOME
        cp -R -f $ZOPE_HOME/ZServer $INSTANCE_HOME/Zope-Backup$ZOPE_HOME
        cp -R -f $ZOPE_HOME/lib $INSTANCE_HOME/Zope-Backup$ZOPE_HOME
        #cp -f $ZOPE_HOME/* $INSTANCE_HOME/Zope-Backup$ZOPE_HOME
	echo -e "\nZope structure has been saved to $INSTANCE_HOME/Zope-Backup\n"
    elif [ "$opt" = "Continue" ]; then
        echo -e "Continue without Backup...\n"
    fi
    break
done	

## delete and copy files
#find $ZOPE_HOME -name '*.o' -o -name '*.so' -o -name '*.py[co]' \
#    -o -name 'core*' | xargs rm -f 
echo -e "delete old compilations in $ZOPE_HOME ....\n"
find $ZOPE_HOME  -name '*.py[co]' -o -name 'core*' | xargs rm -f 

echo -e "copy new files to $ZOPE_HOME ...."
cp -R -f $INSTANCE_HOME/$tarball/Extensions $ZOPE_HOME
cp -R -f $INSTANCE_HOME/$tarball/ZServer $ZOPE_HOME
cp -R -f $INSTANCE_HOME/$tarball/lib $ZOPE_HOME
cp -R -f $INSTANCE_HOME/$tarball/utilities $ZOPE_HOME
cp -R -f $INSTANCE_HOME/$tarball/import $INSTANCE_HOME
if [ -d /usr/share/doc/zope ]; then
    cp -r -f $INSTANCE_HOME/$tarball/doc/* /usr/share/doc/zope
fi    
cp -f $INSTANCE_HOME/$tarball/zpasswd.py $ZOPE_HOME/zpasswd.py
mv $ZOPE_HOME/z2.py $ZOPE_HOME/z2.py.bak

## Create Unix-User for running Zope Instance
groupadd $zopeuser
useradd -g $zopeuser -d $INSTANCE_HOME $zopeuser
zuid=`id -u $zopeuser`

## Debian modifications for z2.py - dirty hack - at least it's easy to find
echo "#! /usr/bin/$pythonver" > $ZOPE_HOME/z2.py
echo "# Debian setup begin" >> $ZOPE_HOME/z2.py
echo "import os, sys" >> $ZOPE_HOME/z2.py
echo "sys.path.insert(0, '$SOFTWARE_HOME')" >> $ZOPE_HOME/z2.py
echo "os.chdir('$ZOPE_HOME')" >> $ZOPE_HOME/z2.py
echo "os.environ['INSTANCE_HOME']='$INSTANCE_HOME'" >> $ZOPE_HOME/z2.py
echo "os.setuid($zuid)" >> $ZOPE_HOME/z2.py
echo "os.umask(077)" >> $ZOPE_HOME/z2.py
echo "# Debian setup end" >> $ZOPE_HOME/z2.py
cat $INSTANCE_HOME/$tarball/z2.py >> $ZOPE_HOME/z2.py

## Set values for UID AND HTTP_PORT in z2.py
sed -e "s/UID=None/UID='$zopeuser'/" $ZOPE_HOME/z2.py > $ZOPE_HOME/z2.py.tmp
  mv $ZOPE_HOME/z2.py.tmp $ZOPE_HOME/z2.py
sed -e "s/HTTP_PORT=8080/HTTP_PORT=$http_port/" $ZOPE_HOME/z2.py > $ZOPE_HOME/z2.py.tmp
  mv $ZOPE_HOME/z2.py.tmp $ZOPE_HOME/z2.py
## Change the restart Timeout / 5 sec is too short
sed -e 's/HTTP-EQUIV=REFRESH CONTENT="5/HTTP-EQUIV=REFRESH CONTENT="15/' \ 
    $ZOPE_HOME/lib/python/App/ApplicationManager.py > \
    $ZOPE_HOME/lib/python/App/ApplicationManager.py.tmp 
  mv $ZOPE_HOME/lib/python/App/ApplicationManager.py.tmp \ 
  $ZOPE_HOME/lib/python/App/ApplicationManager.py

chmod 755 $ZOPE_HOME/z2.py
chmod 755 $ZOPE_HOME/zpasswd.py
    
echo -e "\nFinishing installation....\n"
    
## Set Startupmode for non Debian
if [ ! -e /etc/init.d/zope ]; then
    echo -e "Default Zope detected (no Debian)...\n" 
    cp -f $INSTANCE_HOME/$tarball/start $ZOPE_HOME/start
    cp -f $INSTANCE_HOME/$tarball/stop $ZOPE_HOME/stop
    sed -e "s/$tarball//" $ZOPE_HOME/stop > $ZOPE_HOME/stop.tmp
        mv $ZOPE_HOME/stop.tmp $ZOPE_HOME/stop   
    chmod 755 $ZOPE_HOME/start
    chmod 755 $ZOPE_HOME/stop
fi
    

## Set Initial / Emergency User if no access file found
if [ ! -e $INSTANCE_HOME/access ]; then
    echo -e "The initial/emergency user '$zopeuser' will now be created !"
    echo -e "The emergency user can only logon to Zope and create other users."
    echo -e "Please enter a new password for the emergency user '$zopeuser':"
    read -s -p Password: password		
    $ZOPE_HOME/zpasswd.py -u $zopeuser -p $password -e CRYPT $INSTANCE_HOME/access
    chmod 644 $INSTANCE_HOME/access
    echo -e "\nYou can now login to http://YourZopeSite:$http_port/manage/"
    echo -e "username: $zopeuser"
    echo -e "password: $password\n"
fi
    
## Check if Database is already installed
if [ -e $INSTANCE_HOME/var/Data.fs ]; then
    echo -e "Existing Zope Database found in $INSTANCE_HOME/var !\n"
else
    mkdir -p $INSTANCE_HOME/var
    cp -f $INSTANCE_HOME/$tarball/var/* $INSTANCE_HOME/var
    echo -e "Created new Zope Database...\n"
fi

## Setting owner rights to zopeuser and restart script as zopeuser
echo -e "Set owner of $INSTANCE_HOME/var to $zopeuser."
chown -R $zopeuser:$zopeuser $INSTANCE_HOME/var
rm -fr $INSTANCE_HOME/$tarball 

## Restart Zope as zopeuser 
if [ -e /etc/init.d/zope ]; then
    echo -e "\nPrepare Debian Zope restart as user $zopeuser...\n"
    cd $currdir 
    su -c "/etc/init.d/zope restart" $zopeuser
else
    echo -e "\nPrepare non Debian Zope restart as user $zopeuser...\n"    
    cd $currdir
    su -c "$ZOPE_HOME/start&" $zopeuser
fi

exit