forked from marius311/boinc-server-docker
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmakeproject-step2.sh
More file actions
executable file
·64 lines (52 loc) · 2.16 KB
/
makeproject-step2.sh
File metadata and controls
executable file
·64 lines (52 loc) · 2.16 KB
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
#!/bin/bash
set -e
source /run/secrets/secrets.env
PROJECT_ROOT_DEST=$PROJECT_ROOT.dst
cd $PROJECT_ROOT
echo "Updating project files in data volume..."
# do variable substitution in files
for file in config.xml html/user/schedulers.txt *.httpd.conf html/ops/.htaccess html/project/project.inc; do
sed -i -e "s|\${PROJECT}|$PROJECT|gI" \
-e "s|REPLACE WITH PROJECT NAME|$PROJECT|gI" \
-e "s|\${PROJECT_ROOT}|$PROJECT_ROOT|gI" \
-e "s|\${URL_BASE}|$URL_BASE|gI" \
-e "s|\${DB_PASSWD}|$DB_PASSWD|gI" \
-e "s|\${MAILPASS}|$MAILPASS|gI" \
-e "s|\${RECAPTCHA_PUBLIC_KEY}|$RECAPTCHA_PUBLIC_KEY|gI" \
-e "s|\${RECAPTCHA_PRIVATE_KEY}|$RECAPTCHA_PRIVATE_KEY|gI" \
$file
done
# do variable substitution in file names (although with -n to not overwrite
# existing files which may be customized versions provided by the project)
for file in \$\{project\}*; do
mv -n $file ${file/\$\{project\}/$PROJECT}
rm -f $file
done
# copy files
cp -rfT --preserve=mode,ownership $PROJECT_ROOT $PROJECT_ROOT_DEST
mv $PROJECT_ROOT ${PROJECT_ROOT}.orig
ln -s $PROJECT_ROOT_DEST $PROJECT_ROOT
cd $PROJECT_ROOT
# wait for MySQL server to start
echo "Waiting for MySQL server to start..."
if ! timeout -s KILL 60 mysqladmin ping -h mysql --wait &> /dev/null ; then
echo "MySQL server failed to start after 60 seconds. Aborting."
exit 1
fi
# if we can get in the root MySQL account without password, it means this is the
# first run after project creation, in which case set the password, and create
# the project database
if mysql -u root -e "" &> /dev/null ; then
echo "Creating database..."
mysqladmin -h mysql -u root password $DB_PASSWD
PYTHONPATH=/usr/local/boinc/py python -c """if 1:
from Boinc import database, configxml
database.create_database(srcdir='/usr/local/boinc',
config=configxml.ConfigFile(filename='$PROJECT_ROOT/config.xml').read().config,
drop_first=False)
"""
fi
(cd html/ops && ./db_schemaversion.php > ${PROJECT_ROOT}/db_revision)
bin/xadd
yes | bin/update_versions
touch $PROJECT_ROOT/.built_${PROJECT}