forked from helmo/docker-aegir-mariadb
-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.sh
executable file
·117 lines (91 loc) · 3.57 KB
/
run.sh
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/bin/bash
# needed variables:
# AEGIR_SITE
# AEGIR_EMAIL
# AEGIR_DB_PASSWORD
# AEGIR_VERSION
# Start ssh early to be able to login for debugging.
service openssh-server start
echo "Install mysql:"
MYSQL="/usr/bin/mysqld_safe"
MYSQL_ADMIN="/usr/bin/mysqladmin"
INITDB="/usr/bin/mysql_install_db"
DATADIR="/var/lib/mysql"
chown -R mysql:mysql /var/log/mysql
# test if DATADIR is existent
if [ ! -d $DATADIR ]; then
echo "Creating MySQL data at $DATADIR"
mkdir -p $DATADIR
fi
# test if DATADIR has content
if [ ! "$(ls -A $DATADIR)" ]; then
echo "Initializing MySQL Database at $DATADIR"
chown -R mysql:mysql $DATADIR
chmod 700 $DATADIR
$INITDB --user=mysql --ldata=$DATADIR
echo "starting MySQL server..."
/usr/bin/mysqld_safe &
MYSQL_PID=$!
sleep 6
# Finally, grant access to off-container connections
GRANT="GRANT ALL PRIVILEGES ON *.* to root@'%' IDENTIFIED BY '${MYSQL_ROOT_PW}' WITH GRANT OPTION;\
UPDATE user SET Password=PASSWORD('$MYSQL_ROOT_PW') WHERE User='root';\
FLUSH PRIVILEGES;"
echo "$GRANT" | mysql -u root mysql
echo "server running."
else
echo "starting MySQL server..."
/usr/bin/mysqld_safe &
MYSQL_PID=$!
sleep 6
fi
echo "init aegir"
if [ -e "/root/installed" ] ; then
echo "Host already installed"
else
GRANT="GRANT ALL PRIVILEGES ON *.* TO 'aegir_root'@'%' IDENTIFIED BY '${AEGIR_DB_PASSWORD}' WITH GRANT OPTION;\
FLUSH PRIVILEGES;"
echo "$GRANT" | mysql -u root -h localhost -p$MYSQL_ROOT_PW
debconf-set-selections /tmp/dpkg_selection.conf
# set installation parameters to prevent the installation script from asking
echo "postfix postfix/relayhost string " | debconf-set-selections
echo "postfix postfix/mailname string $POSTFIX_MAILNAME" | debconf-set-selections
echo "postfix postfix/destinations string $POSTFIX_DESTINATION, localhost.localdomain, localhost" | debconf-set-selections
apt-get -y install postfix
adduser --system --group --home /var/aegir aegir
adduser aegir www-data #make aegir a user of group www-data
chsh aegir -s /bin/bash
chown -R www-data:www-data /var/log/apache2
chown -R aegir:www-data /var/aegir
phpmemory_limit=256M #or what ever you want it set to
sed -i 's/memory_limit = .*/memory_limit = '${phpmemory_limit}'/' /etc/php5/apache2/php.ini
a2enmod rewrite
echo -e "Defaults:aegir !requiretty\naegir ALL=NOPASSWD: /usr/sbin/apache2ctl" >> /etc/sudoers.d/aegir
chmod 0440 /etc/sudoers.d/aegir
mkdir -p /var/aegir/drush
chown aegir:aegir /var/aegir/drush
ln -s /usr/bin/drush /var/aegir/drush/drush
ln -s /var/aegir/drush/drush /usr/local/bin/drush
# some of my older drush extensions expect drush commands to be in there:
mkdir -p /usr/share/drush/commands
ln -s /var/aegir/.drush/provision /usr/share/drush/commands/provision
# This is where Aegir is installed
echo "Starting Aegir install script..."
su -s /bin/bash aegir -c "bash /aegir_install.sh"
echo "Aegir install script finished."
# make sure apache knows about Aegir's config
ln -s /var/aegir/config/apache.conf /etc/apache2/conf.d/aegir.conf
touch /root/installed
# Stop apache, supervisor will start it later and keep it running.
apache2ctl stop
echo "Installing hosting_queue_runner daemon..."
cp /var/aegir/hosting_queue_runner.conf /etc/supervisor/conf.d/
chown aegir:aegir /var/aegir/hosting_queue_runner.sh
chmod 700 /var/aegir/hosting_queue_runner.sh
echo "Hosting_queue_runner installed"
fi
# Stop these, supervisor will start them later and keep them running.
mysqladmin -p$MYSQL_ROOT_PW shutdown
/etc/init.d/postfix stop
echo "Starting supervisor..."
supervisord -c /opt/supervisor.conf -n