How to update all of your jails at once!

Status
Not open for further replies.

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,526
So I've written a script that allows you to update all of your jails in one swoop using pkg-ng. Here's the info you need to know:

[panel][root@FreeNASMini] /mnt/tank/# ./fnjailup.sh
Usage:
-A Audit all running jails with pkg-ng.
-C Cleanup old packages from the pkg-ng cache
-O Remove orphaned packages
-U Upgrade all running packages with pkg-ng.
-V Do a version comparison of pkg-ng itself.

-p Pause after each jail completes its task.
-y If done with -U will not prompt for confirmation
to download packages for installation.

Version 1.0 (June 4, 2014)

Reminder: Your jails must be running and you must run this script as root.

WARNING: It is always recommended you make a snapshot of your jail before doing
any updates to software as updates may cause packages installed to no longer
behave properly.

[/panel]

Keep in mind a few things:

1. The jail must be up and running to interact with this script. (ie start all of your jails before running this script to update all of your jails at once).
2. You may want to shutdown processes that require updates for packages that will need to be updated. For example, if you run Minecraft in a jail(which uses java) and the java package needs to be updated it would be wise to stop Minecraft.
3. You may want to restart the jail after installing updates just to make sure everything is properly applied for all of the processes inside the jails.
4. ZFS snapshots can be a real hero if things go badly for your jail when you update! So always do a manual zfs snapshot of your jail before doing updates. I haven't had a problem yet in my 3 months of testing, but that doesn't mean you won't.
5. If your pkg-ng version is older than 1.2.7 then your repositories are not set properly. See my thread here. You will get a warning if any of your jails aren't on 1.2.7 or newer and the script will abort. Since 1.2.7 has been out for over 2 months if you aren't on 1.2.7+ you are a bad boy and should be spanked.
6. If your jail has open access to the internet via port forwarding you absolutely should be keeping stuff up to date! Doing this regularly is a must!
7. Sometimes package conflicts will occur. This script will not be able to automatically handle those conflicts. You will have to resolve them on your own.
8. If you aren't using pkg-ng you are a bad boy/girl. This script won't work for you and you should seriously consider upgrading to a real pkg management system.

Basically you can throw this script anywhere you want, give it execute permissions and run it as root.

Current version: 1.0

- Special thanks to wedgie and YCNZ in IRC for a little help with the scripting.
 

Attachments

  • fnjailup.zip
    2.1 KB · Views: 663
Joined
Apr 12, 2014
Messages
7
Thank you! This worked for me. (after I brought my pkg-ng up-to-scratch and removed aria2 from my jails. o_O )
 

mrMuppet

Contributor
Joined
Mar 14, 2014
Messages
192
Hi,

i tried your skript, but and its successfully downloading the updates, but i'm getting tons of conflice-errrors:
Code:
...Conflict found on path /usr/local/lib/gcc47/include/c++/javax/management/JMRunti47)

Conflict found on path /usr/local/lib/gcc47/include/c++/javax/management/openmbe7.4.20140419(lang/gcc47)

Conflict found on path /usr/local/lib/gcc47/include/c++/javax/management/openmbe419(lang/gcc47)
...


what can i do?
 

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,526
Yep, and you have to reconcile those conflicts one by one by hand. That's #7 on my list above.
 

mrMuppet

Contributor
Joined
Mar 14, 2014
Messages
192
Puh. Ok. Is there any tutorial how to resolve those conflicts?
 

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,526
Puh. Ok. Is there any tutorial how to resolve those conflicts?

Nope. Just gotta google around until you learn enough to do stuff on your own.
 

raidflex

Guru
Joined
Mar 14, 2012
Messages
531
Nope. Just gotta google around until you learn enough to do stuff on your own.


I am seeings 100's of conflicts for the Subsonic plugin when doing a pkg upgrade, I would like to update the jail but there has to be a better way then going through every single one....

This is also on a fresh install of the latest version of the plugin.
 

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,526
Nope. But in your own defense, you'll probably find that those 100s of conflicts are probably caused by one or two packages at the most. ;)

There is no better way except to find and deal with the problems when found. :(

Stuff like this is precisely why FreeBSD admins make good money compared to Windows admins. Gotta know your stuff in FreeBSD.
 

raidflex

Guru
Joined
Mar 14, 2012
Messages
531
Yeah, I later figured this out but in the end my jails were all in different states and had other issues with updates. So I backed up everything and re-created new jails with the latest jail templates and everything installed/updated without issues. Now I plan to run this script to keep them all up to date.

Sent from my HTC6525LVW using Tapatalk
 
Status
Not open for further replies.
Top