Просмотр исходного кода

new package: limesurvey 1.71 (Survey System)

Ralf S. Engelschall 17 лет назад
Родитель
Сommit
eb883ab292
4 измененных файлов с 442 добавлено и 0 удалено
  1. 108 0
      limesurvey/limesurvey-apache.conf
  2. 83 0
      limesurvey/limesurvey-setup.sh
  3. 211 0
      limesurvey/limesurvey.spec
  4. 40 0
      limesurvey/rc.limesurvey

+ 108 - 0
limesurvey/limesurvey-apache.conf

@@ -0,0 +1,108 @@
+##
+##  limesurvey-apache.conf -- Drupal Apache Custom Configuration
+##
+
+ServerRoot             @l_prefix@
+ServerAdmin            root@@l_hostname@.@l_domainname@
+ServerName             @l_hostname@.@l_domainname@
+ServerTokens           Prod
+User                   @l_rusr@
+Group                  @l_rgrp@
+Listen                 127.0.0.1:8084
+
+#   runtime files
+PidFile                @l_prefix@/var/limesurvey/run/apache.pid
+ScoreBoardFile         @l_prefix@/var/limesurvey/run/apache.sb
+LockFile               @l_prefix@/var/limesurvey/run/apache.lck
+
+#   include apache-php
+Include                @l_prefix@/etc/apache/apache.d/apache-php.conf
+
+#  server behaviour
+Timeout                300
+KeepAlive              on
+MaxKeepAliveRequests   100
+KeepAliveTimeout       15
+MinSpareServers        5
+MaxSpareServers        10
+StartServers           5
+MaxClients             15
+MaxRequestsPerChild    500
+HostnameLookups        off
+UseCanonicalName       on
+
+#   access logging
+LogFormat              "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
+LogFormat              "%h %l %u %t \"%r\" %>s %b" common
+LogFormat              "%{Referer}i -> %U" referer
+LogFormat              "%{User-agent}i" agent
+CustomLog              @l_prefix@/var/limesurvey/log/apache.access.log common
+
+#   error logging
+LogLevel               warn
+ErrorLog               @l_prefix@/var/limesurvey/log/apache.error.log
+ServerSignature        on
+
+#   secure root directory
+<Directory />
+    Options FollowSymLinks
+    AllowOverride None
+</Directory>
+
+#   browser specifics
+BrowserMatch "Mozilla/2"       nokeepalive
+BrowserMatch "MSIE 4\.0b2;"    nokeepalive downgrade-1.0 force-response-1.0
+BrowserMatch "RealPlayer 4\.0" force-response-1.0
+BrowserMatch "Java/1\.0"       force-response-1.0
+BrowserMatch "JDK/1\.0"        force-response-1.0
+
+#   SSL/TLS support
+<IfModule ssl_module>
+    SSLRandomSeed           startup builtin
+    SSLRandomSeed           connect builtin
+    SSLMutex                sem
+    SSLSessionCache         shmcb:@l_prefix@/var/limesurvey/run/apache.scache(512000)
+    SSLSessionCacheTimeout  300
+    SSLCipherSuite          ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
+    SetEnvIf User-Agent ".*MSIE.*" \
+             nokeepalive ssl-unclean-shutdown \
+             downgrade-1.0 force-response-1.0
+    <Files ~ "\.(cgi|shtml|phtml|php?)$">
+        SSLOptions +StdEnvVars
+    </Files>
+    <Directory "@l_prefix@/cgi">
+        SSLOptions +StdEnvVars
+    </Directory>
+</IfModule>
+
+#   configure PHP for Drupal
+AddType           application/x-httpd-php       .php
+php_admin_flag    magic_quotes_gpc              off
+php_admin_flag    register_globals              off
+php_admin_flag    session.auto_start            off
+php_admin_value   session.save_handler          user
+php_admin_value   session.cache_limiter         none
+php_admin_value   error_reporting               6135
+php_admin_value   memory_limit                  64M
+php_admin_value   mbstring.http_input           pass
+php_admin_value   mbstring.http_output          pass
+php_admin_flag    mbstring.encoding_translation off
+php_admin_value   include_path                  .:@l_prefix@/libexec/limesurvey/includes
+
+#   configure Drupal
+RewriteEngine     on
+RewriteRule       ^/$ /limesurvey/ [R,L]
+Alias             /limesurvey @l_prefix@/libexec/limesurvey
+DocumentRoot      @l_prefix@/libexec/limesurvey
+DirectoryIndex    index.php
+ErrorDocument     404 /index.php
+ExpiresByType     text/html A1
+<Directory        @l_prefix@/share/limesurvey>
+    Options       -Indexes +FollowSymLinks
+    AllowOverride All
+    Order         allow,deny
+    Allow         from all
+    RewriteEngine On
+    RewriteBase   /limesurvey
+</Directory>
+

