Zum Inhalt springen

Debian Installer

Erstellt am 9. März 2006 · 6 Antworten · letzte Antwort am 26. Februar 2007

Tags: Frage

Frescha ·

hi,
ich habe mich ja schon lange nichts mehr geschrieben aber nun ist es wieder soweit.
Da ich den Debian-Typo3-Installer benutze und dieser nicht mehr mit typo3 4.x funktioniert habe ich versucht den alten installer zu erneuern.

#!/bin/sh
# TYPO3 site installer
# This script will create new TYPO3 sites.
# Version 0.2, 16.09.2003
# Michael Stucki <mundaun@gmx.ch>
# #################################
# Orginal von Michael Stucki
# Modifiziert von Andreas Karfusehr am 09.03.2006
# Version 0.3


# Define some values

GROUP="www-data" # name of the group that runs the Apache webserver
# TODO: We could also grep through httpd.conf in case that this name was changed:
# GROUP=`cat /etc/apache/httpd.conf | grep "^[Gg]roup\ [^\ ]*$" | awk '{ print $NF; }'`

FIX_PERMISSIONS=0
ALWAYS_LATEST=0

######
# Scroll to the end to find the start of this script!
###

######
# Check on startup
###
start_check()
{
    ERROR=0

    # We always use /var/lib/typo3/latest to get the version number that will be used for installation
    # Check if /var/lib/typo3/latest is a symlink
    if [ -L /var/lib/typo3/latest ]; then

        # Get the current version which will be used by default
        TYPO3_SOURCE=`ls -l /var/lib/typo3/latest | awk '{ print $NF; }'`

        # Maybe /var/lib/typo3/latest does not point to the absolute path
        if [ ! -e $TYPO3_SOURCE ]; then TYPO3_SOURCE=/var/lib/typo3/$TYPO3_SOURCE; fi

        # If the updated still doesn't exist: Abort.
        if [ ! -e $TYPO3_SOURCE ]; then ERROR=1; fi

    else

        # It seems that /var/lib/typo3/latest is not a correct symlink: Abort.
        ERROR=1

    fi

    if [ $ERROR == 1 ]; then

        echo
        echo "/var/lib/typo3/latest is wrong or does not exist at all!"
        echo
        echo "Aborted."
        exit 1

    fi

    ERROR=0
}

######
# Display usage info
###
show_usage()
{
    echo "typo3-site-installer, a simple installer for fresh TYPO3 sites"
    echo
    echo "  Usage: typo3-site-installer [OPTIONS]"
    echo
    echo "  General options:"
    echo "    -d, --destination=DIR      Specify the target directory for your new site"
    echo "    -a, --always-latest        If set, the symlink typo3_src will point to"
    echo "                               /var/lib/typo3/latest"
    echo
    echo "  Options you can only use as root:"
    echo "    -f, --fix-permissions      Fix all permissions"
    echo "    -g, --group=GROUP          Change group ownership to this group"
    echo
}

######
# Install a clean dummysite
###
install_site()
{

    # Test if directory is writable
    if [ -w `dirname $DESTINATION` ]; then

        # Test if target directory already exists (may also be a file)
        if [ -e $DESTINATION ]; then

            echo
            echo "=============================================================================="
            echo "Directory $DESTINATION exists!"
            echo "=============================================================================="
            echo
            echo "Aborted."
            exit 1

        fi

        # Create the directory structure
        mkdir $DESTINATION
        mkdir $DESTINATION/fileadmin
        mkdir $DESTINATION/fileadmin/_temp_
        mkdir $DESTINATION/fileadmin/user_upload
        mkdir $DESTINATION/fileadmin/user_upload/_temp_
        mkdir $DESTINATION/typo3conf
        mkdir $DESTINATION/typo3conf/ext
        mkdir $DESTINATION/typo3temp
        mkdir $DESTINATION/typo3temp/temp
	mkdir $DESTINATION/typo3temp/pics
	mkdir $DESTINATION/typo3temp/llxml
	mkdir $DESTINATION/typo3temp/cs
	mkdir $DESTINATION/typo3temp/GB
        mkdir $DESTINATION/uploads
        mkdir $DESTINATION/uploads/dmail_att
        mkdir $DESTINATION/uploads/media
        mkdir $DESTINATION/uploads/pics
        mkdir $DESTINATION/uploads/tf

        # Create index.html for directories that should not be shown
        cat <<eof> $DESTINATION/uploads/index.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
    <title></title>
    <meta http-equiv="Refresh" content="0; Url=../" />
</head>
</html>
EOF

        # Create a symlink to this file in every subdirectory
        cp $DESTINATION/uploads/index.html $DESTINATION/uploads/dmail_att/
        cp $DESTINATION/uploads/index.html $DESTINATION/uploads/media/
        cp $DESTINATION/uploads/index.html $DESTINATION/uploads/pics/
        cp $DESTINATION/uploads/index.html $DESTINATION/uploads/tf/
        cp $DESTINATION/uploads/index.html $DESTINATION/typo3conf/

        # Copy some other files from /usr/share/doc/typo3-site-installer
        cp /usr/share/doc/typo3-site-installer/_.htaccess $DESTINATION/
        cp /usr/share/doc/typo3-site-installer/clear.gif $DESTINATION/
        #gunzip -c /usr/share/doc/typo3-site-installer/changelog.gz > $DESTINATION/changelog
        gunzip -c /usr/share/doc/typo3-site-installer/database.sql.gz > $DESTINATION/typo3conf/database.sql

        # Copy the localconf.php into typo3conf/
        cp /usr/share/doc/typo3-base/examples/localconf.php $DESTINATION/typo3conf/

        # Create a few symlinks
        ln -s $TYPO3_SOURCE $DESTINATION/typo3_src
        ln -s typo3_src/t3lib $DESTINATION/
        ln -s typo3_src/typo3 $DESTINATION/
        ln -s typo3_src/index.php $DESTINATION/index.php

        # Fix the permissions
        fix_permissions

    else

        echo
        echo "=============================================================================="
        echo "Error: The target directory cannot be created."
        echo "Please check your settings."
        echo "Note that the parent directory needs to be existing!"
        echo "=============================================================================="
        echo
        echo "Aborted."
        exit 1

    fi
}


######
# Fix some permissions
###
fix_permissions()
{

    ERROR=0
    if [ ! -d $DESTINATION ]; then

        echo
        echo "=============================================================================="
        echo "Error: Directory does not exist!"
        ERROR=1

    elif [ ! -e $DESTINATION/index.php ]; then

        echo
        echo "=============================================================================="
        echo "Error: Site seems to be incorrect!"
        ERROR=1

    fi

    if [ $ERROR == 1 ]; then

        echo -n "The directory you tried to use was:"
        echo $DESTINATION
        echo
        echo "Make sure you create the directory structure with this script."
        echo "Use this command to do so:"
        echo "  typo3-site-installer -d=$DESTINATION"
        echo
        echo "If you think this is a bug, please contact the author."
        echo "=============================================================================="
        echo
        echo "Aborted."
        exit 1

    fi

    ERROR=0

    if [ $USER == 'root' ]; then

        # www-data is the group owner of the Apache process
        chgrp -R $GROUP $DESTINATION
        find $DESTINATION -type f -exec chmod 640 {} \;
        find $DESTINATION -type d -exec chmod 750 {} \;

        chmod -R g+w $DESTINATION/fileadmin
        chmod -R g+w $DESTINATION/typo3conf
        chmod -R g+w $DESTINATION/typo3temp
        chmod -R g+w $DESTINATION/uploads
        chmod 600 $DESTINATION/changelog

    else

        find $DESTINATION -type f -exec chmod 666 {} \;
        find $DESTINATION -type d -exec chmod 777 {} \;
        chmod 600 $DESTINATION/changelog

        echo
        echo "=============================================================================="
        echo "You are not logged in as root."
        echo -n "I was unable to change the group ownership to"
        echo $GROUP
        echo
        echo "I have therefore changed the permissions to minimal security (everybody can"
        echo "read / write)."
        echo
        echo "Though your site will be working with these settings, you are strongly"
        echo "encouraged to fix that problem by running this script again but with root"
        echo "permissions and using the option '--fix-permissions':"
        echo
        echo "Use this command to do so:"
        echo "  typo3-site-installer -d $DESTINATION --fix-permissions"
    fi

    echo
    echo "=============================================================================="
    echo "Finished. But there is still something to do for you:"
    echo
    echo "First: Make sure that "$DESTINATION" is accessable through your webserver."
    echo "(Move this directory to /var/www if you don't know what to do.)"
    echo
    echo
    echo "Next, follow these steps:"
    echo
    echo "  * In $TYPO3_SOURCE/typo3/install/index.php:"
    echo "    Comment out line 40 (the 'die()' call)"
    echo "  * Point your browser to the location you just created and complete the setup"
    echo "  * Remove the comment from above"
    echo
    echo "Note: the image settings should already be optimized for Debian Woody."
    echo
    echo "Make sure to read the README file for later install instructions."
    echo "=============================================================================="
    echo
    echo "Successfully done."
}


