1

I'm working on a shell script that will automatically install additional programs after a fresh install of ubuntu 18.04 and restore my personal data and program data. To restore my program data I need the folder structure that is created by the programs after their first launch. As an example I'll use firefox, but I also need it for for instance thunderbird and some other programs. I know you can also use a firefox account and let it restore your account, but that is not what I need since I also have other programs that do not allow that sort of restoring.

The user profile data of a fesh install of firefox is stored in /home/$USER/.mozilla/firefox/*.default-release. I need to copy my backup of my profile data into that folder, firefox will then start with my profile data. The problem is that the exact name of the *.default-release folder is not known in advance. I think it is some kind of random generation, for instance my profile folder is called 11qpplpx.default-release. So I cannot just use mkdir /home/$USER/11qpplpx.default-release to create the folder before I start firefox, because the name of the folder is random.

I am now trying to start firefox from the command line and immediately stop it so the folder structure is created, but firefox is closed again so the rest of the shell script can run to copy the files into the directory. My question is, how do I start firefox and immediately stop it again, but still let it create the folder structure? I tried firefox & pkill -f firefox, which does not create the folder structure.

Thanks in advance!

1 Answer 1

1

My question is, how do I start firefox and immediately stop it again, but still let it create the folder structure?

Give it some time before killing it:

firefox &
sleep 5
pkill -f firefox 

This waits 5 seconds before killing firefox. If not enough, increase the time given to sleep.

2
  • That works, but the delay should be longer than 1 second. I tried 5 and that worked fine. So I added the following two lines to my shell script: firefox & sleep 5 and pkill -f firefox. Maybe you can edit your answer so the delay is longer than 1 second? Thanks a lot for your advice!
    – jcnc
    Mar 1, 2020 at 10:37
  • By the way, I also tried this for thunderbird and that works too
    – jcnc
    Mar 1, 2020 at 10:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .