|
182 | 182 | # Check and update modules.
|
183 | 183 | if [ -n "${functionsdir}" ]; then
|
184 | 184 | if [ -d "${functionsdir}" ]; then
|
185 |
| - cd "${functionsdir}" || exit |
186 |
| - for functionfile in *; do |
187 |
| - # check if module exists in the repo and remove if missing. |
188 |
| - # commonly used if module names change. |
189 |
| - echo -en "checking ${remotereponame} module ${functionfile}...\c" |
190 |
| - github_file_url_dir="lgsm/functions" |
191 |
| - if [ "${remotereponame}" == "GitHub" ]; then |
192 |
| - curl --connect-timeout 10 -IsfL "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}" 1> /dev/null |
193 |
| - else |
194 |
| - curl --connect-timeout 10 -IsfL "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/${github_file_url_dir}/${functionfile}" 1> /dev/null |
195 |
| - fi |
196 |
| - if [ $? != 0 ]; then |
197 |
| - fn_print_error_eol_nl |
198 |
| - fn_script_log_error "Checking ${remotereponame} module ${functionfile}" |
199 |
| - echo -en "removing module ${functionfile}...\c" |
200 |
| - if ! rm -f "${functionfile:?}"; then |
201 |
| - fn_print_fail_eol_nl |
202 |
| - fn_script_log_fatal "Removing module ${functionfile}" |
203 |
| - core_exit.sh |
204 |
| - else |
205 |
| - fn_print_ok_eol_nl |
206 |
| - fn_script_log_pass "Removing module ${functionfile}" |
207 |
| - fi |
208 |
| - else |
209 |
| - # compare file |
| 185 | + ( |
| 186 | + cd "${functionsdir}" || exit |
| 187 | + for functionfile in *; do |
| 188 | + # check if module exists in the repo and remove if missing. |
| 189 | + # commonly used if module names change. |
| 190 | + echo -en "checking ${remotereponame} module ${functionfile}...\c" |
| 191 | + github_file_url_dir="lgsm/functions" |
210 | 192 | if [ "${remotereponame}" == "GitHub" ]; then
|
211 |
| - function_file_diff=$(diff "${functionsdir}/${functionfile}" <(curl --connect-timeout 10 -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}")) |
| 193 | + curl --connect-timeout 10 -IsfL "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}" 1> /dev/null |
212 | 194 | else
|
213 |
| - function_file_diff=$(diff "${functionsdir}/${functionfile}" <(curl --connect-timeout 10 -s "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/${github_file_url_dir}/${functionfile}")) |
| 195 | + curl --connect-timeout 10 -IsfL "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/${github_file_url_dir}/${functionfile}" 1> /dev/null |
214 | 196 | fi
|
215 |
| - |
216 |
| - # results |
217 |
| - if [ "${function_file_diff}" != "" ]; then |
218 |
| - fn_print_update_eol_nl |
219 |
| - fn_script_log_update "Checking ${remotereponame} module ${functionfile}" |
220 |
| - rm -rf "${functionsdir:?}/${functionfile}" |
221 |
| - fn_update_function |
| 197 | + if [ $? != 0 ]; then |
| 198 | + fn_print_error_eol_nl |
| 199 | + fn_script_log_error "Checking ${remotereponame} module ${functionfile}" |
| 200 | + echo -en "removing module ${functionfile}...\c" |
| 201 | + if ! rm -f "${functionfile:?}"; then |
| 202 | + fn_print_fail_eol_nl |
| 203 | + fn_script_log_fatal "Removing module ${functionfile}" |
| 204 | + core_exit.sh |
| 205 | + else |
| 206 | + fn_print_ok_eol_nl |
| 207 | + fn_script_log_pass "Removing module ${functionfile}" |
| 208 | + fi |
222 | 209 | else
|
223 |
| - fn_print_ok_eol_nl |
224 |
| - fn_script_log_pass "Checking ${remotereponame} module ${functionfile}" |
| 210 | + # compare file |
| 211 | + if [ "${remotereponame}" == "GitHub" ]; then |
| 212 | + function_file_diff=$(diff "${functionsdir}/${functionfile}" <(curl --connect-timeout 10 -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}")) |
| 213 | + else |
| 214 | + function_file_diff=$(diff "${functionsdir}/${functionfile}" <(curl --connect-timeout 10 -s "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/${github_file_url_dir}/${functionfile}")) |
| 215 | + fi |
| 216 | + |
| 217 | + # results |
| 218 | + if [ "${function_file_diff}" != "" ]; then |
| 219 | + fn_print_update_eol_nl |
| 220 | + fn_script_log_update "Checking ${remotereponame} module ${functionfile}" |
| 221 | + rm -rf "${functionsdir:?}/${functionfile}" |
| 222 | + fn_update_function |
| 223 | + else |
| 224 | + fn_print_ok_eol_nl |
| 225 | + fn_script_log_pass "Checking ${remotereponame} module ${functionfile}" |
| 226 | + fi |
225 | 227 | fi
|
226 |
| - fi |
227 |
| - done |
| 228 | + done |
| 229 | + ) |
228 | 230 | fi
|
229 | 231 | fi
|
230 | 232 |
|
|
0 commit comments