Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offline installation enhancements #950

Merged
merged 15 commits into from
Jun 10, 2020
Merged
9 changes: 6 additions & 3 deletions build-image/first-boot.bash
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,10 @@ if tryUntil "ping -c1 9.9.9.9 >/dev/null || wget -S -t 3 --waitretry=4 http://ww
cat /etc/wpa_supplicant/wpa_supplicant.conf
rm -f /etc/wpa_supplicant/wpa_supplicant.conf
else
echo "$(timestamp) [openHABian] The public internet is not reachable. Please check your network."
echo "$(timestamp) [openHABian] The public internet is not reachable. Please check your local network environment."
echo "$(timestamp) [openHABian] We will continue trying to get your system installed, but without proper Internet connectivity this is not guaranteed to work."
fi
fail_inprogress
#fail_inprogress
fi
echo "OK"

Expand All @@ -156,7 +157,9 @@ if apt-get --yes upgrade &>/dev/null; then echo "OK"; else echo "FAILED"; fail_i
if hash python3 2>/dev/null; then bash /boot/webif.bash reinsure_running; fi

echo -n "$(timestamp) [openHABian] Installing git package... "
if apt-get install --yes git &>/dev/null; then echo "OK"; else echo "FAILED"; fail_inprogress; fi
if ! cond_redirect dpkg -s "git" &>/dev/null; then
if apt-get install --yes git &>/dev/null; then echo "OK"; else echo "FAILED"; fail_inprogress; fi
fi

if [ -d /opt/openhabian ]; then cd /opt && rm -rf /opt/openhabian; fi
# shellcheck disable=SC2154
Expand Down
14 changes: 6 additions & 8 deletions docs/openhabian.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ You'll also see added commits when executing the "Update" function within the op
### <a id="successful"></a>Did my Installation succeed? What to do in case of a problem?

A note on **patience**: stay calm - the openHABian setup will take 15 up to 45 minutes to complete all steps.
The amount of time highly depends on your device's performance and a number of extrenal factors such as your internet connection.
The amount of time highly depends on your device's performance and a number of external factors such as your internet connection.


<!--
Expand Down Expand Up @@ -330,20 +330,19 @@ If the installation was **not successful** you will see a warning and further in
After the installation of openHABian was successful, you should be able to access the openHAB dashboard:

