Skip to content

Commit 8f3eca7

Browse files
committed
fix(shell): SC2086 auto apply
1 parent be08c12 commit 8f3eca7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+699
-699
lines changed

docker/mysql-xtrabackup/xbackup.sh

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ DATABASE_FILE=/root/xtrabackup.database.txt
157157

158158
if [ "x${RESETDATABASE}" = "x1" ]; then
159159
# write the file containing the name of the DB xtrabackup should store data in
160-
echo ${NEWDATABASENAME} > ${DATABASE_FILE}
160+
echo "${NEWDATABASENAME}" > ${DATABASE_FILE}
161161
chmod 600 ${DATABASE_FILE}
162162
fi
163163

@@ -199,31 +199,31 @@ EOF
199199
##############################################################
200200

201201
_df() {
202-
df -P -B 1K $1|tail -n-1|awk '{print $4}'
202+
df -P -B 1K "$1"|tail -n-1|awk '{print $4}'
203203
}
204204

205205
_df_h() {
206-
df -Ph $1|tail -n-1|awk '{print $4}'
206+
df -Ph "$1"|tail -n-1|awk '{print $4}'
207207
}
208208

209209
_du_r() {
210-
du -B 1K --max-depth=0 $1|awk '{print $1}'
210+
du -B 1K --max-depth=0 "$1"|awk '{print $1}'
211211
}
212212

213213
_du_h() {
214-
du -h --max-depth=0 $1|awk '{print $1}'
214+
du -h --max-depth=0 "$1"|awk '{print $1}'
215215
}
216216

217217
_s_inf() {
218-
echo "$(date +%Y-%m-%d_%H_%M_%S) xbackup $1" | tee -a ${INF_FILE_WORK}
218+
echo "$(date +%Y-%m-%d_%H_%M_%S) xbackup $1" | tee -a "${INF_FILE_WORK}"
219219
}
220220

221221
_echo() {
222222
echo "$(date +%Y-%m-%d_%H_%M_%S) xbackup $1"
223223
}
224224

225225
_d_inf() {
226-
echo "$(date +%Y-%m-%d_%H_%M_%S) xbackup $1" | tee -a ${INF_FILE_WORK}
226+
echo "$(date +%Y-%m-%d_%H_%M_%S) xbackup $1" | tee -a "${INF_FILE_WORK}"
227227
exit 1
228228
}
229229

@@ -418,7 +418,7 @@ _s_inf "INFO: Backup type: ${BKP_TYPE}"
418418
[ -d ${STOR_DIR} ] || \
419419
_d_inf "ERROR: STOR_DIR ${STOR_DIR} does not exist, \
420420
I will not create this automatically!"
421-
[ -d ${WORK_DIR} ] || \
421+
[ -d "${WORK_DIR}" ] || \
422422
_d_inf "ERROR: WORK_DIR ${WORK_DIR} does not exist, \
423423
I will not create this automatically!"
424424

@@ -466,7 +466,7 @@ fi
466466
#
467467
if [ "${BKP_TYPE}" = "incr" ]; then
468468
if [ -n "${INC_BSEDIR}" ]; then
469-
if [ ! -d ${WORK_DIR}/bkps/${INC_BSEDIR} ]; then
469+
if [ ! -d "${WORK_DIR}"/bkps/"${INC_BSEDIR}" ]; then
470470
_d_inf "ERROR: Specified incremental basedir ${WORK_DIR}/bkps/${_inc_basedir} does not exist.";
471471
fi
472472

@@ -496,10 +496,10 @@ else
496496
fi
497497

498498
# Check for work directory
499-
if [ ! -d ${WORK_DIR} ]; then _d_inf "ERROR: XtraBackup work directory does not exist"; fi
499+
if [ ! -d "${WORK_DIR}" ]; then _d_inf "ERROR: XtraBackup work directory does not exist"; fi
500500

501-
DATASIZE=$(_du_r ${DATADIR})
502-
DISKSPCE=$(_df ${WORK_DIR})
501+
DATASIZE=$(_du_r "${DATADIR}")
502+
DISKSPCE=$(_df "${WORK_DIR}")
503503
HASSPACE=$(echo "${DATASIZE} ${DISKSPCE}"|awk '{if($1 < $2) {print 1} else {print 0}}')
504504
NOSPACE=0
505505

@@ -514,7 +514,7 @@ echo
514514
# Keep track if any errors happen
515515
_status=0
516516

517-
cd ${WORK_DIR}/bkps/
517+
cd "${WORK_DIR}"/bkps/
518518
_s_inf "INFO: Backing up with: ${_ibx_bkp}"
519519
${_ibx_bkp}
520520
RETVAR=$?
@@ -536,11 +536,11 @@ echo
536536
_echo "INFO: Syncing binary log snapshots"
537537
if [ -n "${_last_bkp}" ]; then
538538
_first_bkp_since=$(_sql_first_backup_elapsed)
539-
> ${WORK_DIR}/bkps/binlog.index
539+
> "${WORK_DIR}"/bkps/binlog.index
540540

541541
_echo "INFO: Getting a list of binary logs to copy"
542-
for f in $(cat ${BNLGDIR}/${BNLGFMT}.index); do
543-
echo $(basename ${f}) >> ${WORK_DIR}/bkps/binlog.index
542+
for f in $(cat "${BNLGDIR}"/${BNLGFMT}.index); do
543+
echo $(basename "${f}") >> "${WORK_DIR}"/bkps/binlog.index
544544
done
545545

546546
if [ "${STOR_CMP}" = 1 ]; then
@@ -562,28 +562,28 @@ if [ -n "${_last_bkp}" ]; then
562562
if [ -n "${_xbinlog_info}" -a -f "${_xbinlog_info}" ]; then
563563
_echo "INFO: Found last binlog information ${_xbinlog_info}"
564564

565-
_last_binlog=$(cat ${_xbinlog_info}|awk '{print $1}')
565+
_last_binlog=$(cat "${_xbinlog_info}"|awk '{print $1}')
566566

567-
cd ${BNLGDIR}
567+
cd "${BNLGDIR}"
568568

569-
for f in $(grep -A $(cat ${WORK_DIR}/bkps/binlog.index|wc -l) "${_last_binlog}" ${WORK_DIR}/bkps/binlog.index); do
569+
for f in $(grep -A $(cat "${WORK_DIR}"/bkps/binlog.index|wc -l) "${_last_binlog}" "${WORK_DIR}"/bkps/binlog.index); do
570570
if [ "${STOR_CMP}" = 1 ]; then
571571
[ -f "${_this_stor}/bnlg/${f}.tar.gz" ] && rm -rf "${_this_stor}/bnlg/${f}.tar.gz"
572-
tar czvf "${_this_stor}/bnlg/${f}.tar.gz" ${f}
572+
tar czvf "${_this_stor}/bnlg/${f}.tar.gz" "${f}"
573573
else
574574
[ -f "${_this_stor}/bnlg/${f}" ] && rm -rf "${_this_stor}/bnlg/${f}"
575-
cp -v ${f} "${_this_stor}/bnlg/"
575+
cp -v "${f}" "${_this_stor}/bnlg/"
576576
fi
577577
done
578578

579579
if [ -f "${_this_stor}/bnlg/${BNLGFMT}.index" ]; then rm -rf "${_this_stor}/bnlg/${BNLGFMT}.index"; fi
580-
cp ${BNLGFMT}.index ${_this_stor}/bnlg/${BNLGFMT}.index
581-
cd ${WORK_DIR}/bkps/
580+
cp ${BNLGFMT}.index "${_this_stor}"/bnlg/${BNLGFMT}.index
581+
cd "${WORK_DIR}"/bkps/
582582
fi
583583

584584
if [ -n "${_first_bkp_since}" -a "${_first_bkp_since}" -gt 0 ]; then
585585
_echo "INFO: Deleting archived binary logs older than ${_first_bkp_since} minutes ago"
586-
find ${_this_stor}/bnlg/ -mmin +${_first_bkp_since} -exec rm -rf {} \;
586+
find "${_this_stor}"/bnlg/ -mmin +"${_first_bkp_since}" -exec rm -rf {} \;
587587
fi
588588
fi
589589
_echo " ... done"
@@ -596,12 +596,12 @@ if [ -n "${STOR_DIR}" ]; then
596596
echo
597597
_echo "INFO: Copying to immediate storage ${STOR_DIR}/bkps/"
598598
if [ "${STOR_CMP}" = 1 ]; then
599-
tar czvf ${STOR_DIR}/bkps/${CURDATE}.tar.gz ${CURDATE}
599+
tar czvf ${STOR_DIR}/bkps/"${CURDATE}".tar.gz "${CURDATE}"
600600
ret=$?
601-
[ -f ${_this_bkp}/xtrabackup_binlog_info ] \
602-
&& cp ${_this_bkp}/xtrabackup_binlog_info ${STOR_DIR}/bkps/${CURDATE}-xtrabackup_binlog_info.log
601+
[ -f "${_this_bkp}"/xtrabackup_binlog_info ] \
602+
&& cp "${_this_bkp}"/xtrabackup_binlog_info ${STOR_DIR}/bkps/"${CURDATE}"-xtrabackup_binlog_info.log
603603
else
604-
cp -r ${_this_bkp}* ${STOR_DIR}/bkps/
604+
cp -r "${_this_bkp}"* ${STOR_DIR}/bkps/
605605
ret=$?
606606
fi
607607

@@ -611,36 +611,36 @@ if [ -n "${STOR_DIR}" ]; then
611611
# Delete backup on work dir if no apply log is needed
612612
elif [ "x${APPLY_LOG}" = "x0" ]; then
613613
_echo "INFO: Cleaning up ${WORK_DIR}/bkps/"
614-
cd ${WORK_DIR}/bkps/
614+
cd "${WORK_DIR}"/bkps/
615615
if [ "x${STOR_CMP}" != "x1" ]; then
616616
_rxp="${CURDATE}[-info]?+.log"
617617
else
618618
_rxp="${CURDATE}[-info.log]?"
619619
fi
620620
_echo "\"ls | grep -Ev ${_rxp}\""
621621
ls | grep -Ev "${_rxp}"
622-
for f in $(ls | grep -Ev ${_rxp}); do rm -rf ${f}; done
622+
for f in $(ls | grep -Ev "${_rxp}"); do rm -rf "${f}"; done
623623
# We also delete the previous incremental if the backup has been successful
624624
elif [ "${BKP_TYPE}" = "incr" ]; then
625625
_echo "INFO: Deleting previous incremental ${WORK_DIR}/bkps/${_inc_basedir}"
626-
rm -rf ${WORK_DIR}/bkps/${_inc_basedir}*;
626+
rm -rf "${WORK_DIR}"/bkps/"${_inc_basedir}"*;
627627
elif [ "${BKP_TYPE}" = "full" ]; then
628-
_echo "INFO: Deleting previous work backups $(find ${WORK_DIR}/bkps/ -maxdepth 1 -mindepth 1|grep -v ${CURDATE}|xargs)"
629-
rm -rf $(find ${WORK_DIR}/bkps/ -maxdepth 1 -mindepth 1|grep -v ${CURDATE}|xargs)
628+
_echo "INFO: Deleting previous work backups $(find "${WORK_DIR}"/bkps/ -maxdepth 1 -mindepth 1|grep -v "${CURDATE}"|xargs)"
629+
rm -rf $(find "${WORK_DIR}"/bkps/ -maxdepth 1 -mindepth 1|grep -v "${CURDATE}"|xargs)
630630
fi
631631
_echo " ... done"
632632
fi
633633

