-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_sf.sh
executable file
·156 lines (140 loc) · 5.1 KB
/
install_sf.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
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
150
151
152
153
154
155
156
#!/bin/bash
###############################################################################
## Automated "clean" Symfony(v2.8) installer
## Authors:
## Armas Spann
## inspired by Martin Bieder
## CreationDate: 2016-03-16
###############################################################################
## including helpers..
installer_path=$(dirname `readlink -f $0`)
source ${installer_path}/helper/helper.sh
## Additional test configuration (config_test.yml) - base64 encoded
CONFTST_YML_B64="ZG9jdHJpbmU6DQogIGRiYWw6DQogICAgICAgIGRlZmF1bHRfY29ubmVjdGlvb\
jogZGVmYXVsdA0KICAgICAgICBjb25uZWN0aW9uczoNCiAgICAgICAgICAgIGRlZmF1bHQ6DQogICA\
gICAgICAgICAgICAgZHJpdmVyOiAgIHBkb19zcWxpdGUNCiAgICAgICAgICAgICAgICBwYXRoOiAgI\
CAgJyVrZXJuZWwuY2FjaGVfZGlyJS9kYXRhLnNxbGl0ZSc="
## Welcome message
prntMessage "=== Symfony Framework installer (2.8) ===\n"
function help {
prntMessage "usage: $0 <project_name> [<options>]\n<options>:\n -f force overwrite\n -h help$1\n -u updates install_sf (if available)\n -y yes to all questions"
}
## checking if $1 (project_name) is set
if [[ -z $1 ]]; then
help " (this message)"
exit 0;
else
parms="$@"
## parsing options..
while [[ $# -gt 0 ]]; do
case "$1" in
-u|-au|--update)
prntMessage "Try to Update myself..."
real_app=$(readlink -eq `whereis install_sf | cut -d ' ' -f2`)
real_app_dir=$(dirname ${real_app})
if [[ -d ${real_app_dir} ]]; then
if [[ $EUID -ne 0 && ${suCmd} != "sudo sh -c" ]]; then echo -n "root-"; fi
$(${suCmd} "cd ${real_app_dir} && git pull >/dev/null 2>&1")
prntMessage "Updated succeeded, please rerun." "ok"
else
prntMessage "Update failed." "err"
fi
exit 0; ;;
-h|--h|--help)
help " (this message)"; exit 0; ;;
-f)
opt_force=true; ;;
-y)
opt_y2all=true; ;;
-fy|-yf)
opt_force=true
opt_y2all=true
;;
*)
if [[ ! ${project_name} ]] && [[ ! $1 == -* ]]; then
project_name=$1
else
prntMessage ">>> Invalid option: $1" "err"; echo
help; exit 0
fi
esac
shift
done
## checking paths... (existence)
if [[ -d ${project_name} ]] && [[ ${opt_force} ]]; then
prntWithSpaces "Deleting existing project '${project_name}' due -f option..."
rm -rf ${project_name}
if [[ -d ${project_name} ]]; then
prntERR; exit 1;
fi
prntOK
elif [[ -d ${project_name} ]]; then
prntCRIT "Sorry, project '${project_name}' exists already."
fi
if [[ ${opt_y2all} ]]; then
prntWithSpaces "Enabeling 'yes to all' due -y option..."
prntOK
fi; echo
fi
## checking for binaries
prntMessage "Checking for needed binaries/aliases..."
chkBinMulti "awk, base64, bash, bower, curl, df, npm, php, sed, whereis, composer, symfony"
if [[ $SH_ERROR -eq 1 ]]; then
prntCRIT "Sorry some dependencies are missing. please fix them!"
else
## determine composer path ()
if [[ `builtin type composer 2>/dev/null` ]]; then
composer="composer"
else
composer=$(echo -e $(bash -i -c "alias" \
| awk -v FS="(composer=| alias=)" '{print $2}') | tr -d '[[:space:]]')
composer=${composer:1:-1}
fi
## checking for enough free space on /tmp
tmppath="/tmp"
tmpnspace=50
tmpmount=$(df | grep ${tmppath})
prntWithSpaces "Checking for enough(${tmpnspace}M) free disk space on '${tmppath}'..."
if [[ ! -z ${tmpmount} ]]; then
tmpsleft=$(echo ${tmpmount} | awk '{print $4}')
if [[ ! -z ${tmpsleft} ]] && [[ ${tmpsleft} -ge $((tmpnspace*1024)) ]]; then
prntOK
else
prntERR
prntCRIT "Sorry not enough free disk space on '${tmppath}'. please fix it!"
fi
else
prntOK
fi
fi; echo
## preparing symfony base-installation...
prntWithSpaces "Installing Symfony 2.8..."
symfony new ${project_name} 2.8 >/dev/null 2>&1
if [[ -d ${project_name} ]]; then
prntOK
## installing bundle files
for bundle in ${installer_path}/mod_bundle/*.bundle; do
if [[ ! ${opt_y2all} ]]; then
read -p "Install $(basename $bundle | \
sed -s 's/.bundle//g')? (y/n): " -n 1 -r
echo
else
REPLY="y"
fi
if [[ $REPLY =~ ^[YyJj]$ ]]; then
source ${bundle};
fi
done
## finalizing install (comperser update)
prntWithSpaces "Finalizing Symfony 2.8 (composer update)..."
$(cd ${project_name} && eval ${composer} update >/dev/null 2>&1)
prntOK; echo
## patching config_test.yml
prntWithSpaces "Fixing test-environment..."
echo $CONFTST_YML_B64 | base64 -d >> ${project_name}/app/config/config_test.yml
prntOK
else
prntCRIT "Sorry, can't install Symfony 2.8."
fi; echo
prntMessage "Symfony 2.8 setup complete."
exit 0