Skip to content

Commit

Permalink
Fix random docker errors
Browse files Browse the repository at this point in the history
Signed-off-by: Ethan Dye <[email protected]>
  • Loading branch information
ecdye committed Jan 13, 2025
1 parent 7de8980 commit a80a18f
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 19 deletions.
6 changes: 3 additions & 3 deletions build-image/first-boot.bash
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ if ! is_bookworm; then
rfkill unblock wifi # Wi-Fi is blocked by Raspi OS default since bullseye(?)
fi
webserver=/boot/webserver.bash
[[ -L $webserver ]] || ln -s /boot/firmware/webserver.bash "$webserver"
ln -sfn /boot/firmware/webserver.bash "$webserver"

if [[ "${debugmode:-on}" == "on" ]]; then
unset SILENT
Expand Down Expand Up @@ -93,7 +93,7 @@ hotSpot=${hotspot:-enable}
wifiSSID="$wifi_ssid"
# shellcheck source=/etc/openhabian.conf disable=SC2154
wifiPassword="$wifi_password"
if is_bookworm; then
if ! running_in_docker && is_bookworm; then
echo -n "$(timestamp) [openHABian] Setting up NetworkManager and Wi-Fi connection... "
systemctl enable --now NetworkManager

Expand All @@ -105,7 +105,7 @@ if is_bookworm; then
#elif [[ -z $wifiSSID ]]; then
elif grep -qs "up" /sys/class/net/eth0/operstate; then
# Actually check if ethernet is working
echo -n "$(timestamp) [openHABian] Setting up Ethernet connection... OK"
echo "$(timestamp) [openHABian] Setting up Ethernet connection... OK"
elif [[ -n $wifiSSID ]] && grep -qs "openHABian" /etc/wpa_supplicant/wpa_supplicant.conf && ! grep -qsE "^[[:space:]]*dtoverlay=(pi3-)?disable-wifi" /boot/config.txt; then
echo -n "$(timestamp) [openHABian] Checking if WiFi is working... "
if iwlist wlan0 scan |& grep -qs "Interface doesn't support scanning"; then
Expand Down
28 changes: 17 additions & 11 deletions functions/java-jre.bash
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,19 @@ openjdk_fetch_apt() {
local keyName="debian-bookworm"

echo -n "$(timestamp) [openHABian] Fetching OpenJDK ${1}... "
if ! cond_redirect add_keys "https://ftp-master.debian.org/keys/archive-key-12.asc" "$keyName"; then echo "FAILED (add keys)"; return 1; fi # Add keys for older systems that need them
echo "deb [signed-by=/usr/share/keyrings/${keyName}.gpg] http://deb.debian.org/debian/ unstable main" > /etc/apt/sources.list.d/java.list
if [[ $1 == "21" ]]; then
if ! cond_redirect add_keys "https://ftp-master.debian.org/keys/archive-key-12.asc" "$keyName"; then echo "FAILED (add keys)"; return 1; fi # Add keys for older systems that need them
echo "deb [signed-by=/usr/share/keyrings/${keyName}.gpg] http://deb.debian.org/debian/ unstable main" > /etc/apt/sources.list.d/java.list
# Avoid release mixing: prevent RPi from using the Debian distro for normal Raspbian packages
echo -e "Package: *\\nPin: release a=unstable\\nPin-Priority: 90\\n" > /etc/apt/preferences.d/limit-unstable
if ! cond_redirect apt-get update; then echo "FAILED (update apt lists)"; return 1; fi

if ! cond_redirect apt-get update; then echo "FAILED (update apt lists)"; return 1; fi
if ! cond_redirect dpkg --configure -a; then echo "FAILED (dpkg)"; return 1; fi
if cond_redirect apt-get install --download-only --yes "openjdk-${1}-jre-headless"; then echo "OK"; else echo "FAILED (download)"; return 1; fi

# Avoid release mixing: prevent RPi from using the Debian distro for normal Raspbian packages
# But wait until the package is actually installed to avoid breaking the system
echo -e "Package: *\\nPin: release a=unstable\\nPin-Priority: 90\\n" > /etc/apt/preferences.d/limit-unstable
cond_redirect apt-get update
if ! cond_redirect dpkg --configure -a; then echo "FAILED (dpkg)"; return 1; fi
if cond_redirect apt-get install --download-only --yes -t unstable "openjdk-${1}-jre-headless"; then echo "OK"; else echo "FAILED (download)"; return 1; fi
else
if ! cond_redirect dpkg --configure -a; then echo "FAILED (dpkg)"; return 1; fi
if cond_redirect apt-get install --download-only --yes "openjdk-${1}-jre-headless"; then echo "OK"; else echo "FAILED (download)"; return 1; fi
fi
}

