4

I have several different use cases for my Raspberry Pi 3. Currently I have a configuration for it as a media centre, for streaming audio, for hacking purposes, office workplace, etc. All configurations are based on the default Raspbian distribution.

Those configurations require different (systemd) services and different /etc service config files. For example: my office workplace, I have Network Manager configured with as much wifi network passwords as I need, while for my hacking station, I'd like to disable Network Manager and configure a rotating mac address and static ip. Sometimes I like my Pi headless, and sometimes I need a GUI. Etc.

Key is, that not only the services differ, also the service config files differ, based on the purpose.

My question is: how do I "switch" between configurations (services+ config files) within the same Linux environment? Ideally I'd like to issue a (terminal) command to switch to another "mode".

Already tried:

  • Different partitions with multi boot grub: costs a lot of space/overhead. Does not accommodate easy switching.
  • Use runlevel to differentiate: does not accommodate different config files.
  • Create my own "switch script" that stops services, copies/switches config files and (re)starts services: comes close, but feels like I'm re-inventing the wheel.

Any suggestions for an "out-of-the-box" solution for this? I can't imagine I'm the first or only one with this need.

  • Perhaps etckeeper might be somewhat helpful? – phk Feb 12 '17 at 21:49
2

It sounds like creating targets in systemd, and possibly storing /etc/ in git would create something akin to what you want. Change target, switch git branch, you might want to have an intermediary target that disables most services before switching everything.

1

What about something like a 'configuration' partition mounted with folders something like this:

/mnt/config/setup1/etc
/mnt/config/setup2/etc
/mnt/config/setup3/etc
/mnt/config/etc -> /mnt/config/setup1/etc

Then make a systemd service that copies /mnt/config/etc to /etc early in boot. Place anything that differs in these /mnt/config/.../etc folders. Update the symlink to change your setup and reboot.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.