I did some more digging into the code and noticed some errors in the first-boot.bash file.
In the next statements (line 181) the return code is incorrectly handled (success returns 0)
if ! dpkg -s 'git' &> /dev/null; then
echo -n "$(timestamp) [openHABian] Installing git package... "
if apt-get install --yes git &> /dev/null; then echo "OK"; else echo "FAILED"; fi
fi
If dpkg returns 0 (success, git exists), the if statements are executed
Then apt-get also installs git and if it succeeds it returns zero and will indicate FAILED.
If no dpkg git exists, git will not be installed with the code above and there will be no success/failed indication.
The code should probably be:
if dpkg -s 'git' &> /dev/null; then
echo -n "$(timestamp) [openHABian] Installing git package... "
if ! apt-get install --yes git &> /dev/null; then echo "OK"; else echo "FAILED"; fi
fi
so that the apt-get only gets executed if git is not yet installed with dpkg (I assume that is the intention)
but when a git install is needed and apt-get succeeds (returns 0) it should certainly echo OK
Likewise the following code also has the same problem (line 188): if openhabian_update succeeds it returns 0 and prints executes the FAILED message
type openhabian_update &> /dev/null && if ! openhabian_update &> /dev/null; then
echo "FAILED"
echo "$(timestamp) [openHABian] The git repository on the public internet is not reachable."
echo "$(timestamp) [openHABian] We will continue trying to get your system installed, but this is not guaranteed to work."
else
echo "OK"
fi
The correct code should be (to avoid confusion using the indentation shown and I would also suggest to run the function call with no redirection so that the echoes in there end up in the log):
type openhabian_update &> /dev/null && \
if openhabian_update; then
echo "FAILED"
echo "$(timestamp) [openHABian] The git repository on the public internet is not reachable."
echo "$(timestamp) [openHABian] We will continue trying to get your system installed, but this is not guaranteed to work."
else
echo "OK"
fi
Now when openhabian_update returns 0 (success), it will print OK.
Note that when the openhabian_update function is not present nothing at all happens or is printed since the if statement will not be executed at all.
Returning to my original ZRAM problem, the only way I can have received FAILED on both parts in the erroneous first-boot.bash code is when dpkg returned zero (git was already installed) and the openhabian_update function was present and after execution returned success (0).
So actually git was present, openhabian_update succeeded and the install was largely successful, except for the problem with the ZRAM installation.
The first-boot.log file shows that the modules get loaded but the service ‘zram-config.service’ could not be started.
2020-09-14_16:55:17_CEST [openHABian] Installing ZRAM code...
e[90;01m$ mkdir -p /opt/zram e[39;49;00m
e[90;01m$ git clone https://github.com/kmxz/overlayfs-tools /opt/zram/overlayfs-tools e[39;49;00m
Cloning into '/opt/zram/overlayfs-tools'...
e[90;01m$ git clone https://github.com/mstormi/openhabian-zram /opt/zram/openhabian-zram e[39;49;00m
Cloning into '/opt/zram/openhabian-zram'...
OK
2020-09-14_16:55:20_CEST [openHABian] Setting up OverlayFS...
e[90;01m$ make --always-make --directory=/opt/zram/overlayfs-tools e[39;49;00m
make: Entering directory '/opt/zram/overlayfs-tools'
gcc -Wall -std=c99 -c main.c
gcc -Wall -std=c99 -c logic.c
gcc -Wall -std=c99 -c sh.c
gcc -lm main.o logic.o sh.o -o overlay
make: Leaving directory '/opt/zram/overlayfs-tools'
e[90;01m$ install -m 755 /opt/zram/overlayfs-tools/overlay /usr/local/lib/zram-config/overlay e[39;49;00m
OK
2020-09-14_16:55:23_CEST [openHABian] Setting up ZRAM...
e[90;01m$ install -m 644 /opt/openhabian/includes/ztab /etc/ztab e[39;49;00m
e[90;01m$ install -m 644 /opt/zram/openhabian-zram/ro-root.sh /usr/local/share/zram-config/ro-root.sh e[39;49;00m
e[90;01m$ install -m 644 /opt/zram/openhabian-zram/zram-config.logrotate /etc/logrotate.d/zram-config e[39;49;00m
OK
2020-09-14_16:55:23_CEST [openHABian] Setting up ZRAM service...
e[90;01m$ install -m 644 /opt/zram/openhabian-zram/zram-config.service /etc/systemd/system/zram-config.service e[39;49;00m
e[90;01m$ systemctl enable zram-config.service e[39;49;00m
Created symlink /etc/systemd/system/basic.target.wants/zram-config.service → /etc/systemd/system/zram-config.service.
e[90;01m$ systemctl restart zram-config.service e[39;49;00m
Job for zram-config.service failed because the control process exited with error code.
See "systemctl status zram-config.service" and "journalctl -xe" for details.
FAILED (restart service)
FAILED
Looking into the daemon.log file more info is revealed:
Sep 14 15:55:17 openhab first-boot.bash[554]: 2020-09-14_16:55:17_CEST [openHABian] Installing ZRAM code...
Sep 14 15:55:17 openhab first-boot.bash[554]: #033[90;01m$ mkdir -p /opt/zram #033[39;49;00m
Sep 14 15:55:17 openhab first-boot.bash[554]: #033[90;01m$ git clone https://github.com/kmxz/overlayfs-tools /opt/zram/overlayfs-tools #033[39;49;00m
Sep 14 15:55:17 openhab first-boot.bash[554]: Cloning into '/opt/zram/overlayfs-tools'...
Sep 14 15:55:19 openhab first-boot.bash[554]: #033[90;01m$ git clone https://github.com/mstormi/openhabian-zram /opt/zram/openhabian-zram #033[39;49;00m
Sep 14 15:55:19 openhab first-boot.bash[554]: Cloning into '/opt/zram/openhabian-zram'...
Sep 14 15:55:20 openhab first-boot.bash[554]: OK
Sep 14 15:55:20 openhab first-boot.bash[554]: 2020-09-14_16:55:20_CEST [openHABian] Setting up OverlayFS...
Sep 14 15:55:20 openhab first-boot.bash[554]: #033[90;01m$ make --always-make --directory=/opt/zram/overlayfs-tools #033[39;49;00m
Sep 14 15:55:20 openhab first-boot.bash[554]: make: Entering directory '/opt/zram/overlayfs-tools'
Sep 14 15:55:20 openhab first-boot.bash[554]: gcc -Wall -std=c99 -c main.c
Sep 14 15:55:22 openhab first-boot.bash[554]: gcc -Wall -std=c99 -c logic.c
Sep 14 15:55:23 openhab first-boot.bash[554]: gcc -Wall -std=c99 -c sh.c
Sep 14 15:55:23 openhab first-boot.bash[554]: gcc -lm main.o logic.o sh.o -o overlay
Sep 14 15:55:23 openhab first-boot.bash[554]: make: Leaving directory '/opt/zram/overlayfs-tools'
Sep 14 15:55:23 openhab first-boot.bash[554]: #033[90;01m$ install -m 755 /opt/zram/overlayfs-tools/overlay /usr/local/lib/zram-config/overlay #033[39;49;00m
Sep 14 15:55:23 openhab first-boot.bash[554]: OK
Sep 14 15:55:23 openhab first-boot.bash[554]: 2020-09-14_16:55:23_CEST [openHABian] Setting up ZRAM...
Sep 14 15:55:23 openhab first-boot.bash[554]: #033[90;01m$ install -m 644 /opt/openhabian/includes/ztab /etc/ztab #033[39;49;00m
Sep 14 15:55:23 openhab first-boot.bash[554]: #033[90;01m$ install -m 644 /opt/zram/openhabian-zram/ro-root.sh /usr/local/share/zram-config/ro-root.sh #033[39;49;00m
Sep 14 15:55:23 openhab first-boot.bash[554]: #033[90;01m$ install -m 644 /opt/zram/openhabian-zram/zram-config.logrotate /etc/logrotate.d/zram-config #033[39;49;00m
Sep 14 15:55:23 openhab first-boot.bash[554]: OK
Sep 14 15:55:23 openhab first-boot.bash[554]: 2020-09-14_16:55:23_CEST [openHABian] Setting up ZRAM service...
Sep 14 15:55:23 openhab first-boot.bash[554]: #033[90;01m$ install -m 644 /opt/zram/openhabian-zram/zram-config.service /etc/systemd/system/zram-config.service #033[39;49;00m
Sep 14 15:55:23 openhab first-boot.bash[554]: #033[90;01m$ systemctl enable zram-config.service #033[39;49;00m
Sep 14 15:55:23 openhab first-boot.bash[554]: Created symlink /etc/systemd/system/basic.target.wants/zram-config.service → /etc/systemd/system/zram-config.service.
Sep 14 15:55:23 openhab systemd[1]: Reloading.
Sep 14 15:55:23 openhab systemd[1]: /lib/systemd/system/smbd.service:9: PIDFile= references path below legacy directory /var/run/, updating /var/run/samba/smbd.pid → /run/samba/smbd.pid; please update the unit file accordingly.
Sep 14 15:55:23 openhab systemd[1]: /lib/systemd/system/nmbd.service:9: PIDFile= references path below legacy directory /var/run/, updating /var/run/samba/nmbd.pid → /run/samba/nmbd.pid; please update the unit file accordingly.
Sep 14 15:55:24 openhab first-boot.bash[554]: #033[90;01m$ systemctl restart zram-config.service #033[39;49;00m
Sep 14 15:55:24 openhab systemd[1]: Starting zram-config...
Sep 14 15:55:24 openhab systemd[15531]: zram-config.service: Executable /usr/local/sbin/zramsync missing, skipping: No such file or directory
Sep 14 15:55:24 openhab systemd[15532]: zram-config.service: Failed to execute command: No such file or directory
Sep 14 15:55:24 openhab systemd[15532]: zram-config.service: Failed at step EXEC spawning /usr/local/sbin/zram-config: No such file or directory
Sep 14 15:55:24 openhab systemd[1]: zram-config.service: Main process exited, code=exited, status=203/EXEC
Sep 14 15:55:24 openhab systemd[1]: zram-config.service: Failed with result 'exit-code'.
Sep 14 15:55:24 openhab systemd[1]: Failed to start zram-config.
Sep 14 15:55:24 openhab first-boot.bash[554]: Job for zram-config.service failed because the control process exited with error code.
Sep 14 15:55:24 openhab first-boot.bash[554]: See "systemctl status zram-config.service" and "journalctl -xe" for details.
Sep 14 15:55:24 openhab first-boot.bash[554]: FAILED (restart service)
Sep 14 15:55:24 openhab first-boot.bash[554]: FAILED
this indicates that the executable /usr/local/sbin/zramsync is missing
A file search on my system showed that a file with that name is present in:
‘./opt/zram/openhabian-zram/zramsync’
so maybe there is an erroneous directory in some file or a copy statement forgotten in some script/program?