-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·56 lines (47 loc) · 1.81 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·56 lines (47 loc) · 1.81 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
#!/bin/bash
echo "Checking prerequisites..."
tools=( git docker docker-compose npm )
for tool in "${tools[@]}"; do
if ! type "$tool" > /dev/null; then
echo -e "\e[0;31m - $tool \e[m"
else
echo -e "\e[0;32m + $tool \e[m"
fi
done
if [ ! -e ".git" ]; then
echo "Fetching sources..."
git clone --recursive git://github.com/dime-timetracker/dime-docker.git dime || exit 1
cd dime
else
if [ -e ".installed" ]; then
echo 'Dime already installed.'
exit 1
fi
fi
fqn=$(host -TtA $(hostname -s)2>/dev/null|grep "has address"|awk '{print $1}');
if [[ "${fqn}" == "" ]]; then
fqn=$(hostname -s);
fi
echo "Initialize Docker"
docker-compose up -d
echo "Setup Server"
serverConfig="server/config/parameters.php"
sed -r "s/'dbname' => '.*'/'dbname' => 'dime'/" $serverConfig.dist > $serverConfig
sed -i -r "s/'host' => '.*'/'host' => 'db'/" $serverConfig
curl -s https://getcomposer.org/installer > server/composer-setup.php
docker-compose run api php -r "if (hash_file('SHA384', 'composer-setup.php') !== 'e115a8dc7871f15d853148a7fbac7da27d6c0030b848d9b3dc09e2a0388afed865e6a3d6b3c0fad45c48e2b5fc1196ae') { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
docker-compose run api php composer-setup.php
rm server/composer-setup.php
docker-compose run api php composer.phar install --no-dev
docker-compose run api mysql -hdb -uroot -e "create database dime"
docker-compose run api php console.php dime:install
echo "Setup Frontend"
frontendConfig="frontend/src/parameters.js"
echo "Using ${fqn} as server name. Please adjust $frontendConfig manually, if that is not correct."
cp $frontendConfig.template $frontendConfig
echo "env.baseUrl = \"$fqn:8100\"" >> $frontendConfig
cd frontend; npm install; npm run build
cd ..
touch .installed
echo ""
echo "Done. Dime is now running at http://$fqn:8100/"