summarylogtreecommitdiffstats
path: root/codeigniter-create-project
blob: 11e0366599a275ac600567f5a2c4dd4bbf01bcad (plain)
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
#!/bin/bash

function help() {
cat << EOF
Usage: $0 html_path app_path
html_path: directory, where your CodeIgniter's index.php is (e.g. ~/public_html/ci)
app_path: directory, where your CodeIgniter programs are (e.g. ~/programs/CI)
EOF
}

if [ $# -ne 2 ]; then
    help
    exit 1
fi

WEBDIR=$(realpath $1)
APPDIR=$(realpath $2)
CI_DIR=/usr/share/pear/codeigniter

echo "Create web-directory ($WEBDIR)"
install -d $WEBDIR || exit 1
echo "Copy index.php to $WEBDIR"
install $CI_DIR/index.php $WEBDIR || exit 1
sed -i "0,/\$application_folder.*=.*/s@@\$application_folder = \"$APPDIR\";@" $WEBDIR/index.php || exit 1
sed -i "0,/\$system_path.*=.*/s@@\$system_path = \"$CI_DIR\/system\";@" $WEBDIR/index.php || exit 1

echo "Create main app directory ($APPDIR)"
install -d $APPDIR || exit 1
echo "Creating directories to app directory"
for dir in cache config controllers core errors helpers hooks language libraries logs models third_party views; do
    install -d $APPDIR/$dir || exit 1
    [ -d $CI_DIR/application/$dir ] && (cp -r -n $CI_DIR/application/$dir/* $APPDIR/$dir || exit 1)
done

echo Installation done.