+ 83 - 0
limesurvey/limesurvey-setup.sh

@@ -0,0 +1,83 @@
+#!@l_bash@
+##
+##  limesurvey-setup.sh -- LimeSurvey RDBMS Setup Utility
+##
+
+#   command line argument sanity check
+prg="$0"
+if [ $# -eq 0 ]; then
+    echo "$prg:ERROR: invalid command line" 1>&2
+    echo "$prg:USAGE: $prg install [<database-directory>]" 1>&2
+    echo "$prg:USAGE: $prg uninstall" 1>&2
+    echo "$prg:USAGE: $prg backup [<dump-file>]" 1>&2
+    echo "$prg:USAGE: $prg restore [<dump-file>|<dump-number>]" 1>&2
+    exit 1
+fi
+
+#   database configuration
+db_dir="@l_prefix@/var/limesurvey/db"
+db_type="@l_dbtype@"
+db_name="limesurvey"
+db_user="limesurvey"
+db_pass="limesurvey"
+
+#   determine RDBMS-specific details
+if [ ".$db_type" = .mysql ]; then
+    db_sname="mysql"
+    db_suser=`grep "^user" @l_prefix@/etc/mysql/my.pwd |\
+              sed -e 's;^user[^=]*= *;;' -e 's; *$;;'`
+    db_spass=`grep "^password" @l_prefix@/etc/mysql/my.pwd |\
+              sed -e 's;^password[^=]*= *;;' -e 's; *$;;'`
+elif [ ".$db_type" = .pgsql ]; then
+    db_sname=`grep "^superuser_database" @l_prefix@/var/postgresql/db/pg_superuser.conf |\
+              sed -e 's;^ *superuser_database="\(.*\)".*;\1;'`
+    db_suser=`grep "^superuser_username" @l_prefix@/var/postgresql/db/pg_superuser.conf |\
+              sed -e 's;^ *superuser_username="\(.*\)".*;\1;'`
+    db_spass=`grep "^superuser_password" @l_prefix@/var/postgresql/db/pg_superuser.conf |\
+              sed -e 's;^ *superuser_password="\(.*\)".*;\1;'`
+fi
+
+#   dispatch operation
+cmd="${1:-"install"}"
+shift
+case "$cmd" in
+    install )
+        ##
+        ##  create the database
+        ##
+
+        if [ $# -gt 0 ]; then
+            db_dir="$1"
+            shift
+        fi
+        if [ ".$db_type" = .mysql ]; then
+            #   FIXME: MySQL 5.0 still doesn't allow easy relocation of tablespaces
+            @l_prefix@/bin/mysqladmin --user="$db_suser" --password="$db_spass" create "$db_name"
+            ( echo "GRANT ALL PRIVILEGES ON $db_name.* TO $db_user@localhost IDENTIFIED BY '$db_pass';"
+              echo "FLUSH PRIVILEGES;"
+            ) | @l_prefix@/bin/mysql --user="$db_suser" --password="$db_spass" "$db_sname"
+        elif [ ".$db_type" = .pgsql ]; then
+            ( echo "CREATE ROLE $db_user LOGIN ENCRYPTED PASSWORD '$db_pass' NOCREATEDB NOCREATEUSER;"
+              echo "CREATE TABLESPACE $db_name OWNER $db_user LOCATION '$db_dir';"
+              echo "CREATE DATABASE $db_name OWNER $db_user TABLESPACE $db_name ENCODING 'UTF8';"
+            ) | PGPASSWORD="$db_spass" @l_prefix@/bin/psql -q -U "$db_suser" -d "$db_sname" -f-
+        fi
+        ;;
+
+    uninstall )
+        ##
+        ##  remove the database
+        ##
+
+        if [ ".$db_type" = .mysql ]; then
+            ( echo "DROP DATABASE $db_name;"
+            ) | @l_prefix@/bin/mysql --user="$db_suser" --password="$db_spass" "$db_sname"
+        elif [ ".$db_type" = .pgsql ]; then
+            ( echo "DROP DATABASE $db_name;"
+              echo "DROP TABLESPACE $db_name;"
+              echo "DROP ROLE $db_user;"
+            ) | PGPASSWORD="$db_spass" @l_prefix@/bin/psql -q -U "$db_suser" -d "$db_sname" -f-
+        fi
+        ;;
+esac
+

+ 211 - 0
limesurvey/limesurvey.spec

@@ -0,0 +1,211 @@
+##
+##  limesurvey.spec -- OpenPKG RPM Package Specification
+##  Copyright (c) 2000-2008 OpenPKG Foundation e.V. <http://openpkg.net/>
+##
+##  Permission to use, copy, modify, and distribute this software for
+##  any purpose with or without fee is hereby granted, provided that
+##  the above copyright notice and this permission notice appear in all
+##  copies.
+##
+##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+##  SUCH DAMAGE.
+##
+
+#   package version
+%define       V_dist 171plus_build5326_20080715
+%define       V_opkg 1.71
+
+#   package information
+Name:         limesurvey
+Summary:      Survey System
+URL:          http://www.limesurvey.org/
+Vendor:       LimeSurvey Project Team
+Packager:     OpenPKG Foundation e.V.
+Distribution: OpenPKG Community
+Class:        EVAL
+Group:        Web
+License:      GPL
+Version:      %{V_opkg}
+Release:      20080722
+
+#   package options
+%option       with_pgsql   yes
+%option       with_mysql   no
+
+#   checking for option conflicts
+%if "%{with_mysql}" == "no" && "%{with_pgsql}" == "no"
+    %{error:one of the build-time options 'with_mysql' or 'with_pgsql' have to be enabled}
+%endif
+%if "%{with_mysql}" == "yes" && "%{with_pgsql}" == "yes"
+    %{error:only one of the build-time options 'with_mysql' or 'with_pgsql' can be enabled at a time}
+%endif
+
+#   list of sources
+Source0:      http://switch.dl.sourceforge.net/limesurvey/limesurvey%{V_dist}.tar.gz
+Source1:      limesurvey-apache.conf
+Source2:      limesurvey-setup.sh
+Source3:      rc.limesurvey
+
+#   build information
+Prefix:       %{l_prefix}
+BuildRoot:    %{l_buildroot}
+BuildPreReq:  OpenPKG, openpkg >= 20060823
+PreReq:       OpenPKG, openpkg >= 20060823
+PreReq:       apache
+PreReq:       apache-php
+%if "%{with_mysql}" == "yes"
+PreReq:       apache-php::with_mysql = yes
+%endif
+%if "%{with_pgsql}" == "yes"
+PreReq:       apache-php::with_pgsql = yes
+%endif
+PreReq:       apache-php::with_pcre = yes
+PreReq:       apache-php::with_session = yes
+PreReq:       apache-php::with_mbstring = yes
+PreReq:       apache-php::with_iconv = yes
+PreReq:       apache-php::with_gd = yes
+AutoReq:      no
+AutoReqProv:  no
+
+%description
+    LimeSurvey is a Web application to create online surveys. It
+    features open/closed surveys, branching, participant administration,
+    quotas, WYSIWYG HTML editor, email invitations & reminders,
+    assessments, basic statistics and more.
+
+%track
+    prog limesurvey = {
+        version   = %{version}
+        url       = http://prdownloads.sourceforge.net/limesurvey/
+        regex     = limesurvey(.+?)\.tar\.gz
+    }
+
+%prep
+    %setup -q -n limesurvey
+    chmod -R u+w .
+
+%build
+
+%install
+    #   create installation hierarchy
+    rm -rf $RPM_BUILD_ROOT
+    %{l_shtool} mkdir -f -p -m 755 \
+        $RPM_BUILD_ROOT%{l_prefix}/sbin \
+        $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
+        $RPM_BUILD_ROOT%{l_prefix}/etc/limesurvey \
+        $RPM_BUILD_ROOT%{l_prefix}/libexec/limesurvey \
+        $RPM_BUILD_ROOT%{l_prefix}/var/limesurvey/run \
+        $RPM_BUILD_ROOT%{l_prefix}/var/limesurvey/log \
+        $RPM_BUILD_ROOT%{l_prefix}/var/limesurvey/db
+
+    #   install base system
+    cp -rp * $RPM_BUILD_ROOT%{l_prefix}/libexec/limesurvey/
+
+    #   adjust default configuration
+%if "%{with_mysql}" == "yes"
+    l_dbtype="mysql"
+%endif
+%if "%{with_pgsql}" == "yes"
+    l_dbtype="postgres"
+%endif
+    %{l_shtool} subst \
+        -e "s;\\(databasetype[^']*'\\)[^']*\\('\\);\\1${l_dbtype}\\2;" \
+        -e "s;\\(databasename[^']*'\\)[^']*\\('\\);\\1limesurvey\\2;" \
+        -e "s;\\(databaseuser[^']*'\\)[^']*\\('\\);\\1limesurvey\\2;" \
+        -e "s;\\(databasepass[^']*'\\)[^']*\\('\\);\\1limesurvey\\2;" \
+        $RPM_BUILD_ROOT%{l_prefix}/libexec/limesurvey/config.php
+
+    #   install run-command script
+    %{l_shtool} install -c -m 755 %{l_value -s -a} \
+        %{SOURCE rc.limesurvey} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
+
+    #   install database setup script
+%if "%{with_mysql}" == "yes"
+    l_dbtype="mysql"
+%endif
+%if "%{with_pgsql}" == "yes"
+    l_dbtype="pgsql"
+%endif
+    %{l_shtool} install -c -m 755 %{l_value -s -a} \
+        -e "s;@l_dbtype@;$l_dbtype;g" \
+        -e "s;@l_bash@;%{l_bash};g" \
+        %{SOURCE limesurvey-setup.sh} $RPM_BUILD_ROOT%{l_prefix}/sbin/limesurvey-setup
+
+    #   install custom Apache configuration
+    l_hostname=`%{l_shtool} echo -e %h`
+    l_domainname=`%{l_shtool} echo -e %d | cut -c2-`
+    %{l_shtool} install -c -m 644 %{l_value -s -a} \
+        -e "s;@l_hostname@;$l_hostname;g" \
+        -e "s;@l_domainname@;$l_domainname;g" \
+        %{SOURCE limesurvey-apache.conf} \
+        $RPM_BUILD_ROOT%{l_prefix}/etc/limesurvey/
+
+    #   determine installation files
+    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
+        %{l_files_std} \
+        '%config %{l_prefix}/etc/limesurvey' \
+        '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/libexec/limesurvey' \
+        '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/limesurvey'
+
+%files -f files
+
+%clean
+    rm -rf $RPM_BUILD_ROOT
+
+%post
+    if [ $1 -eq 1 ]; then
+        #   display final hints on initial installation
+        ( echo "1. To complete this installation of LimeSurvey please start"
+          echo "   the RDBMS and initialize the LimeSurvey database like this:"
+%if "%{with_mysql}" == "yes"
+          echo "     \$ $RPM_INSTALL_PREFIX/bin/openpkg rc mysql start"
+%endif
+%if "%{with_pgsql}" == "yes"
+          echo "     \$ $RPM_INSTALL_PREFIX/bin/openpkg rc postgresql start"
+%endif
+          echo "     \$ $RPM_INSTALL_PREFIX/sbin/limesurvey-setup install"
+          echo ""
+          echo "2. Now start LimeSurvey by running the command"
+          echo "     \$ $RPM_INSTALL_PREFIX/bin/openpkg rc limesurvey start"
+          echo "   and connect with a browser to the URL:"
+          echo "     http://127.0.0.1:8084/limesurvey/admin/install/"
+          echo ""
+          echo "3. cleanup after installation to enable run-time:"
+          echo "   \$ rm -f $RPM_INSTALL_PREFIX/libexec/limesurvey/admin/install"
+          echo ""
+          echo "4. By default, LimeSurvey runs its own Apache server on IPv4 address"
+          echo "   127.0.0.1, TCP port 8084. Please change this by editing the"
+          echo "   \"Listen 127.0.0.1:8084\" directive in"
+          echo "     $RPM_INSTALL_PREFIX/etc/limesurvey/limesurvey-apache.conf"
+          echo ""
+          echo "5. Access LimeSurvey via:"
+          echo "     http://127.0.0.1:8080/limesurvey/"
+        ) | %{l_rpmtool} msg -b -t notice
+    fi
+    if [ $1 -eq 2 ]; then
+        #   after upgrade, restart service
+        eval `%{l_rc} limesurvey status 2>/dev/null`
+        [ ".$limesurvey_active" = .yes ] && %{l_rc} limesurvey restart
+    fi
+    exit 0
+
+%preun
+    if [ $1 -eq 0 ]; then
+        #   before erase, stop service and remove log files
+        %{l_rc} limesurvey stop 2>/dev/null
+        rm -f $RPM_INSTALL_PREFIX/var/limesurvey/log/*   >/dev/null 2>&1 || true
+        rm -f $RPM_INSTALL_PREFIX/var/limesurvey/run/*   >/dev/null 2>&1 || true
+        rm -f $RPM_INSTALL_PREFIX/var/limesurvey/db/*    >/dev/null 2>&1 || true
+    fi
+    exit 0
+

+ 40 - 0
limesurvey/rc.limesurvey

@@ -0,0 +1,40 @@
+#!@l_prefix@/bin/openpkg rc
+##
+##  rc.limesurvey -- Run-Commands
+##
+
+%config
+    limesurvey_enable="$openpkg_rc_def"
+    limesurvey_backup="daily"
+
+%status -u @l_susr@ -o
+    limesurvey_usable="no"
+    limesurvey_active="no"
+    @l_prefix@/sbin/apache -t \
+        -f @l_prefix@/etc/limesurvey/limesurvey-apache.conf 2>/dev/null && \
+        limesurvey_usable="yes"
+    [ -f @l_prefix@/var/limesurvey/run/apache.pid ] && \
+        kill -0 `cat @l_prefix@/var/limesurvey/run/apache.pid` && \
+        limesurvey_active="yes"
+    echo "limesurvey_enable=\"$limesurvey_enable\""
+    echo "limesurvey_usable=\"$limesurvey_usable\""
+    echo "limesurvey_active=\"$limesurvey_active\""
+
+%start -u @l_susr@
+    rcService limesurvey enable yes || exit 0
+    rcService limesurvey active yes && exit 0
+    @l_prefix@/sbin/apache \
+        -f @l_prefix@/etc/limesurvey/limesurvey-apache.conf
+
+%stop -u @l_susr@
+    rcService limesurvey enable yes || exit 0
+    rcService limesurvey active no  && exit 0
+    [ -f @l_prefix@/var/limesurvey/run/apache.pid ] && \
+        kill -TERM `cat @l_prefix@/var/limesurvey/run/apache.pid`
+    sleep 2
+
+%restart -u @l_susr@
+    rcService limesurvey enable yes || exit 0
+    rcService limesurvey active no  && exit 0
+    rc limesurvey stop start
+