hyperboria / bugs

Peer-to-peer IPv6 networking, secure and near-zero-conf.
154 stars 17 forks source link

Make systemd config generation more resilient #74

Closed ghost closed 8 years ago

ghost commented 8 years ago

We wanna make sure that it really really generates a config, or fails otherwise

cc @shnatsel @kpcyrd

Shnatsel commented 8 years ago

Looks good to me. The && everywhere is not necessary because "/bin/sh -e" already takes care of that, but you might as well keep it for readability.

The same changes should be applied to the Upstart script: https://github.com/hyperboria/cjdns/blob/master/contrib/upstart/cjdns.conf

ghost commented 8 years ago

Right, you said that on IRC when I brought it up -- bringing the semicolons back.

Shnatsel commented 8 years ago

Now that I look at the updated diff, this line looks fishy:

echo $conf > /etc/cjdroute.conf

Multi-line variables in shell scripts, like $conf, should be quouted. So it should end up like this eventually:

echo "$conf" > /etc/cjdroute.conf

But you're already quoting the entire thing to get it out of systemd's parser, so you'll have to look up how to escape quotes in systemd docs.

Kubuxu commented 8 years ago

Also if $conf gets too long echo will fail. It would be better do gen it once, check if it worked and then gen it straight into the file.

EDIT: Might not be an issue in most systems (2MB in case of my Arch).

Shnatsel commented 8 years ago

Now that I think about it, "test -s" is all that's needed to fix that particular bug. We don't have to do any of this fishy store-and-echo stuff. You can just swap "test -e" for "test -s" and call it a day, and I think we really ought to do that.

ghost commented 8 years ago

@Shnatsel you make an excellent point! Wanna fix it for systemd too in #76?

Shnatsel commented 8 years ago

Not really. I've found a git recipe for rolling back a single file, should be this:

git checkout 01b2990 contrib/systemd/cjdns.service

And then swap "-e" for "-s" and poof, done.

But you'd have to tell the the correct branch-switching and your-changes-pulling and this-branch-pushing sequence too because last time I did that on git instead of bzr there were fireworks and I don't really want to go through it all again right now.