tprelog / iocage-homeassistant

Home Assistant Core - TrueNAS CORE Community Plugin
MIT License
61 stars 11 forks source link

Problems upgrading Jail and HA #31

Closed csoltenborn closed 3 years ago

csoltenborn commented 3 years ago

Hi,

first of all, thanks for the plugin and the excellent descriptions in the Wiki! :-)

I'm on TrueNAS 12.0, but my HA jail is still running 11.3 and 0.116.4, and updating the HA version results in the OpenSSL errors. Thus, I thought I'd upgrade the jail's OS first. I have tried 12.1 and 12.2, but running into the same error...

Here are my update steps:

# update OS - in global shell
iocage upgrade -r 12.1-RELEASE HomeAssistant

# in Jail shell
pkg-static update -f
pkg-static upgrade -f

# reinstall/update Home Assistant
service homeassistant stop
service homeassistant reinstall homeassistant # When asked, type `YES` to clear the cache

# hangs, PyNaCl can not be installed
service homeassistant check_config

service homeassistant start

The problem occurs at the check_config step: the installation of PyNaCl is failing with the following error:

  running build_clib
  checking build system type... x86_64-unknown-freebsd12.2
  checking host system type... x86_64-unknown-freebsd12.2
  checking for a BSD-compatible install... /usr/bin/install -c
  checking whether build environment is sane... yes
  checking for a thread-safe mkdir -p... /tmp/pip-install-99mra_qi/pynacl/src/libsodium/build-aux/install-sh -c -d
  checking for gawk... no
  checking for mawk... no
  checking for nawk... nawk
  checking whether make sets $(MAKE)... yes
  checking whether make supports nested variables... yes
  checking whether UID '8123' is supported by ustar format... yes
  checking whether GID '8123' is supported by ustar format... yes
  checking how to create a ustar tar archive... gnutar
  checking whether make supports nested variables... (cached) yes
  checking whether to enable maintainer-specific portions of Makefiles... no
  checking for style of include used by make... GNU
  checking for gcc... gcc
  checking whether the C compiler works... no
  configure: error: in `/tmp/pip-install-99mra_qi/pynacl/build/temp.freebsd-12.2-RC3-amd64-3.8':
  configure: error: C compiler cannot create executables
  See `config.log' for more details
  Traceback (most recent call last):
    File "/usr/local/share/homeassistant/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 280, in <module>
      main()
    File "/usr/local/share/homeassistant/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 263, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/usr/local/share/homeassistant/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 204, in build_wheel
      return _build_backend().build_wheel(wheel_directory, config_settings,
    File "/tmp/pip-build-env-lbu8vjoe/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 216, in build_wheel
      return self._build_with_temp_dir(['bdist_wheel'], '.whl',
    File "/tmp/pip-build-env-lbu8vjoe/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 202, in _build_with_temp_dir
      self.run_setup()
    File "/tmp/pip-build-env-lbu8vjoe/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 253, in run_setup
      super(_BuildMetaLegacyBackend,
    File "/tmp/pip-build-env-lbu8vjoe/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 145, in run_setup
      exec(compile(code, __file__, 'exec'), locals())
    File "setup.py", line 208, in <module>
      setup(
    File "/tmp/pip-build-env-lbu8vjoe/overlay/lib/python3.8/site-packages/setuptools/__init__.py", line 153, in setup
      return distutils.core.setup(**attrs)
    File "/usr/local/lib/python3.8/distutils/core.py", line 148, in setup
      dist.run_commands()
    File "/usr/local/lib/python3.8/distutils/dist.py", line 966, in run_commands
      self.run_command(cmd)
    File "/usr/local/lib/python3.8/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/tmp/pip-build-env-lbu8vjoe/overlay/lib/python3.8/site-packages/wheel/bdist_wheel.py", line 290, in run
      self.run_command('build')
    File "/usr/local/lib/python3.8/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/usr/local/lib/python3.8/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/usr/local/lib/python3.8/distutils/command/build.py", line 135, in run
      self.run_command(cmd_name)
    File "/usr/local/lib/python3.8/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/usr/local/lib/python3.8/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "setup.py", line 165, in run
      subprocess.check_call(
    File "/usr/local/lib/python3.8/subprocess.py", line 364, in check_call
      raise CalledProcessError(retcode, cmd)
  subprocess.CalledProcessError: Command '['/tmp/pip-install-99mra_qi/pynacl/src/libsodium/configure', '--disable-shared', '--enable-static', '--disable-debug', '--disable-dependency-tracking', '--with-pic', '--prefix', '/tmp/pip-install-99mra_qi/pynacl/build/temp.freebsd-12.2-RC3-amd64-3.8']' returned non-zero exit status 77.
  ----------------------------------------
  ERROR: Failed building wheel for PyNaCl
ERROR: Could not build wheels for PyNaCl which use PEP 517 and cannot be installed directly

Afterwards, a couple of more packages are installed without issues, the last being sqlalchemy. Then, the script gets stuck and can only be canceled with Ctrl-C. I can then restart the jail, and HA starts, but the log contains a couple of errors, and some entities are broken. The errors:

Log Details (ERROR)
Logger: homeassistant.setup
Source: setup.py:138
First occurred: 8:49:44 AM (3 occurrences)
Last logged: 8:50:01 AM

Setup failed for cloud: Unable to import component: /usr/local/share/homeassistant/lib/python3.8/site-packages/cryptography/hazmat/bindings/_openssl.abi3.so: Undefined symbol "sk_pop_free"
Setup failed for mobile_app: Requirements for mobile_app not found: ['PyNaCl==1.3.0'].
Setup failed for default_config: Could not set up all dependencies.
Logger: homeassistant.setup
Source: setup.py:118
First occurred: 8:50:01 AM (1 occurrences)
Last logged: 8:50:01 AM

Unable to set up dependencies of default_config. Setup failed for dependencies: cloud, mobile_app
Logger: homeassistant.util.package
Source: util/package.py:95
First occurred: 8:50:01 AM (1 occurrences)
Last logged: 8:50:01 AM

Unable to install package PyNaCl==1.3.0: ERROR: Command errored out with exit status 1: command: /usr/local/share/homeassistant/bin/python3.8 /usr/local/share/homeassistant/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py build_wheel /tmp/tmpmd064uta cwd: /tmp/pip-install-xysaljsm/pynacl Complete output (101 lines): running bdist_wheel running build running build_py creating build creating build/lib.freebsd-12.2-RC3-amd64-3.8 creating build/lib.freebsd-12.2-RC3-amd64-3.8/nacl copying src/nacl/encoding.py -> build/lib.freebsd-12.2-RC3-amd64-3.8/nacl copying src/nacl/exceptions.py -> build/lib.freebsd-12.2-RC3-amd64-3.8/nacl copying src/nacl/hashlib.py -> build/lib.freebsd-12.2-RC3-amd64-3.8/nacl copying src/nacl/utils.py -> build/lib.freebsd-12.2-RC3-amd64-3.8/nacl copying src/nacl/hash.py -> build/lib.freebsd-12.2-RC3-amd64-3.8/nacl copying src/nacl/public.py -> build/lib.freebsd-12.2-RC3-amd64-3.8/nacl copying src/nacl/secret.py -> build/lib.freebsd-12.2-RC3-amd64-3.8/nacl copying src/nacl/signing.py -> build/lib.freebsd-12.2-RC3-amd64-3.8/nacl copying src/nacl/__init__.py -> build/lib.freebsd-12.2-RC3-amd64-3.8/nacl creating build/lib.freebsd-12.2-RC3-amd64-3.8/nacl/pwhash copying src/nacl/pwhash/scrypt.py -> build/lib.freebsd-12.2-RC3-amd64-3.8/nacl/pwhash copying src/nacl/pwhash/argon2i.py -> build/lib.freebsd-12.2-RC3-amd64-3.8/nacl/pwhash copying src/nacl/pwhash/argon2id.py -> build/lib.freebsd-12.2-RC3-amd64-3.8/nacl/pwhash copying src/nacl/pwhash/_argon2.py -> build/lib.freebsd-12.2-RC3-amd64-3.8/nacl/pwhash copying src/nacl/pwhash/__init__.py -> build/lib.freebsd-12.2-RC3-amd64-3.8/nacl/pwhash creating build/lib.freebsd-12.2-RC3-amd64-3.8/nacl/bindings copying src/nacl/bindings/crypto_secretbox.py -> build/lib.freebsd-12.2-RC3-amd64-3.8/nacl/bindings copying src/nacl/bindings/sodium_core.py -> build/lib.freebsd-12.2-RC3-amd64-3.8/nacl/bindings copying src/nacl/bindings/crypto_secretstream.py -> build/lib.freebsd-12.2-RC3-amd64-3.8/nacl/bindings copying src/nacl/bindings/crypto_generichash.py -> build/lib.freebsd-12.2-RC3-amd64-3.8/nacl/bindings copying src/nacl/bindings/crypto_scalarmult.py -> build/lib.freebsd-12.2-RC3-amd64-3.8/nacl/bindings copying src/nacl/bindings/crypto_kx.py -> build/lib.freebsd-12.2-RC3-amd64-3.8/nacl/bindings copying src/nacl/bindings/crypto_shorthash.py -> build/lib.freebsd-12.2-RC3-amd64-3.8/nacl/bindings copying src/nacl/bindings/crypto_aead.py -> build/lib.freebsd-12.2-RC3-amd64-3.8/nacl/bindings copying src/nacl/bindings/utils.py -> build/lib.freebsd-12.2-RC3-amd64-3.8/nacl/bindings copying src/nacl/bindings/crypto_hash.py -> build/lib.freebsd-12.2-RC3-amd64-3.8/nacl/bindings copying src/nacl/bindings/__init__.py -> build/lib.freebsd-12.2-RC3-amd64-3.8/nacl/bindings copying src/nacl/bindings/crypto_box.py -> build/lib.freebsd-12.2-RC3-amd64-3.8/nacl/bindings copying src/nacl/bindings/crypto_pwhash.py -> build/lib.freebsd-12.2-RC3-amd64-3.8/nacl/bindings copying src/nacl/bindings/randombytes.py -> build/lib.freebsd-12.2-RC3-amd64-3.8/nacl/bindings copying src/nacl/bindings/crypto_sign.py -> build/lib.freebsd-12.2-RC3-amd64-3.8/nacl/bindings running build_clib checking build system type... x86_64-unknown-freebsd12.2 checking host system type... x86_64-unknown-freebsd12.2 checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... /tmp/pip-install-xysaljsm/pynacl/src/libsodium/build-aux/install-sh -c -d checking for gawk... no checking for mawk... no checking for nawk... nawk checking whether make sets $(MAKE)... yes checking whether make supports nested variables... yes checking whether UID '8123' is supported by ustar format... yes checking whether GID '8123' is supported by ustar format... yes checking how to create a ustar tar archive... gnutar checking whether make supports nested variables... (cached) yes checking whether to enable maintainer-specific portions of Makefiles... no checking for style of include used by make... GNU checking for gcc... gcc checking whether the C compiler works... no configure: error: in `/tmp/pip-install-xysaljsm/pynacl/build/temp.freebsd-12.2-RC3-amd64-3.8': configure: error: C compiler cannot create executables See `config.log' for more details Traceback (most recent call last): File "/usr/local/share/homeassistant/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 280, in <module> main() File "/usr/local/share/homeassistant/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 263, in main json_out['return_val'] = hook(**hook_input['kwargs']) File "/usr/local/share/homeassistant/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 204, in build_wheel return _build_backend().build_wheel(wheel_directory, config_settings, File "/tmp/pip-build-env-g_7u7muv/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 216, in build_wheel return self._build_with_temp_dir(['bdist_wheel'], '.whl', File "/tmp/pip-build-env-g_7u7muv/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 202, in _build_with_temp_dir self.run_setup() File "/tmp/pip-build-env-g_7u7muv/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 253, in run_setup super(_BuildMetaLegacyBackend, File "/tmp/pip-build-env-g_7u7muv/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 145, in run_setup exec(compile(code, __file__, 'exec'), locals()) File "setup.py", line 208, in <module> setup( File "/tmp/pip-build-env-g_7u7muv/overlay/lib/python3.8/site-packages/setuptools/__init__.py", line 153, in setup return distutils.core.setup(**attrs) File "/usr/local/lib/python3.8/distutils/core.py", line 148, in setup dist.run_commands() File "/usr/local/lib/python3.8/distutils/dist.py", line 966, in run_commands self.run_command(cmd) File "/usr/local/lib/python3.8/distutils/dist.py", line 985, in run_command cmd_obj.run() File "/tmp/pip-build-env-g_7u7muv/overlay/lib/python3.8/site-packages/wheel/bdist_wheel.py", line 290, in run self.run_command('build') File "/usr/local/lib/python3.8/distutils/cmd.py", line 313, in run_command self.distribution.run_command(command) File "/usr/local/lib/python3.8/distutils/dist.py", line 985, in run_command cmd_obj.run() File "/usr/local/lib/python3.8/distutils/command/build.py", line 135, in run self.run_command(cmd_name) File "/usr/local/lib/python3.8/distutils/cmd.py", line 313, in run_command self.distribution.run_command(command) File "/usr/local/lib/python3.8/distutils/dist.py", line 985, in run_command cmd_obj.run() File "setup.py", line 165, in run subprocess.check_call( File "/usr/local/lib/python3.8/subprocess.py", line 364, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '['/tmp/pip-install-xysaljsm/pynacl/src/libsodium/configure', '--disable-shared', '--enable-static', '--disable-debug', '--disable-dependency-tracking', '--with-pic', '--prefix', '/tmp/pip-install-xysaljsm/pynacl/build/temp.freebsd-12.2-RC3-amd64-3.8']' returned non-zero exit status 77. ---------------------------------------- ERROR: Failed building wheel for PyNaCl ERROR: Could not build wheels for PyNaCl which use PEP 517 and cannot be installed directly
Logger: homeassistant.components.vacuum
Source: components/xiaomi_miio/vacuum.py:476
Integration: Vacuum (documentation, issues)
First occurred: 8:49:55 AM (1 occurrences)
Last logged: 8:49:55 AM

xiaomi_miio: Error on device update!
Traceback (most recent call last):
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/homeassistant/helpers/entity_platform.py", line 359, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/homeassistant/helpers/entity.py", line 466, in async_device_update
    await task
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/homeassistant/components/xiaomi_miio/vacuum.py", line 476, in update
    state = self._vacuum.status()
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/miio/vacuum.py", line 215, in status
    return VacuumStatus(self.send("get_status")[0])
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/miio/device.py", line 146, in send
    return self._protocol.send(
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/miio/miioprotocol.py", line 173, in send
    m = Message.build(msg, token=self.token)
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/construct/core.py", line 352, in build
    self.build_stream(obj, stream, **contextkw)
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/construct/core.py", line 364, in build_stream
    self._build(obj, stream, context, "(building)")
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/construct/core.py", line 2003, in _build
    buildret = sc._build(subobj, stream, context, path)
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/construct/core.py", line 2472, in _build
    return self.subcon._build(obj, stream, context, path)
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/construct/core.py", line 4078, in _build
    buildret = self.subcon._build(obj, stream, context, path)
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/construct/core.py", line 4365, in _build
    buildret = self.subcon._build(value, stream, context, path)
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/construct/core.py", line 718, in _build
    obj2 = self._encode(obj, context, path)
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/miio/protocol.py", line 158, in _encode
    return Utils.encrypt(
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/miio/protocol.py", line 85, in encrypt
    cipher = Cipher(algorithms.AES(key), modes.CBC(iv), backend=default_backend())
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/cryptography/hazmat/backends/__init__.py", line 15, in default_backend
    from cryptography.hazmat.backends.openssl.backend import backend
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/cryptography/hazmat/backends/openssl/__init__.py", line 7, in <module>
    from cryptography.hazmat.backends.openssl.backend import backend
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/cryptography/hazmat/backends/openssl/backend.py", line 117, in <module>
    from cryptography.hazmat.bindings.openssl import binding
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/cryptography/hazmat/bindings/openssl/binding.py", line 16, in <module>
    from cryptography.hazmat.bindings._openssl import ffi, lib
ImportError: /usr/local/share/homeassistant/lib/python3.8/site-packages/cryptography/hazmat/bindings/_openssl.abi3.so: Undefined symbol "sk_pop_free"

Apparently, openssl is involved into the problems - I guess that this will annoy the heck out of you, but I think I have to take that risk ;-)

Any idea? Could setting up a new jail using the plugin an approach? Could I then just copy the contents of /home/homeassistant into the new jail, restart and be all set up? Sorry if this is a stupid question - I'm rather new to HA...

atxbyea commented 3 years ago

That is what I did @csoltenborn Deployed a new plugin on 12.1, then migrated config over, was definitely faster ;-)

csoltenborn commented 3 years ago

@atxbyea Thanks for letting me know :-)

As I said, I'm rather new to HA - would you mind to confirm the following steps?

  1. Save /home/homeassistant directory
  2. Destroy current jail (note: I'd like to reuse the jail's name, but this is not actually required)
  3. Run HA plugin. It will create a jail with the current OS version (I assume 12.2) and install the current HA version into it
  4. Stop HA
  5. Copy the save homedirectory to the new jail (same location)
  6. Start HA
tprelog commented 3 years ago

Hi @csoltenborn

atxbyea is correct. If spending more than 15-20 minutes trouble shooting a broken plugin, it should be quicker to just reinstall. Although you are the first person to report pkg-static update -f then pkg-static upgrade -f did not work. One person has reported using Plugin > UPDATE after upgrading the jail. In that case, the virtualenv was ale to be rebuilt.

In my opinion, this highlights the biggest downfall using plugins on TrueNAS. That is to say, there is not a simple way to store the configuration directories to a separate dataset.

would you mind to confirm the following steps?

That is correct.

Just to be safe, you can export the existing plugin before it's destroyed. This will create a zip backup of the entire jail, I know the jail is broke but it will still contain the HA configuration.

tprelog commented 3 years ago

Thinking about this now, it might be the perfect time to create an external dataset :wink:

There's a few ways to configure this - I think this a relatively easy approach. If you're already familiar with TrueNAS, I assume you can make adjustments as needed.

  1. In TrueNAS UI, create a dataset that will be used for the configuration (I leave permissions at default for now)
  2. In TrueNAS UI, create a homeassistant uses with a UID of 8123 (optional, set the config dataset as home directory)
  3. In TrueNAS UI, set owner/group and permissions of the dataset to homeassistant and RW access
  4. Save the contents of /home/homeassistant directory to the new dataset
  5. export (optional) then destroy current jail
  6. Run HA plugin. It will create a jail with the current OS version
  7. Stop HA
  8. Move (or delete) the existing /home/homeassistant directory (we need an empty directory to mount external dataset)
  9. Stop the entire jail
  10. Add dataset to Home Assistant from Plugins > MOUNT POINTS. The mount path inside the jail should home/homeassistant
  11. Start the jail

I'm gonna try to write these steps with little more detail and add to the wiki over this weekend. It you already reinstalled the plugin, you can still add the external dataset following the steps above, just skip steps 5 and 6.

csoltenborn commented 3 years ago

Oops - that's my inexperience with HA. I spent more like a couple of hours :-)

Your approach of separating config and installation makes a lot of sense to me - I will in fact try this right now and let you know about the result.

adorobis commented 3 years ago

4. contents of /home/homeassistant

Is that directory the only place where HA config is stored?

tprelog commented 3 years ago

Short answer is YES

Long answer is still YES but technically (to be more exact) Home Assistant config - /home/homeassistant/homeassistant

If installed using the console menu Configurator (File Editor) config - /home/homeassistant/configurator AppDaemon config - /home/homeassistant/appdaemon


Also to note for anyone who installed this plugin before August 2020 - The previous username was hass. In this case /home/hass would contain the HA config as laid out above

csoltenborn commented 3 years ago

Worked like a charm. The only "drawback" when assigning the config dataset to the homeassistant user as home directory is that the dir will then contain a couple of other files, which confused me for a second since I'm a Windows user ;-)

Edit: I just noted that the File Editor now allows to navigate the jail's complete file structure - as far as I remember, I could not go beyond the home/homeassistant directory before.

It seems that when there is the needed to destroy/recreate the jail once more, the only thing needed is to re-add the mount point - might that be a candidate for the plug-in? It might ask for a config directory during installation, or might offer to create that mount point from the shell service menu... Let me know whether I shall create a feature request (I guess most of the steps could be automated by the plug-in).

Thanks, @atxbyea and @tprelog! Issue can be closed from my point of view...

tprelog commented 3 years ago

It seems that when there is the needed to destroy/recreate the jail once more, the only thing needed is to re-add the mount point

Yes, step 5-11 anytime you need to reinstall the plugin. Your configuration is now safely separated from the jail.

might that be a candidate for the plug-in? It might ask for a config directory during installation, or might offer to create that mount point from the shell service menu

https://github.com/ix-plugin-hub/iocage-plugin-index/issues/120

The only "drawback" when assigning the config dataset to the homeassistant user as home directory is that the dir will then contain a couple of other files, which confused me for a second since I'm a Windows user

I'll add these details in the wiki page but briefly, the homeassistant user created on TrueNAS can optionally be used to validate access to a samba share but the shell can still be set to nologin. Also most of the extra files can be deleted.

Assuming you have installed all 3 services, these are the 4 directories you should keep

.cache
appdaemon
configurator
homeassistant

Unless you have created any extra files yourself anything beyond the above list can safely be deleted.

Also to access the HA config via samba share from windows have a look at this overview

If you're following along with the link - You should create the share path pointing directly to the external dataset (do not point it to the directory inside the jail)

csoltenborn commented 3 years ago

I see - taking care of the mount point feature from iocage obviously is preferable.

Thanks for pointing out the mandatory files - I have changed the user's shell config and removed the other files.

In fact, I already have a samba share for the HomeAssistant config - however, given HA's File Explorer extension (which, btw, I got to know from your tutorial at the HA forum, same for AppDaemon and HACS) I'm not even sure whether I will keep it...

tprelog commented 3 years ago

Of course this has to be more complicated... I just realized that the TrueNAS UI does not create the homeassistant user as I expected - To be more specific, when setting a specific UID for the user, the primary group is created with the next available GUID. It does NOT match the UID as expected.

root@truenas-vm[~]# id homeassistant
uid=8123(homeassistant) gid=1001(homeassistant) groups=1001(homeassistant),545(builtin_users)

If your accessing the share using the (TrueNAS) homeassistant user, I guess this shouldn't really cause any serious issues but IMO, I would prefer both UID and GUID are correctly set to match the homeassistant account inside the jail

I'll address how to avoid (and correct) this in wiki

tprelog commented 3 years ago

The wiki page is started - If you have a minute, please provide any feed back or suggestions

https://github.com/tprelog/iocage-homeassistant/wiki/external_dataset_and_samba

I will close this issue when the wiki page it is more complete

csoltenborn commented 3 years ago

Some comments on the Wiki page:

I have not created the Samba share, thus I can't comment too much on that one. I have still read it, and it looks good to me.

Thanks once more for the great explanations!

adorobis commented 3 years ago

Great Wiki, many thanks! I have one question, not sure if it was answered there or here:

tprelog commented 3 years ago

Thank you for looking!

  • First paragraph: I would explicitly point to the "destroy/reinstall instead of update" scenario (but that might just be me ;-) )

I agree. I think I'm also going to split creating the SMB share to a separate page. The dataset will be recommended for everyone. The SMB is optional. Moving forward, I will only cover creating a SMB using the dataset. (Only in case of emergency, creating the share inside the jail will be mentioned)

Would approach to install the HA plugin and mount the config dataset be a recommended approach to any HA version upgrade? Or you would rather recommend it only when major upgrades of TrueNAS are performed?

Moving the config to an external dataset will be suggested, recommend and encouraged for everybody. The initial steps to setup and move the config, will only need to preformed once.

I will recommend reinstalling the plugin to everyone who has upgraded from FreeNAS, even people who have already upgraded successfully. Moving forward, I will recommend a full reinstall on a case by case basis (this relates to the "plugin")

Don't tell anyone, Version 5 in progress :speak_no_evil:

HA version upgrade?

Not likely, maybe only when the supported version of Python changes.

The "how to correct wrong id of group" part is not yet contained, but might not be needed (since your instructions prevent this problem). For me, I would now create the group as described and then switch the homeassistant user's primary group to that group and remove the old one. Correct?

If you are able to just delete and recreate the group with the correct 8123 GID then yes.

Otherwise, at this point it is also safe to delete BOTH the homeassistant user and group from TrueNAS, then re-add them as shown in the new wiki page. -- However, after more testing I think I'm going to recommend the homeassistant user is created with following setting. Notice I am not setting a path to home and password login, samba authentication have been disabled.

image

On the page to the access the SMB, I will instruct to either A) add the homeassistant group to your own existing user account. B) enable password login and samba authentication for the homeassistant user

"Copy existing configuration": I in fact had the problem that some files did not have the correct permissions (already at the old place), which I then corrected after copying. Maybe it makes sense to mention that permissions should be checked either before or after copying.

I have included the commands under the final section Reset Permissions - but still needs brief explanation. As I understand, because we are copying the config while logged in as root, everything should get copied regardless permissions. IMO, it makes the most sense to fix permissions after the config have been moved. Generally speaking, resetting the permissions should be safe for everyone, however,I should point certain files, for example, if you have any shell scripts, they will need to made executable again.

tprelog commented 3 years ago
  • Would approach to install the HA plugin and mount the config dataset be a recommended approach to any HA version upgrade? Or you would rather recommend it only when major upgrades of TrueNAS are performed?

I think this is the right idea :shrug: It's certainly better than the NA I provide now

starting with version 5, I'm gonna try something like this https://github.com/tprelog/iocage-homeassistant/wiki/temp_about_version

tprelog commented 3 years ago

I've updated the plugin to version 5.

Please see the following for more information

tprelog commented 3 years ago

I will close this issue when the wiki page it is more complete

The wiki should be updated to cover topics discussed here so I'm gonna close this now.

I've also found and and enabled a new discussion feature on this repository.

We can continue to discuss any ideas here without creating issues

-- Please open a new issue for version 5 if you have trouble with a reinstall