File: install.sh

package info (click to toggle)
postfixadmin 4.0.1%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,888 kB
  • sloc: php: 12,256; perl: 1,156; sh: 717; python: 142; xml: 63; sql: 3; makefile: 2
file content (75 lines) | stat: -rw-r--r-- 2,445 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash

set -eu

# PostfixAdmin install script.
# 1. Downloads 'composer.phar' to the current directory, if 'composer' is not found in your PATH
# 2. Runs 'php composer install' which should install required runtime libraries for Postfixadmin
# 3. Runs 'mkdir templates_c && chmod 777 templates_c'

PATH=/bin:/usr/bin:/usr/local/bin
export PATH

COMPOSER_URL=https://getcomposer.org/download/latest-stable/composer.phar

type php >/dev/null 2>&1 || { echo >&2 "I require php but it's not installed.  Aborting."; exit 1; }

cd "$(dirname "$0")"

# Check for $(pwd)/composer.phar

echo " * Checking for composer.phar "

if ! command -v composer >/dev/null 2>&1 ; then
    # not in path, try and fall back to a local version
    if [ ! -f composer.phar ]; then
        echo " * 'composer' not found in your path, will try to download from $COMPOSER_URL "

        # try and download it one way or another
        if [ -x /usr/bin/wget ]; then
            wget -q -O composer.phar $COMPOSER_URL
        else
            if [ -x /usr/bin/curl ]; then
                curl -o composer.phar $COMPOSER_URL
            else
                echo " ** Could not find wget or curl; please download $COMPOSER_URL to pwd" >/dev/stderr
                exit 1
            fi
        fi
    fi

    COMPOSER="$(pwd)/composer.phar"

    # not sure if we can actually get here, wget/curl failing should kill the script due to 'set -e'
    if [ ! -f "${COMPOSER}" ]; then
        echo "Failed to download composer, download $COMPOSER_URL manually into this directory." > /dev/stderr
        exit 1
    fi

else
    COMPOSER="$(which composer)"
fi

echo " * Using composer ( $COMPOSER )"
echo " * Installing libraries ( composer install --no-dev ... )"

php "${COMPOSER}" install --prefer-dist -n --no-dev

if [ ! -d templates_c ]; then

    mkdir -p templates_c && chmod 777 templates_c

    echo
    echo " Warning: "
    echo "   templates_c directory didn't exist, now created."
    echo
    echo "   You should change the ownership and reduce permissions on templates_c to 750. "
    echo "   The ownership needs to match the user used to execute PHP scripts, perhaps 'www-data' or 'httpd'"
    echo
    echo "   e.g. chown www-data templates_c && chmod 750 templates_c"
    echo
fi
echo
echo "Please continue configuration / setup within your web browser. "
echo "See also : https://github.com/postfixadmin/postfixadmin/blob/master/INSTALL.TXT#L58 "
echo