#####
# Main control
###

start_check

# Show info if no parameters were specified
if [ $# -lt 1 ]; then show_usage; exit 1; fi

# Read all parameters
while [ $# -gt 0 ]; do
    case "$1" in

        -d|-d=*|--destination|--destination=*)
            # Example: --destination /abc/def/geh
            if [ $1 == -d -o $1 == --destination ] && [ ! -z "$2" ]; then

                DESTINATION="$2"
                shift 2

            elif [ -z `echo $1 | sed -e 's/\(-d\|--destination\)=\(.\+\)//'` ]; then

                # Example: --destination=/abc/def/geh
                DESTINATION=`echo "$1" | awk -F= '{ print $2; }'`

                # proceed if $DESTINATION is non-zero
                if [ ! -z $DESTINATION ]; then shift 1
                else show_usage; exit 1
                fi

            else

                show_usage
                exit 1

            fi

            # Convert disallowed characters to underscores
            DESTINATION=`echo $DESTINATION | sed -e 's/[^-\~_./a-zA-Z0-9]\+/_/g'`
          ;;

        -f|--fix-permission|--fix-permissions)
            # We only want to fix the permissions of an existing site
            FIX_PERMISSIONS=1
            shift
          ;;

        -g|-g=*|--group|--group=*)
            # Group was manually specified; only act if we are root.
            if [ $USER == 'root' ]; then

                # $GROUP should normally be the group owner of the Apache process
                if [ $1 == -g -o $1 == --group ] && [ ! -z "$2" ]; then

                    GROUP="$2"
                    shift 2

                elif [ -z `echo $1 | sed -e 's/\(-g\|--group\)=\(.\+\)//'` ]; then

                    # Example: --destination=/abc/def/geh
                    GROUP=`echo "$1" | awk -F= '{ print $2; }'`

                    # proceed if $DESTINATION is non-zero
                    if [ ! -z $GROUP ]; then shift 1
                    else show_usage; exit 1
                    fi

                fi

            else

                echo
                echo "=============================================================================="
                echo "You are not logged in as root."
                echo -n "I was unable to change the group ownership to"
                echo $GROUP
                echo "=============================================================================="
                echo
                echo "Aborted."
                exit 1

            fi

          ;;

        -a|--always-latest)
            # Point typo3_src to /var/lib/typo3/latest
            if [ $ALWAYS_LATEST == 1 ]; then TYPO3_SOURCE=/var/lib/typo3/latest; fi
            shift
          ;;

        *)
            # something went wrong
            show_usage
            exit 1
          ;;

    esac
done

# see what we have to do
if [ $FIX_PERMISSIONS == 1 ]; then fix_permissions
elif [ ! -z $DESTINATION ]; then install_site
fi

exit 0