- Raspberry Pi image setup: [http://openhab:8080](http://openhab:8080)
- In any case: [http://your-device-hostname:8080](http://your-device-hostname:8080) or [http://192.168.0.2:8080](http://192.168.0.2:8080) (replace name/IP)
- In any case: [http://your-device-hostname:8080](http://your-device-hostname:8080) or [http://192.168.0.2:8080](http://192.168.0.2:8080) (replace name/IP with yours)

#### What's next?
If you are not able to access your system via the openHAB dashboard or SSH after more than one hour, chances are high that your hardware setup is the problem. Consult the [debug guide](openhabian-DEBUG.md) and move on from there.

#### <a id="switch-openhab-branch"></a>Can I switch from openHAB 2 stable to the testing or unstable branch?
####<a id="switch-openhab-branch"></a>Can I switch from openHAB 2 stable to the testing or unstable branch?
openHABian installs the latest stable build of openHAB 2.
If you want to switch over to the snapshot or milestone release, please do so via the openHABian Configuration Tool.
Switching from stable to newer development releases might introduce changes and incompatibilities, so please be sure to make a full openHAB backup first!

Check the Linux installation article for all needed details: [Linux: Changing Versions](https://www.openhab.org/docs/installation/linux.html#changing-versions)

{#headache}
#### Where is the graphical user interface?
#### <a id="headache"></a>Where is the graphical user interface?
I've just installed openHABian and now I'm confused.
No fancy login screen, no windows, no mouse support. What did I get into?

Expand All @@ -364,9 +363,8 @@ However as you are willing to tinker with smart home technology, I'm sure you ar
**If** the above didn't convince you, execute the following commands to get the graphical user interface [Pixel](https://www.raspberrypi.org/blog/introducing-pixel) installed.
You have been warned, if there came any warranty with openHABian to begin with, it would end here.

{#faq-other-platforms}
#### Can I use openHABian on ...?
See the [README](../README.md) for a list of supported HW and OS.
####<a id="faq-other-platforms"></a>Can I use openHABian on ...?
See the [README](#../README.md) for a list of supported HW and OS.
openHABian is developed for Debian/Ubuntu based systems.
If your operating system is based on these or if your hardware supports one, your chances are high openHABian can be used.
Check out the [Manual Setup](#manual-setup) instructions for guidance and consult the [debug guide](openhabian-DEBUG.md) if you run into problems.
Expand Down
4 changes: 2 additions & 2 deletions functions/nodejs-apps.bash
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ frontail_setup() {
if [ -d "$frontail_base" ]; then
cond_redirect npm uninstall -g frontail
fi
if ! cond_redirect npm install -g frontail; then echo "FAILED (frontail)"; return 1; fi
cond_redirect npm update -g frontail
if ! cond_redirect npm install --force -g frontail; then echo "FAILED (frontail)"; return 1; fi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need --force here? It will enforce new download, correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not that I am aware, but we need it simply because without it'll break install when Inet is unavailable. Haven't found a better way around so far.

cond_redirect npm update --force -g frontail
#
mkdir -p "${frontail_base}"/preset "${frontail_base}"/web/assets/styles

Expand Down
5 changes: 5 additions & 0 deletions functions/openhabian.bash
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ wait_for_apt_to_finish_update() {
wait -f ${PID_APT} 2>/dev/null
}

install_cleanup() {
echo "$(timestamp) [openHABian] Cleaning up ... "
cond_redirect apt --yes autoremove -q
}

openhabian_announcements() {
local newsfile="${BASEDIR}/NEWS.md"
local readnews="${BASEDIR}/docs/LASTNEWS.md"
Expand Down
38 changes: 29 additions & 9 deletions functions/zram.bash
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
#!/usr/bin/env bash

## install code needed to compile ZRAM tools at installation time
## can be called standalone from build.bash or during install from init_zram_mounts()
## argument is destination directory
##
## install_zram_code(String dir)
##
install_zram_code() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fetch zram source code and dependencies to location given in $1 (will create folder)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a comment what the function does/has as arguments like Ethan does

local ZRAMGIT=https://github.com/mstormi/openhabian-zram
local OVERLAYFSGIT=https://github.com/kmxz/overlayfs-tools
local TAG=openhabian_v1.6
cond_redirect apt-get install -y -q --no-install-recommends make libattr1-dev

mkdir -p "$1"
cd $1 || return 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like that defensive way of coding!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kudos go to shellcheck :-|

git clone -q "$OVERLAYFSGIT"
git clone -q --branch "$TAG" "$ZRAMGIT"
cd - || return 1;
}

init_zram_mounts() {
local introtext="You are about to activate the ZRAM feature.\\nBe aware you do this at your own risk of data loss.\\nPlease check out the \"ZRAM status\" thread at https://community.openhab.org/t/zram-status/80996 before proceeding."
local text_lowmem="Your system has less than 1 GB of RAM. It is definitely NOT recommended to run ZRAM (AND openHAB) on your box. If you proceed now you will do so at your own risk !"
local ZRamInstallLocation

if [ "$1" == "install" ]; then
if [ -z "$UNATTENDED" ]; then
# display warn disclaimer and point to ZRAM status thread on forum
Expand All @@ -13,19 +34,18 @@ init_zram_mounts() {
fi
fi

local ZRAMGIT=https://github.com/mstormi/openhabian-zram
local TAG=openhabian_v1.5
TMP="$(mktemp -d /tmp/openhabian.XXXXX)"
ZRamInstallLocation=/opt/zram

/usr/bin/git clone -q --branch "$TAG" "$ZRAMGIT" "$TMP"
cond_redirect apt-get install -y -q --no-install-recommends make
cd "$TMP" || return 1
install_zram_code "$ZRamInstallLocation"
cd "$ZRamInstallLocation"/overlayfs-tools || return 1
make
cd "$ZRamInstallLocation" || return 1
/bin/sh ./install.sh
/usr/bin/install -m 644 "${BASEDIR:=/opt/openhabian}"/includes/ztab /etc/ztab
service zram-config start
rm -rf "$TMP"

cond_redirect systemctl start zram-config
else
service zram-config stop
cond_redirect systemctl stop zram-config
/bin/sh /usr/local/share/zram-config/uninstall.sh
rm -f /etc/ztab
fi
Expand Down
1 change: 1 addition & 0 deletions openhabian-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ if [[ -n "$UNATTENDED" ]]; then
clean_config_userpw
frontail_setup
zram_setup
install_cleanup
else
apt_update
whiptail_check
Expand Down