-
Notifications
You must be signed in to change notification settings - Fork 10
/
install
218 lines (131 loc) · 5.16 KB
/
install
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#!/usr/bin/env bash
### ############################################################################
### initialize script with standard synthia bootstrapping block.
### ############################################################################
#### 1 | add padding to output / clear screen.
### ############################################################################
### evaluate arguments.
### ############################################################################
if [ "${custom_output-null}" = "v" ]
then
echo "Printing verbose output as per | -o v |."
echo
set -x
fi
if [[ "${@#--return-check}" = "$@" ]]
then
echo "This script must not be run directly."
echo
echo "You should instead run the | setup | script and it will take care of the installation itself."
echo
echo "Exiting..."
echo
exit 1
fi
### ############################################################################
### continue script initialization.
### ############################################################################
#### 2 | locate execution environment and perform synthia-bound operations.
#### ###########################################################################
##### set bash environment error management.
set -eu
##### determine script execution directory and install directory.
if [ -L "${BASH_SOURCE}" ]
then
###### this file is being executed via a symlink.
###### therefore identify the parent directory of the target file.
link_target="$(readlink ${BASH_SOURCE})"
exec_dir="${link_target%/*}"
else
###### this file is being directly executed.
###### therefore identify our parent directory.
exec_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
fi
exec_dir_trim_2="$( echo ${exec_dir} | cut -f 1,2,3 -d'/')"
exec_dir_trim_3="$( echo ${exec_dir} | cut -f 1,2,3,4 -d'/')"
if [ -f "${exec_dir_trim_2}/functions" ]
then
exec_dir_root="${exec_dir_trim_2}"
else
if [ -f "${exec_dir_trim_3}/functions" ]
then
exec_dir_root="${exec_dir_trim_3}"
else
echo "Functions file not found in any second or third level parent directory of: | ${exec_dir} |."
echo
echo "Exiting..."
echo
exit 1
fi
fi
##### source local functions file.
. "$exec_dir_root/functions"
##### define formatting.
synthia-define_formatting
##### check for root user runtime.
synthia-check_root
#### ###########################################################################
#### 3 | source dna and perform dna-bound operations.
#### ###########################################################################
##### ensure that the dna version required hasn't changed due to a new version
##### of this very project being installed.
if [ -z "${custom_dna_version-}" ]
then
## no custom dna version was requested upon running the setup script.
## let's check if an upgrade to the project itself has changed the required
## dna version.
dna_selected_vers="$(cat "${os_base_dir}/dna/version_installed")"
if [ "${dna_version}" != "${dna_selected_vers}" ]
then
echo "${l-}${b-}Now upgrading version of dna as required by the newly upgraded version of this very project which was just fetched...${x-}"
echo
synthia-download_dna
echo
fi
fi
##### source dna.
synthia-source_dna
##### define variables.
synthia-define_vars
##### read conf settings.
dna-read_conf_settings
##### touch temp dir.
dna-touch_tmp_project_dir
#### ###########################################################################
#### 4 | head/log script.
dna-log_script -i
### ############################################################################
### actually start script operations.
### ############################################################################
#### preflight checks.
#### ###########################################################################
##### check for any already existing installation.
dna-check_install_version
##### install repo contents into destination dir.
dna-echo_operation -h "installing repository contents into destination directory"
##### install rsync if it isn't yet [like in debian].
if ! dpkg -s rsync &> /dev/null
then
dna-install_dependencies -p "rsync"
fi
##### proceed with rsync.
rsync -aAXx "${source_dir}/" "${install_dir}/" --include=tools*** --include=functions --exclude="*"
dna-link_tools
dna-echo_operation -t
#### ###########################################################################
#### proceed with installation.
#### ###########################################################################
if [ ! "${skip_full_installation-}" = "y" ]
then
##### echo install initialization.
dna-echo -m "Initiating install..."
##### perform installation.
synthia-perform_installation
fi
#### ###########################################################################
#### post-install.
#### ###########################################################################
##### mark installer as completed successfully.
touch "$source_dir/install_complete"
#### ###########################################################################
### ############################################################################