## Install OpenJDK using APT repository.
Expand All @@ -94,7 +96,11 @@ openjdk_install_apt() {
openjdk_fetch_apt "$1"
echo -n "$(timestamp) [openHABian] Installing OpenJDK ${1}... "
cond_redirect java_alternatives_reset
if cond_redirect apt-get install --yes -o DPkg::Lock::Timeout="$APTTIMEOUT" -t unstable "openjdk-${1}-jre-headless"; then echo "OK"; else echo "FAILED"; return 1; fi
if [[ $1 == "21" ]]; then
if cond_redirect apt-get install --yes -o DPkg::Lock::Timeout="$APTTIMEOUT" -t unstable "openjdk-${1}-jre-headless"; then echo "OK"; else echo "FAILED"; return 1; fi
else
if cond_redirect apt-get install --yes -o DPkg::Lock::Timeout="$APTTIMEOUT" "openjdk-${1}-jre-headless"; then echo "OK"; else echo "FAILED"; return 1; fi
fi
else
echo -n "$(timestamp) [openHABian] Reconfiguring OpenJDK ${1}... "
cond_redirect java_alternatives_reset
Expand Down
6 changes: 3 additions & 3 deletions functions/nodejs-apps.bash
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ nodejs_setup() {
local temp


myDistro="$(lsb_release -sc)"
if [[ "$myDistro" == "n/a" ]]; then
myDistro=${osrelease:-bullseye}
myDistro="$(lsb_release -sc | head -1)"
if [[ "$myDistro" == "n/a" ]] || running_in_docker; then
myDistro=${osrelease:-bookworm}
fi
temp="$(mktemp "${TMPDIR:-/tmp}"/openhabian.XXXXX)"

Expand Down
2 changes: 2 additions & 0 deletions functions/openhabian.bash
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ system_check_default_password() {
## config_ipv6()
##
config_ipv6() {
if running_in_docker; then echo "$(timestamp) [openHABian] Making sure router advertisements are available... SKIPPED"; return 0; fi

local aptConf="/etc/apt/apt.conf.d/S90force-ipv4"
local sysctlConf="/etc/sysctl.d/99-sysctl.conf"

Expand Down
3 changes: 1 addition & 2 deletions functions/system.bash
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ system_upgrade() {
# bad packages may require interactive input despite of this setting so do not mask output (no cond_redirect)
if ! apt-get upgrade --yes -o DPkg::Lock::Timeout="$APTTIMEOUT" -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold"; then echo "FAILED"; return 1; fi
if ! cond_redirect java -version &> /dev/null; then
update_config_java "11" && java_install "11"
update_config_java "17" && java_install "17"
fi
unset DEBIAN_FRONTEND
}
Expand Down Expand Up @@ -69,7 +69,6 @@ needed_packages() {
moreutils python3 python3-pip python3-wheel python3-setuptools sysstat \
fontconfig; \
then echo "OK"; else echo "FAILED"; return 1; fi
echo -n "$(timestamp) [openHABian] Installing additional Python packages... "
if is_pi_wlan && [[ -z $PREOFFLINE ]]; then
echo -n "$(timestamp) [openHABian] Installing python3 serial package... "
if cond_redirect apt-get install --yes -o DPkg::Lock::Timeout="$APTTIMEOUT" python3-smbus python3-serial; then echo "OK"; else echo "FAILED"; return 1; fi
Expand Down
1 change: 1 addition & 0 deletions tests/Dockerfile.amd64-installation
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ ENTRYPOINT ["./tests/entry.sh"]

# Setup openHABian environment
COPY . /opt/openhabian/
COPY ./build-image/webserver.bash /boot/firmware/webserver.bash
WORKDIR /opt/openhabian/
RUN install -m 755 ./tests/runlevel /sbin/runlevel
1 change: 1 addition & 0 deletions tests/Dockerfile.rpi3-installation
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ ENTRYPOINT ["./tests/entry.sh"]

# Setup openHABian environment
COPY . /opt/openhabian/
COPY ./build-image/webserver.bash /boot/firmware/webserver.bash
WORKDIR /opt/openhabian/
RUN install -m 755 ./tests/runlevel /sbin/runlevel
1 change: 1 addition & 0 deletions tests/Dockerfile.rpi5-installation
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ ENTRYPOINT ["./tests/entry.sh"]

# Setup openHABian environment
COPY . /opt/openhabian/
COPY ./build-image/webserver.bash /boot/firmware/webserver.bash
WORKDIR /opt/openhabian/
RUN install -m 755 ./tests/runlevel /sbin/runlevel

0 comments on commit a80a18f

Please sign in to comment.