This repository has been archived by the owner on Apr 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
main
executable file
·80 lines (65 loc) · 1.88 KB
/
main
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
76
77
78
79
#!/bin/bash -ex
DB_NAME=mahara
DB_USER=mahara
DB_PASS=$(mcookie)
ADMIN_NAME=admin
ADMIN_PASS=turnkey
ADMIN_MAIL=admin@example.com
SRC=/usr/local/src
WEBROOT=/var/www/mahara
DATADIR=/var/lib/mahara/data
# unpack mahara ans set ownership
tar -zxf $SRC/mahara-*.tar.gz -C $(dirname $WEBROOT)
mv $WEBROOT-*/htdocs $WEBROOT
chown -R www-data:www-data $WEBROOT
rm -rf $WEBROOT-*
rm $SRC/mahara-*.tar.gz
# configure apache
a2dissite 000-default
a2ensite mahara
a2enmod rewrite
a2enmod headers
# start services
/etc/init.d/postgresql start
# create database
su postgres -c "createuser --no-superuser --createdb --no-createrole $DB_USER"
su postgres -c "createdb --owner $DB_USER -EUTF8 $DB_NAME"
su postgres -c "psql postgres" << EOF
alter user $DB_USER with encrypted password '$DB_PASS';
EOF
# create data directory and configuration
mkdir -p $DATADIR
chown -R www-data:www-data $(dirname $DATADIR)
cat > $WEBROOT/config.php <<EOF
<?php
\$cfg = new StdClass;
\$cfg->dbtype = 'postgres';
\$cfg->dbhost = 'localhost';
\$cfg->dbport = null;
\$cfg->dbname = '$DB_NAME';
\$cfg->dbuser = '$DB_USER';
\$cfg->dbpass = '$DB_PASS';
\$cfg->dbprefix = '';
\$cfg->dataroot = '$DATADIR';
\$cfg->emailcontact = '';
\$cfg->passwordsaltmain = '$(mcookie)$(mcookie)';
EOF
chown www-data:www-data $WEBROOT/config.php
chmod 640 $WEBROOT/config.php
# install mahara
cd $WEBROOT
su www-data -s /bin/sh -c "php admin/cli/install.php -p='$ADMIN_PASS' -e=$ADMIN_MAIL"
# setup cron job
echo "
SHELL=/bin/bash
* * * * * php $WEBROOT/lib/cron.php >/dev/null 2>&1
" | crontab -u www-data -
# tweak config
su postgres -c "psql mahara" << EOF
update config set value = 'localhost' where field = 'smtphosts';
update config set value = '25' where field = 'smtpport';
update config set value = 'TurnKey Mahara' where field = 'sitename';
insert into config values('noreplyaddress', 'noreply@example.com');
EOF
# stop services
/etc/init.d/postgresql stop