das orginal shell script liegt in /usr/bin/ und heißt typo3-site-installer. Diese Datei muss man dann auch Aktualisieren.
Solltet ihr Fehler finden oder Anregungen haben, meldet es mir bitte.

Blackchrimi ·

ich bekomme momentan folgende Fehlermeldung:
/usr/bin/typo3-site-installer: line 387: syntax error: unexpected end of file

tandem ·

line 387: syntax error: unexpected end of file

Hast Du eine Zeile angefügt?
Und/oder von Windows nach Linux kopiert?

WiseGuy ·

Hm - bei mir kamleider der gleiche Fehler.
Liegt aber nicht an nem Zeilenumbruch, den man nicht sieht, sondern daran, das doch einige Fehler in dem Script sind:
'eof' muss groß geschrieben werden und die Parameter hast du vergessen. Ich hab das entsprechend geändert:

#!/bin/sh
# TYPO3 site installer
# This script will create new TYPO3 sites.
# Version 0.2, 16.09.2003
# Michael Stucki <mundaun@gmx.ch>
# #################################
# Orginal von Michael Stucki
# Modifiziert von Andreas Karfusehr am 09.03.2006
# Version 0.3

# Define some values

GROUP="www-data" # name of the group that runs the Apache webserver
# TODO: We could also grep through httpd.conf in case that this name was changed:
# GROUP=`cat /etc/apache/httpd.conf | grep "^[Gg]roup\ [^\ ]*$" | awk '{ print $NF; }'`

FIX_PERMISSIONS=0
ALWAYS_LATEST=0

######
# Scroll to the end to find the start of this script!
###

######
# Check on startup
###
start_check()
{
ERROR=0

# We always use /var/lib/typo3/latest to get the version number that will be used for installation
# Check if /var/lib/typo3/latest is a symlink
if [ -L /var/lib/typo3/latest ]; then

# Get the current version which will be used by default
TYPO3_SOURCE=`ls -l /var/lib/typo3/latest | awk '{ print $NF; }'`

# Maybe /var/lib/typo3/latest does not point to the absolute path
if [ ! -e $TYPO3_SOURCE ]; then TYPO3_SOURCE=/var/lib/typo3/$TYPO3_SOURCE; fi

# If the updated still doesn't exist: Abort.
if [ ! -e $TYPO3_SOURCE ]; then ERROR=1; fi

else

# It seems that /var/lib/typo3/latest is not a correct symlink: Abort.
ERROR=1

fi

if [ $ERROR == 1 ]; then

echo
echo "/var/lib/typo3/latest is wrong or does not exist at all!"
echo
echo "Aborted."
exit 1

fi

ERROR=0
}

######
# Display usage info
###
show_usage()
{
echo "typo3-site-installer, a simple installer for fresh TYPO3 sites"
echo
echo " Usage: typo3-site-installer [OPTIONS]"
echo
echo " General options:"
echo " -d, --destination=DIR Specify the target directory for your new site"
echo " -a, --always-latest If set, the symlink typo3_src will point to"
echo " /var/lib/typo3/latest"
echo
echo " Options you can only use as root:"
echo " -f, --fix-permissions Fix all permissions"
echo " -g, --group=GROUP Change group ownership to this group"
echo
}

######
# Install a clean dummysite
###
install_site()
{

# Test if directory is writable
if [ -w `dirname $DESTINATION` ]; then

# Test if target directory already exists (may also be a file)
if [ -e $DESTINATION ]; then

echo
echo "=============================================================================="
echo "Directory $DESTINATION exists!"
echo "=============================================================================="
echo
echo "Aborted."
exit 1

fi

# Create the directory structure
mkdir $DESTINATION
mkdir $DESTINATION/fileadmin
mkdir $DESTINATION/fileadmin/_temp_
mkdir $DESTINATION/fileadmin/user_upload
mkdir $DESTINATION/fileadmin/user_upload/_temp_
mkdir $DESTINATION/typo3conf
mkdir $DESTINATION/typo3conf/ext
mkdir $DESTINATION/typo3temp
mkdir $DESTINATION/typo3temp/temp
mkdir $DESTINATION/typo3temp/pics
mkdir $DESTINATION/typo3temp/llxml
mkdir $DESTINATION/typo3temp/cs
mkdir $DESTINATION/typo3temp/GB
mkdir $DESTINATION/uploads
mkdir $DESTINATION/uploads/dmail_att
mkdir $DESTINATION/uploads/media
mkdir $DESTINATION/uploads/pics
mkdir $DESTINATION/uploads/tf

# Create index.html for directories that should not be shown
cat <<eof> $DESTINATION/uploads/index.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<title></title>
<meta http-equiv="Refresh" content="0; Url=../" />
</head>
</html>
EOF

# Create a symlink to this file in every subdirectory
cp $DESTINATION/uploads/index.html $DESTINATION/uploads/dmail_att/
cp $DESTINATION/uploads/index.html $DESTINATION/uploads/media/
cp $DESTINATION/uploads/index.html $DESTINATION/uploads/pics/
cp $DESTINATION/uploads/index.html $DESTINATION/uploads/tf/
cp $DESTINATION/uploads/index.html $DESTINATION/typo3conf/

# Copy some other files from /usr/share/doc/typo3-site-installer
cp /usr/share/doc/typo3-site-installer/_.htaccess $DESTINATION/
cp /usr/share/doc/typo3-site-installer/clear.gif $DESTINATION/
#gunzip -c /usr/share/doc/typo3-site-installer/changelog.gz > $DESTINATION/changelog
gunzip -c /usr/share/doc/typo3-site-installer/database.sql.gz > $DESTINATION/typo3conf/database.sql

# Copy the localconf.php into typo3conf/
cp /usr/share/doc/typo3-base/examples/localconf.php $DESTINATION/typo3conf/

# Create a few symlinks
ln -s $TYPO3_SOURCE $DESTINATION/typo3_src
ln -s typo3_src/t3lib $DESTINATION/
ln -s typo3_src/typo3 $DESTINATION/
ln -s typo3_src/index.php $DESTINATION/index.php

# Fix the permissions
fix_permissions

else

echo
echo "=============================================================================="
echo "Error: The target directory cannot be created."
echo "Please check your settings."
echo "Note that the parent directory needs to be existing!"
echo "=============================================================================="
echo
echo "Aborted."
exit 1

fi
}

######
# Fix some permissions
###
fix_permissions()
{

ERROR=0
if [ ! -d $DESTINATION ]; then

echo
echo "=============================================================================="
echo "Error: Directory does not exist!"
ERROR=1

elif [ ! -e $DESTINATION/index.php ]; then

echo
echo "=============================================================================="
echo "Error: Site seems to be incorrect!"
ERROR=1

fi

if [ $ERROR == 1 ]; then

echo -n "The directory you tried to use was:"
echo $DESTINATION
echo
echo "Make sure you create the directory structure with this script."
echo "Use this command to do so:"
echo " typo3-site-installer -d=$DESTINATION"
echo
echo "If you think this is a bug, please contact the author."
echo "=============================================================================="
echo
echo "Aborted."
exit 1

fi

ERROR=0

if [ $USER == 'root' ]; then

# www-data is the group owner of the Apache process
chgrp -R $GROUP $DESTINATION
find $DESTINATION -type f -exec chmod 640 {} \;
find $DESTINATION -type d -exec chmod 750 {} \;

chmod -R g+w $DESTINATION/fileadmin
chmod -R g+w $DESTINATION/typo3conf
chmod -R g+w $DESTINATION/typo3temp
chmod -R g+w $DESTINATION/uploads
chmod 600 $DESTINATION/changelog

else

find $DESTINATION -type f -exec chmod 666 {} \;
find $DESTINATION -type d -exec chmod 777 {} \;
chmod 600 $DESTINATION/changelog

echo
echo "=============================================================================="
echo "You are not logged in as root."
echo -n "I was unable to change the group ownership to"
echo $GROUP
echo
echo "I have therefore changed the permissions to minimal security (everybody can"
echo "read / write)."
echo
echo "Though your site will be working with these settings, you are strongly"
echo "encouraged to fix that problem by running this script again but with root"
echo "permissions and using the option '--fix-permissions':"
echo
echo "Use this command to do so:"
echo " typo3-site-installer -d $DESTINATION --fix-permissions"
fi

echo
echo "=============================================================================="
echo "Finished. But there is still something to do for you:"
echo
echo "First: Make sure that "$DESTINATION" is accessable through your webserver."
echo "(Move this directory to /var/www if you don't know what to do.)"
echo
echo
echo "Next, follow these steps:"
echo
echo " * In $TYPO3_SOURCE/typo3/install/index.php:"
echo " Comment out line 44-46 (the 'die()' call)"
echo " * Point your browser to the location you just created and complete the setup"
echo " * Remove the comment from above"
echo
echo "Note: the image settings should already be optimized for Debian Woody."
echo
echo "Make sure to read the README file for later install instructions."
echo "=============================================================================="
echo
echo "Successfully done."
}

