Bug in iocage list

tfjad

Dabbler
Joined
Nov 1, 2016
Messages
12
There is a bug in TrueNAS-12.0-RELEASE, which breaks commands like:

iocage list -h
iocage list -H
iocage list --header

I reported this bug already for 12.0-RC1, and there is a fix upstream, but for some reason the fix isn't included in the 12.0-RELEASE.
This bug affects many scripts, which do anything with iocage jails.

Here is a script, which fixes this bug by patching the correct file in TrueNAS-12.0-RELEASE.
The script does backup the original file. You can undo this patch by running the script with parameter -u

Script: fix-iocage-list.sh

Code:
#!/bin/sh
FILE=/usr/local/lib/python3.8/site-packages/iocage_cli/list.py
if [ "$1" = "-u" ]
then
  [ -f $FILE.bak ] && mv -f $FILE.bak $FILE && echo Successfully restored original file. || echo No backup found.
else
  echo Patching file $FILE
  cp -n $FILE $FILE.bak
  sed -Ei '' 's/("message": "\\t".join)\(item\)/\1(map(lambda i: str(i or "-"), item))/' $FILE && echo Success. || echo Failed.
fi
 

Kris Moore

SVP of Engineering
Administrator
Moderator
iXsystems
Joined
Nov 12, 2015
Messages
1,448
Thanks for posting this! The fix didn't get tested / validated in time for the code-freeze for 12.0-RELEASE. However its merged now and will be in 12.0-U1.
 
Top