634634
if [[ -n "${RMTE_DIR}" && -n "${RMTE_SSH}" ]]; then
635635
echo
636636
_echo "INFO: Syncing backup sets to remote ${RMTE_SSH}:${RMTE_DIR}/"
637-
rsync -avzp --delete -e ssh ${STOR_DIR}/ ${RMTE_SSH}:${RMTE_DIR}/
637+
rsync -avzp --delete -e ssh ${STOR_DIR}/ "${RMTE_SSH}":"${RMTE_DIR}"/
638638
if [ "$?" -gt 0 ]; then _s_inf "WARNING: Failed to sync ${STOR_DIR} to ${RMTE_SSH}:${RMTE_DIR}/"; fi
639639
_echo " ... done"
640640
fi
641641

642642
if [ "${BKP_TYPE}" = "incr" ]; then
643-
set -- $(_sql_incr_bsedir ${_week_no})
643+
set -- $(_sql_incr_bsedir "${_week_no}")
644644
_incr_base=$1
645645
_incr_baseid=$2
646646
_incr_basedir=${_incr_base}
@@ -674,13 +674,13 @@ if [ "${status}" != 1 ]; then
674674
else
675675
_apply_to="${WORK_DIR}/bkps/P_${CURDATE}"
676676
# Check to make sure we have enough disk space to make a copy
677-
_bu_size=$(_du_r ${_this_bkp})
678-
_du_left=$(_df ${WORK_DIR})
677+
_bu_size=$(_du_r "${_this_bkp}")
678+
_du_left=$(_df "${WORK_DIR}")
679679
if [ "${_bu_size}" -gt "${_du_left}" ]; then
680680
_d_inf "ERROR: Apply to copy was specified, however there is not \
681681
enough disk space left on device.";
682682
else
683-
cp -r ${_this_bkp} ${_apply_to}
683+
cp -r "${_this_bkp}" "${_apply_to}"
684684
fi
685685

686686
_ibx_prep="${_ibx_prep} --apply-log --redo-only ${_apply_to}"
@@ -704,7 +704,7 @@ if [ "${RETVAR}" -gt 0 ]; then
704704
Something may have failed! Please prepare, I have not deleted the \
705705
new backup directory.";
706706
elif [ "x${STOR_CMP}" != "x1" ]; then
707-
rm -rf ${_this_bkp}
707+
rm -rf "${_this_bkp}"
708708
fi
709709

710710
# End, whether apply log is enabled
@@ -721,8 +721,8 @@ if [ "${BKP_TYPE}" = "incr" ]; then
721721
else
722722
_incr_basedir="NULL"
723723
fi
724-
[ -d "${_this_bkp}" ] && _bu_size=$(_du_h ${_this_bkp}) || _bu_size=$(_du_h ${_this_bkp_stored})
725-
_du_left=$(_df_h ${WORK_DIR})
724+
[ -d "${_this_bkp}" ] && _bu_size=$(_du_h "${_this_bkp}") || _bu_size=$(_du_h "${_this_bkp_stored}")
725+
_du_left=$(_df_h "${WORK_DIR}")
726726

727727
_sql_save_bkp "${_started_at}" "${_ends_at}" "${_bu_size}" \
728728
"${STOR_DIR}/bkps/${CURDATE}" "${_incr_basedir}" \
@@ -733,11 +733,11 @@ _echo "INFO: Cleaning up previous backup files:"
733733
# Find the ids of base backups first.
734734
_prune_base=$(_sql_prune_base)
735735
if [ -n "${_prune_base}" ]; then
736-
_prune_list=$(_sql_prune_list ${_prune_base})
736+
_prune_list=$(_sql_prune_list "${_prune_base}")
737737
if [ -n "${_prune_list}" ]; then
738738
_echo "INFO: Deleting backups: ${_prune_list}"
739-
_sql_prune_rows ${_prune_base}
740-
cd ${STOR_DIR}/bkps && rm -rf ${_prune_list}
739+
_sql_prune_rows "${_prune_base}"
740+
cd ${STOR_DIR}/bkps && rm -rf "${_prune_list}"
741741
fi
742742
fi
743743
_echo " ... done"
@@ -753,7 +753,7 @@ _s_inf "INFO: Remaining space available on backup device: ${_du_left}"
753753
_s_inf "INFO: Logfile: ${LOG_FILE}"
754754
[ "x${APPLY_LOG}" = "x1" ] && \
755755
_s_inf "INFO: Last full backup fully prepared (including incrementals): ${_last_full_prep}"
756-
cp ${INF_FILE_WORK} ${INF_FILE_STOR}
756+
cp "${INF_FILE_WORK}" "${INF_FILE_STOR}"
757757
echo
758758