#####
# Main control
###

start_check

# Show info if no parameters were specified
if [ $# -lt 1 ]; then show_usage; exit 1; fi

# Read all parameters
while [ $# -gt 0 ]; do
case "$1" in

-d|-d=*|--destination|--destination=*)
# Example: --destination /abc/def/geh
if [ $1 == -d -o $1 == --destination ] && [ ! -z "$2" ]; then

DESTINATION="$2"
shift 2

elif [ -z `echo $1 | sed -e 's/\(-d\|--destination\)=\(.\+\)//'` ]; then

# Example: --destination=/abc/def/geh
DESTINATION=`echo "$1" | awk -F= '{ print $2; }'`

# proceed if $DESTINATION is non-zero
if [ ! -z $DESTINATION ]; then shift 1
else show_usage; exit 1
fi

else

show_usage
exit 1

fi

# Convert disallowed characters to underscores
DESTINATION=`echo $DESTINATION | sed -e 's/[^-\~_./a-zA-Z0-9]\+/_/g'`
;;

-f|--fix-permission|--fix-permissions)
# We only want to fix the permissions of an existing site
FIX_PERMISSIONS=1
shift
;;

-g|-g=*|--group|--group=*)
# Group was manually specified; only act if we are root.
if [ $USER == 'root' ]; then

# $GROUP should normally be the group owner of the Apache process
if [ $1 == -g -o $1 == --group ] && [ ! -z "$2" ]; then

GROUP="$2"
shift 2

elif [ -z `echo $1 | sed -e 's/\(-g\|--group\)=\(.\+\)//'` ]; then

# Example: --destination=/abc/def/geh
GROUP=`echo "$1" | awk -F= '{ print $2; }'`

# proceed if $DESTINATION is non-zero
if [ ! -z $GROUP ]; then shift 1
else show_usage; exit 1
fi

fi

else

echo
echo "=============================================================================="
echo "You are not logged in as root."
echo -n "I was unable to change the group ownership to"
echo $GROUP
echo "=============================================================================="
echo
echo "Aborted."
exit 1

fi

;;

-a|--always-latest)
# Point typo3_src to /var/lib/typo3/latest
if [ $ALWAYS_LATEST == 1 ]; then TYPO3_SOURCE=/var/lib/typo3/latest; fi
shift
;;

*)
# something went wrong
show_usage
exit 1
;;

esac
done

# see what we have to do
if [ $FIX_PERMISSIONS == 1 ]; then fix_permissions
elif [ ! -z $DESTINATION ]; then install_site
fi

exit 0

Aber irgendwas klappt trotzde mnicht. Ich hab den Fehler aber nicht finden können, da ich den genauen Aufbau des dummy-paketes nicht kenne. (und jetzt nicht rausfinde)

Außerdem bleibt das Script hängen, wenn man die Option -g wählt - bei mir zumindestens.

PS: Ich kann es nicht in CODE Schreiben, denn dann fehlt genau wieder das $1 ... das wird quasi rausgefiltert, wenn mans in CODE Container packt :-(