-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·149 lines (122 loc) · 4.19 KB
/
install.sh
File metadata and controls
executable file
·149 lines (122 loc) · 4.19 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
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/usr/bin/env bash
# Deployment script.
# Contains configuration for all deploy places
. deploy-tools/installer/installer.sh
function xcms_install_version_file() {
if [ "$mode" = "production" ] ; then
$sudo_mode cp version $root/
else
version="$(cat version)-$(xcms_git_version)-local"
print_message "Set version: $version"
$sudo_mode bash -e <<EOF
echo "$version" > $root/version
echo "version: $version" > $root/INFO
EOF
fi
}
program_name="FizLesh"
if [[ "$1" == "--help" ]] || [[ "$1" == "-h" ]] ; then
echo "$program_name deployment script"
echo "Usage: $0 <mode>"
echo
echo " <mode> (empty)|production|testing"
exit 0
fi
set -e
# TODO(mvel) support verbose mode
mode="$1"
if [ -z "$mode" ] ; then
mode="default"
fi
service_name="$2"
print_message "Mode: '$mode', service name: '$service_name'"
verbose=""
unalias grep 2>/dev/null || true
host="$( hostname )"
root="/var/www/vhosts/fizlesh.ru"
www_user="www-data:www-data"
content_dir="../content-fizlesh.ru"
if echo $host | grep -q math-lesh ; then
www_user="lesh:lesh"
content_dir="/var/www/${service_name}.ru/content-${service_name}.ru"
root="/var/www/${service_name}.ru/${mode}"
fi
$sudo_mode mkdir -p $root
$sudo_mode cp -r ./site/* $root/
if [ "$mode" = "production" ] ; then
# in production we just use kosher content and set symlink to it
if [ -e $root/content ] ; then
print_message "Unlinking content symlink"
$sudo_mode rm -f $root/content
fi
print_message "Setting production content symlink"
$sudo_mode ln -sf $content_dir/content $root/
cp $root/settings.production-${service_name}.ru.php $root/settings.php
else
# in default/testing mode we clone content from somewhere
tmp_db_path=""
if [ "$mode" = "default" ] ; then
# in default mode we back up database
db_path="$root/content/ank/fizlesh.sqlite3"
if [ -e $db_path ] ; then
tmp_db_path=$(mktemp fizlesh.XXXXXXXX)
print_message "Database $db_path backed up"
cp $db_path $tmp_db_path
fi
fi
print_message "Non-production mode, removing entire content directory"
$sudo_mode rm -rf $root/content
print_message "Copying test content"
$sudo_mode cp -r $content_dir/content $root/
if [ "$mode" = "default" ] ; then
# restore database backed up
if [ -n "$tmp_db_path" ] ; then
cp $tmp_db_path $db_path
print_message "Database $db_path restored from backup"
rm -f $tmp_db_path
fi
fi
cp $root/settings.local.php $root/settings.php
if [ -e $root/content/auth/usr/root.user ] ; then
print_message "Install users with default passwords"
$sudo_mode cp -f $verbose ./tools/xcms_console_tools/*.user $root/content/auth/usr/
else
print_error "User 'root' was not found, password change skipped"
fi
fi
# this all may fail on mathlesh.org
print_message "Clearing cache"
$sudo_mode rm -rf $root/.prec/* || true
print_message "Creating cache directory"
$sudo_mode mkdir -p $root/.prec || true
$sudo_mode chmod 777 $root/.prec || true
$sudo_mode chown -R $www_user $root || true
target_site="fizlesh.local"
if echo $host | grep -q math-lesh ; then
if [ "$mode" = "production" ] ; then
if [ "$service_name" = "fizlesh" ] ; then
target_site="fizlesh.ru"
elif [ "$service_name" = "lesh.org" ] ; then
target_site="lesh.org.ru"
fi
fi
else
if [ "$mode" = "production" ] ; then
target_site="fizlesh.ru"
elif [ "$mode" = "testing" ] ; then
target_site="test.fizlesh.ru"
fi
fi
print_message "Rebuilding aliases..."
curl "http://$target_site/?ref=rebuild_aliases"
if ! [ "$mode" = "production" ] ; then
print_message "Clear notifications and prepare mailer test configuration..."
curl "http://$target_site/?ref=prepare_mailer_in_testing"
fi
xcms_install_version_file
# version css files after installation
xcms_version_css "$root" "engine_public"
xcms_version_css "$root" "fizlesh.ru-design"
xcms_version_css "$root" "lesh.org.ru-design"
set +x
print_message "$program_name [$service_name] was successfully deployed to '$root' in mode '$mode'"