759759
rm -rf /tmp/xbackup.lock

docker/mysql-xtrabackup/xrecovery.sh

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -37,34 +37,34 @@ done
3737

3838
rm -rf ${WORKDIR} chain-search.txt chain.txt
3939

40-
if [ ! -f ${CURLOG}.tar.gz ]; then
41-
echo recovery: invalid starting point ${CURLOG}.tar.gz
40+
if [ ! -f "${CURLOG}".tar.gz ]; then
41+
echo recovery: invalid starting point "${CURLOG}".tar.gz
4242
exit 1
4343
fi
4444

4545
# do-while
4646
while : ; do
47-
if [ ! -f ${CURLOG}-info.log ]; then
48-
echo recovery: cannot find target log ${CURLOG}-info.log
47+
if [ ! -f "${CURLOG}"-info.log ]; then
48+
echo recovery: cannot find target log "${CURLOG}"-info.log
4949
exit 1
5050
fi
51-
if [ ! -f ${CURLOG}.tar.gz ]; then
52-
echo recovery: cannot find target archive ${CURLOG}.tar.gz
51+
if [ ! -f "${CURLOG}".tar.gz ]; then
52+
echo recovery: cannot find target archive "${CURLOG}".tar.gz
5353
exit 1
5454
fi
5555
# identify the type of log
56-
CURTYPE=$(grep 'xbackup INFO: Backup type:' ${CURLOG}-info.log | cut -f 6 -d " ")
56+
CURTYPE=$(grep 'xbackup INFO: Backup type:' "${CURLOG}"-info.log | cut -f 6 -d " ")
5757
if [[ -z "${CURTYPE// }" ]]; then
5858
# not sure I get how this is happening
5959
CURTYPE=full
6060
fi
61-
echo recovery: found ${CURLOG}, ${CURTYPE}
62-
echo ${CURLOG} >> chain-search.txt
61+
echo recovery: found "${CURLOG}", "${CURTYPE}"
62+
echo "${CURLOG}" >> chain-search.txt
6363
# are we done?
6464
[[ ${CURTYPE} = full ]] && break
6565
echo recovery: following chain...
6666
# parse the current log to find the parent
67-
NEWLOG=$(grep -- --incremental-basedir ${CURLOG}-info.log | perl -pe 's~.*incremental-basedir /[^[:space:]]*/([^[:space:]]*).*?~\1~')
67+
NEWLOG=$(grep -- --incremental-basedir "${CURLOG}"-info.log | perl -pe 's~.*incremental-basedir /[^[:space:]]*/([^[:space:]]*).*?~\1~')
6868
if [[ ${CURLOG} = ${NEWLOG} || "${NEWLOG}" = "" ]]; then
6969
echo recovery: could not parse next target, failure
7070
exit 1
@@ -82,40 +82,40 @@ echo recovery: recovery plan ready!
8282
CURLINE=1
8383
MAXLINE=$(cat chain.txt | wc -l)
8484
while read line; do
85-
rm -rf ${line}
86-
tar -zxf ${line}.tar.gz
87-
if [ ${MAXLINE} -eq 1 ]; then
88-
echo recovery: process single backup ${line}
89-
xtrabackup --use-memory ${USE_MEMORY} --prepare --target-dir=${line}
85+
rm -rf "${line}"
86+
tar -zxf "${line}".tar.gz
87+
if [ "${MAXLINE}" -eq 1 ]; then
88+
echo recovery: process single backup "${line}"
89+
xtrabackup --use-memory "${USE_MEMORY}" --prepare --target-dir="${line}"
9090
if [ $? -ne 0 ]; then
9191
echo recovery: backup preparation failed! not deleting workdir
9292
exit 1
9393
fi
94-
mv ${line} ${WORKDIR}
94+
mv "${line}" ${WORKDIR}
9595
elif [ ${CURLINE} -eq 1 ]; then
96-
echo recovery: obtain full backup ${line}
97-
xtrabackup --use-memory ${USE_MEMORY} --prepare --apply-log-only --target-dir=${line}
96+
echo recovery: obtain full backup "${line}"
97+
xtrabackup --use-memory "${USE_MEMORY}" --prepare --apply-log-only --target-dir="${line}"
9898
if [ $? -ne 0 ]; then
9999
echo recovery: initial backup preparation failed! not deleting workdir
100100
exit 1
101101
fi
102-
mv ${line} ${WORKDIR}
103-
elif [ ${CURLINE} -lt ${MAXLINE} ]; then
104-
echo recovery: apply intermediate incremental ${line}
105-
xtrabackup --use-memory ${USE_MEMORY} --prepare --apply-log-only --target-dir=${WORKDIR} --incremental-dir=$(pwd)/${line}
102+
mv "${line}" ${WORKDIR}
103+
elif [ ${CURLINE} -lt "${MAXLINE}" ]; then
104+
echo recovery: apply intermediate incremental "${line}"
105+
xtrabackup --use-memory "${USE_MEMORY}" --prepare --apply-log-only --target-dir=${WORKDIR} --incremental-dir=$(pwd)/"${line}"
106106
if [ $? -ne 0 ]; then
107107
echo recovery: intermediate recovery failed! not deleting workdir
108108
exit 1
109109
fi
110-
rm -rf ${line}
110+
rm -rf "${line}"
111111
else
112-
echo recovery: apply final incremental ${line}
113-
xtrabackup --use-memory ${USE_MEMORY} --prepare --target-dir=${WORKDIR} --incremental-dir=${line}
112+
echo recovery: apply final incremental "${line}"
113+
xtrabackup --use-memory "${USE_MEMORY}" --prepare --target-dir=${WORKDIR} --incremental-dir="${line}"
114114
if [ $? -ne 0 ]; then
115115
echo recovery: final incremental failed! not deleting workdir
116116
exit 1
117117
fi
118-
rm -rf ${line}
118+
rm -rf "${line}"
119119
fi
120120
CURLINE=$((${CURLINE}+1))
121121
done < chain.txt

