ezra
Contributor
- Joined
- Jan 15, 2015
- Messages
- 124
I needed a way to auto update all my jails without the need to edit the script when I delete or add jails. The last script on the forum was a little outdated and did not add jails automatically.
This will grep all jails by name and update, upgrade, pkg upgrade/update and restart the jails if needed.
Please advise if you have any pointers to make the script better.
FreeNAS 11.2 beta-1 / iocage jails.
This will grep all jails by name and update, upgrade, pkg upgrade/update and restart the jails if needed.
Please advise if you have any pointers to make the script better.
FreeNAS 11.2 beta-1 / iocage jails.
Code:
#!/bin/bash VERSION=$(freebsd-version | sed 's|STABLE|RELEASE|g') declare -a vars eval "vars=(`/usr/local/bin/iocage list | awk '{ print $4 }' | sed '2d' | grep .`)" for ((I = 0; I < ${#vars[@]}; ++I )); do /usr/local/bin/iocage update "${vars[$I]}" /usr/local/bin/iocage upgrade "${vars[$I]}" -r "$VERSION" if /usr/local/bin/iocage exec "${vars[$I]}" "pkg update && pkg upgrade" | grep -q 'Your packages are up to date.'; then echo "No need to restart jails" else /usr/local/bin/iocage restart "${vars[$I]}" fi done
Last edited: