Page 1 of 1

Raspberry Pi at home and at work

Posted: Tue Oct 15, 2019 10:29 am
by rcpinheiro
Hi!
I have a Raspberry Pi at work that sometimes I bring home. The configuration in the two environments is different: some services I don't want to run on one of them, firewall rules changes, no wireless or DHCP at work, etc.

What is the best and fastest way to accomplish this with minimal user interaction? Right now I have some cumbersome scripts to do this after logging in but what I really need is a kind of multi-boot where the user select the environment at boot time before loading services, network, login, etc.
Thanks in advance!

Re: Raspberry Pi at home and at work

Posted: Tue Oct 15, 2019 3:50 pm
by W. H. Heydt
Simplest way...use two different microSD cards. One for work, one for home. If you need to have common data files, put them on a USB stick. There are some really tiny USB storage devices that you can just leave in the Pi when you move it.

Re: Raspberry Pi at home and at work

Posted: Tue Oct 15, 2019 4:58 pm
by B.Goode
^--

+1 for what @whh said.

(Annoyed with myself that I wrote a similar reply in almost identical terms about 6 hours ago but failed to hit [Submit] ... )

Re: Raspberry Pi at home and at work

Posted: Wed Oct 16, 2019 7:16 pm
by bjtheone
W. H. Heydt wrote:
Tue Oct 15, 2019 3:50 pm
Simplest way...use two different microSD cards. One for work, one for home. If you need to have common data files, put them on a USB stick. There are some really tiny USB storage devices that you can just leave in the Pi when you move it.
Building on this, use one common SD card to boot and run off two seperate SSD (leave one at work, and one at home). Works great if you have different data sets at home and work, and really should keep them seperate. Alternately have the full OS with appropriate configs on the two SD cards and all your user data on a single SSD and schlep it back and forth if you have a large amount of data. Done right this has the advantage of being able to fairly easily access/use your data on another computer.

Another would be 2 SD cards and store your shared files in the cloud. It really depends on your particular use case (size and number of files, and any restrictions on how they can leave the company).

Are you trying to continue to do work at home, or are you wanting to use the same computer for two different sets of tasks?

Re: Raspberry Pi at home and at work

Posted: Fri Oct 18, 2019 5:30 pm
by rcpinheiro
Thanks for the answers.
The SD Card+External storage is a valid solution but I'l use it as a last resort.
I was thinking along the lines of creating a dialog to select Work or Home in runlevel 2 and change accordingly the configuration files for network and other services. I'll have to dig deeper in /sbin/init manuals to see if this is possible.

Re: Raspberry Pi at home and at work

Posted: Fri Oct 18, 2019 5:37 pm
by DougieLawson
/sbin/init is the systemd control program.

Your better option is to look a PINN (which is a superset of the NOOBS multiboot manager). You can probably set up an SDCard with two distinct copies of Raspbian and use PINN to switch between them. You'll need a 32GB SDCard to do that.

The PINN developer is Procount on here.

https://www.raspberrypi.org/forums/view ... p?t=142574

Re: Raspberry Pi at home and at work

Posted: Fri Oct 18, 2019 9:07 pm
by rcpinheiro
Here's what I've done:

/etc/profiles/choices:

Code: Select all

#!/bin/bash
lastone=`cat /etc/profiles/menu.choice`
WORK=$(systemd-ask-password --timeout 10 "Are you at work? ($lastone): " --echo)
echo $WORK > /etc/profiles/menu.choice

/lib/systemd/system/profile.service

Code: Select all

[Unit]
Description=Profile choice
After=-.mount

[Service]
Type=oneshot
ExecStart=/etc/profiles/choices

[Install]
WantedBy=multi-user.target

Enable service using: systemctl enable profile.service and you're almost done!
Now all you have to do is to make the required services to start after the profile is choosen by using After= in the systemd unit and alter the script to check the user selection (/etc/profiles/menu.choice).

PS: Thanks for the tip, DougieLawson. I will check PINN out.