SOLVED Script for updating pkg

Status
Not open for further replies.

nojohnny101

Wizard
Joined
Dec 3, 2015
Messages
1,478
hwy everyone,
I have a plex jail on my box that I installed manually (via package) and every now and thn I have to manually go into the shell and update it (pkg update && install etc).

Has anyone had any luck getting this into a script that can used to update the jail via crontab? I don’t know if the script could handle properly stopping the jail before updating and then starting it again after updating.

Has anyone tried this?

Thanks!
 

melloa

Wizard
Joined
May 22, 2016
Messages
1,749
If you can get the PID plex is running, you can stop the service, wait for the PID, run your updates, and re-start plex.
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,456

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,456
...and really, if it's only one jail you're worried about, it doesn't need to be anywhere near as complicated as I posted in that thread:
Code:
#!/bin/bash
jexec plexmediaserver pkg upgrade -y
jexec plexmediaserver service plexmediaserver restart

Set it to run at 2:00 AM or so, when nobody will be watching anything. Done. Still can't figure why you'd think the jail needs to be stopped first--seems that would prevent anything (like the update process) from running inside the jail.
 

nojohnny101

Wizard
Joined
Dec 3, 2015
Messages
1,478
Thank for the help guys.

The reason I thought the jail had to be stopped was because of the update process outlined in this thread (that I originally followed in setting everything up). In that thread it lists the step of stopping the plex jail, doing the update, then starting the jail again. I was just following that, if there is no technical reason then I guess I don't need to stop it anymore when updating.

Thanks @danb35 your linked thread is exactly what I was looking for. I adapted your script and it seems to be working (no errors) but the real test is when it updates and then restarts fine, so I'll wait for the next plex update to be made available through packages.

Thanks!
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,456
In that thread it lists the step of stopping the plex jail, doing the update, then starting the jail again.
Actually, no, it doesn't. It calls for stopping the plex service, not the plex jail--big difference. But even that is unnecessary; upgrade then restart will do the job just fine.
 

nojohnny101

Wizard
Joined
Dec 3, 2015
Messages
1,478
You're right, stopping the service, sorry for mixing words there.
Thanks for your help.
 
Status
Not open for further replies.
Top