Init Hook Permissions Issue

I’m developing a plan for core-plans. In my init script, I have this in my init hook:

ln -sf {{ pkg.path }}/gitea/lib {{ pkg.svc_var_path }}/lib
ln -sf {{ pkg.path }}/gitea/log {{ pkg.svc_var_path }}/log
ln -sf {{ pkg.path }}/gitea/lfs {{ pkg.svc_data_path }}/lfs
ln -sf {{ pkg.path }}/gitea/.ssh {{ pkg.svc_data_path }}/.ssh
ln -sf {{ pkg.path }}/gitea/git {{ pkg.svc_data_path }}/git

chown git:git -RL {{ pkg.path }}/gitea
chown git:git -RL {{ pkg.svc_var_path }}/lib
chown git:git -RL {{ pkg.svc_var_path }}/log

And this in do_install():

  mkdir -p $pkg_prefix/gitea/lib/gitea
  mkdir -p $pkg_prefix/gitea/log/gitea
  mkdir -p $pkg_prefix/gitea/lfs
  mkdir -p $pkg_prefix/gitea/.ssh
  mkdir -p $pkg_prefix/gitea/git

I’m getting the following output:

gitea.default hook[init]:(HK): chown: changing ownership of '/hab/pkgs/core/gitea/1.5.3/20181110063557/gitea/.ssh': Operation not permitted

Also, I have these two options set:


I’ve run hab studio rm as well.
Anyone have any ideas on why the init hook isn’t happy?

You got the right idea about getting your runtime to execute things from the svc folders; however, you should treat things in $pkg_prefix as immutable.

If there’s no state to care about from the pkg (and there shouldn’t be any state you store other than default), then removing any of the symbolic links should be a first thing to do. As those things like logs, lfs objects, etc should NOT be stored in the pkg folders. Think eventual future would be that you would mount drives to the svc data and var paths.

Having the thought of $pkg_prefix being immutatable helped. I just reworked the configs to point directly to the svc directories. Thanks so much.