docker/openemr/7.0.3/openemr.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ auto_setup() {
4242
echo "opcache.max_accelerated_files=1000000" >> auto_configure.ini
4343

4444
#run auto_configure
45-
php auto_configure.php -c auto_configure.ini -f ${CONFIGURATION} || return 1
45+
php auto_configure.php -c auto_configure.ini -f "${CONFIGURATION}" || return 1
4646

4747
#remove temporary file cache directory and auto_configure.ini
4848
rm -r ${TMP_FILE_CACHE_LOCATION}
@@ -246,12 +246,12 @@ if
246246
while [ "${c}" -le "${DOCKER_VERSION_ROOT}" ]; do
247247
if [ "${c}" -gt "${DOCKER_VERSION_SITES}" ] ; then
248248
echo "Start: Processing fsupgrade-${c}.sh upgrade script"
249-
sh /root/fsupgrade-${c}.sh
249+
sh /root/fsupgrade-"${c}".sh
250250
echo "Completed: Processing fsupgrade-${c}.sh upgrade script"
251251
fi
252252
c=$(( c + 1 ))
253253
done
254-
echo -n ${DOCKER_VERSION_ROOT} > /var/www/localhost/htdocs/openemr/sites/default/docker-version
254+
echo -n "${DOCKER_VERSION_ROOT}" > /var/www/localhost/htdocs/openemr/sites/default/docker-version
255255
echo "Completed upgrade"
256256
fi
257257
fi

0 commit comments

Comments
 (0)