Skip to content

Commit 20a6026

Browse files
committed
Improve logging output, using read for arrays
1 parent a0d8fc4 commit 20a6026

1 file changed

Lines changed: 12 additions & 13 deletions

File tree

  • root/etc/s6-overlay/s6-rc.d/init-mod-universal-package-install-add-package
Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,31 @@
11
#!/usr/bin/with-contenv bash
2+
# shellcheck shell=bash
23

34
# Exit if no installable packages are provided
4-
if [ -z "${INSTALL_PACKAGES+x}" ] && [ -z "${INSTALL_PIP_PACKAGES+x}" ]; then
5-
echo "**** No packages to install ****"
5+
if [[ -z "${INSTALL_PACKAGES+x}" ]] && [[ -z "${INSTALL_PIP_PACKAGES+x}" ]]; then
6+
echo "[pkg-install-init] **** No packages to install ****"
67
exit 0
78
fi
89

9-
if [ -n "${INSTALL_PIP_PACKAGES}" ] && [ -f /usr/bin/apt ]; then
10+
if [[ -n "${INSTALL_PIP_PACKAGES}" ]] && [[ -f /usr/bin/apt ]]; then
1011
echo "\
1112
python3-dev \
1213
python3-pip" >> /mod-repo-packages-to-install.list
13-
elif [ -n "${INSTALL_PIP_PACKAGES}" ] && [ -f /sbin/apk ]; then
14+
elif [[ -n "${INSTALL_PIP_PACKAGES}" ]] && [[ -f /sbin/apk ]]; then
1415
echo "\
1516
python3-dev \
1617
py3-pip" >> /mod-repo-packages-to-install.list
1718
fi
1819

19-
20-
#Split list of packages on delimiter '|'
21-
IFS='|'
22-
INSTALL_PACKAGES=(${INSTALL_PACKAGES})
23-
for PKG in "${INSTALL_PACKAGES[@]}"; do
24-
echo "**** Adding ${PKG} to OS package install list ****"
20+
# Split list of packages on delimiter '|'
21+
IFS="|" read -r -a SPLIT_INSTALL_PACKAGES <<< "${INSTALL_PACKAGES}"
22+
for PKG in "${SPLIT_INSTALL_PACKAGES[@]}"; do
23+
echo "[pkg-install-init] **** Adding ${PKG} to OS package install list ****"
2524
echo "${PKG}" >> /mod-repo-packages-to-install.list
2625
done
2726

28-
INSTALL_PIP_PACKAGES=(${INSTALL_PIP_PACKAGES})
29-
for PKG in "${INSTALL_PIP_PACKAGES[@]}"; do
30-
echo "**** Adding ${PKG} to pip install list ****"
27+
IFS="|" read -r -a SPLIT_INSTALL_PIP_PACKAGES <<< "${INSTALL_PIP_PACKAGES}"
28+
for PKG in "${SPLIT_INSTALL_PIP_PACKAGES[@]}"; do
29+
echo "[pkg-install-init] **** Adding ${PKG} to pip install list ****"
3130
echo "${PKG}" >> /mod-pip-packages-to-install.list
3231
done

0 commit comments

Comments
 (0)