Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
ai3
docker
roundcube
Commits
8f9b7f0c
Commit
8f9b7f0c
authored
Feb 08, 2018
by
ale
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor start.sh to be more linear
parent
5c941db6
Pipeline
#848
passed with stages
in 3 minutes and 34 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
43 deletions
+39
-43
start.sh
start.sh
+39
-43
No files found.
start.sh
View file @
8f9b7f0c
...
...
@@ -13,53 +13,49 @@ TARGET_DIR=/var/www/webmail
# Name of the MySQL database to use.
MYSQL_DB
=
"ai_roundcube"
install_config
()
{
install
-o
root
-g
root
-m
644
${
CONFIG_DIR
}
/config.inc.php
${
TARGET_DIR
}
/config/config.inc.php
# For each known plugin, look for a NAME.config.inc.php file in
# the config directory: if found, copy it to the plugin directory
# as plugins/NAME/config.inc.php.
for
p
in
$(
cd
${
TARGET_DIR
}
/plugins
&&
echo
*
)
;
do
if
[
-e
"
${
CONFIG_DIR
}
/
${
p
}
.config.inc.php"
]
;
then
install
-o
root
-g
root
-m
644
${
CONFIG_DIR
}
/
${
p
}
.config.inc.php
\
${
TARGET_DIR
}
/plugins/
${
p
}
/config.inc.php
fi
done
}
setup_database
()
{
# The current Roundcube version is stored in the database.
cur_version
=
$(
mysql
-NBe
'select version from rc_version'
${
MYSQL_DB
}
2>/dev/null
)
# If cur_version is empty, it means that the database has not been
# initialized yet.
if
[
-z
"
${
cur_version
}
"
]
;
then
mysql
${
MYSQL_DB
}
<
${
TARGET_DIR
}
/SQL/mysql.initial.sql
mysql
-e
"create table rc_version (version text); insert into rc_version (version) values ('unknown')"
${
MYSQL_DB
}
fi
# Run database upgrade if necessary.
${
TARGET_DIR
}
/bin/update.sh
-v
${
cur_version
}
-y
mysql
-e
"update rc_version set version='
${
RC_VERSION
}
'"
${
MYSQL_DB
}
die
()
{
echo
"ERROR:
$*
"
>
&2
exit
1
}
set
-e
set
-u
# Abort if some fundamental environment variables are not defined.
# This is nicer than having Apache die with an error.
if
[
-z
"
${
DOMAIN
}
"
]
;
then
echo
"ERROR: The 'DOMAIN' environment variable is not defined"
>
&2
exit
1
fi
if
[
-z
"
${
SHARD_ID
}
"
]
;
then
echo
"ERROR: The 'SHARD_ID' environment variable is not defined"
>
&2
exit
1
# This is nicer than having Apache die with an error later.
test
-n
"
${
DOMAIN
}
"
\
||
die
"the 'DOMAIN' environment variable is not defined"
test
-n
"
${
SHARD_ID
}
"
\
||
die
"the 'SHARD_ID' environment variable is not defined"
# Install the main Roundcube configuration to TARGET_DIR/config.
test
-e
${
CONFIG_DIR
}
/config.inc.php
\
||
die
"
${
CONFIG_DIR
}
/config.inc.php is missing"
install
-o
root
-g
root
-m
644
${
CONFIG_DIR
}
/config.inc.php
${
TARGET_DIR
}
/config/config.inc.php
# For each known plugin, look for a NAME.config.inc.php file in
# the config directory: if found, copy it to the plugin directory
# as plugins/NAME/config.inc.php.
for
p
in
$(
cd
${
TARGET_DIR
}
/plugins
&&
echo
*
)
;
do
test
-e
"
${
CONFIG_DIR
}
/
${
p
}
.config.inc.php"
\
&&
install
-o
root
-g
root
-m
644
${
CONFIG_DIR
}
/
${
p
}
.config.inc.php
\
${
TARGET_DIR
}
/plugins/
${
p
}
/config.inc.php
done
# Now set up the MySQL database for Roundcube. The current Roundcube
# version is stored in the database.
cur_version
=
$(
mysql
-NBe
'select version from rc_version'
${
MYSQL_DB
}
2>/dev/null
)
# If cur_version is empty, it means that the database has not been
# initialized yet.
if
[
-z
"
${
cur_version
}
"
]
;
then
mysql
${
MYSQL_DB
}
<
${
TARGET_DIR
}
/SQL/mysql.initial.sql
\
||
die
"could not load initial SQL schema to
${
MYSQL_DB
}
"
mysql
-e
"create table rc_version (version text); insert into rc_version (version) values ('unknown')"
${
MYSQL_DB
}
\
||
die
"could not create rc_version table in
${
MYSQL_DB
}
"
fi
install_config
setup_database
# Run database upgrade if necessary.
${
TARGET_DIR
}
/bin/update.sh
-v
${
cur_version
}
-y
\
||
die
"Roundcube update script failed"
mysql
-e
"update rc_version set version='
${
RC_VERSION
}
'"
${
MYSQL_DB
}
exit
0
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment