-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·96 lines (85 loc) · 2.25 KB
/
install.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
#!/bin/bash
. common.sh
# Check if g++, libtiff and libjpeg are installed.
if ! g++ -ljpeg -ltiff -o /dev/null 2>&1 | grep -q _start
then
echo "Unmet dependencies. g++, libjpeg and libtiff are required."
exit 1
fi
# Ask user for destination path.
DST=""
while [ -z "$DST" ]
do
echo -n "Website destination path: "
read -e DST
if [ ! -d "$DST" ] && [ -n "$DST" ]
then
echo "Error: '$DST' is not a directory."
DST=""
fi
FILES=$(conflicting "$DST" .htaccess index.php backend frontend data favicon.ico)
if [ -n "$FILES" ]
then
echo "Error: conflicting files in destination path:"
echo "$FILES"
echo "Please remove these files manually before installing."
exit 1
fi
done
# Link website.
echo "Linking website..."
if ! ln -st "$DST" "$PWD"/application/www/*
then
echo "Error while linking website."
exit 1
fi
# Set permissions.
echo "Setting permissions..."
if ! chmod -R 0755 application/www/data/
then
echo "Error while setting permissions."
exit 1
fi
mkdir application/www/data/cache
chmod 0755 application/www/data/cache
# Install first database version.
echo "Installing database..."
if ! sqlfile "application/sqlscripts/databases/db74.sql"
then
echo "Installing base database failed."
exit 1
fi
# Update database to current version.
setSetting db-version 74
setSetting maintenance-mode 1
setSetting updating 1
./update.sh
setSetting updating 0
setSetting maintenance-mode 0
# Build the tile builder.
echo "Building the tile builder..."
cd tilepyramidbuilder
if ! ./build.sh
then
echo "Build failed."
exit 1
fi
cd ..
# Install cronjob.
echo "Installing cronjob..."
CT=$(tempfile)
crontab -l 2>/dev/null > "$CT"
if ! grep -q "@reboot $PWD/tilepyramidbuilder/cronjob/cronjob.sh $PWD/application/www/backend/" "$CT"
then
echo "@reboot $PWD/tilepyramidbuilder/cronjob/cronjob.sh $PWD/application/www/backend/" >> "$CT"
if ! crontab "$CT"
then
echo "Crontab installation failed."
exit 1
fi
else
echo "Crontab already present - not updated."
fi
# Start the cronjob - no need to reboot.
echo "Starting the tile builder..."
nohup $PWD/tilepyramidbuilder/cronjob/cronjob.sh $PWD/application/www/backend/ </dev/null >/dev/null 2>/dev/null &