Nas linhas abaixo, que adicionei à minha cópia do script sysdiagnose
da Apple:
Nas duas áreas, IFS=$'\n'
…
# If there exists a zfs binary, get some ZFS information
if [ -f "${ZFS}" ]
then
#
# The pool part
#
"${ECHO}" "Recording ZFS pool version information ..."
"${ZPOOL}" upgrade &> ${data_directory_path}/"ZFS pools and properties.txt" &
add_timeout_pid $! 30
"${ECHO}" " listing all ZFS pools ..."
"${ECHO}" "" >> ${data_directory_path}/"ZFS pools and properties.txt"
"${ECHO}" "ZFS pools:" >> ${data_directory_path}/"ZFS pools and properties.txt"
"${ECHO}" "" >> ${data_directory_path}/"ZFS pools and properties.txt"
"${ZPOOL}" list >> ${data_directory_path}/"ZFS pools and properties.txt" &
add_timeout_pid $! 30
"${ECHO}" " all properties of each pool ..."
OLD_IFS=$IFS
IFS=$'\n'
# If cut or zpool can not progress, then at this point: sysdiagnose will not progress
# <https://superuser.com/q/540939/84988>
for zfspool in '"${ZPOOL}" list -H | cut -f 1'
do
{ echo "\n*********************\n" ; "${ZPOOL}" get all "$zfspool" ; } >> ${data_directory_path}/"ZFS pools and properties.txt"
done
IFS=$OLD_IFS
"${ECHO}" " detailed health status and verbose data error information ..."
"${ZPOOL}" status -v &> ${data_directory_path}/"ZFS pool detailed health status and verbose data error information.txt" &
add_timeout_pid $! 30
"${ECHO}" " pools that are available but not currently imported"
"${ZPOOL}" import &> ${data_directory_path}/"ZFS pools not imported.txt" &
add_timeout_pid $! 30
#
# The file system part
#
"${ECHO}" "Recording ZFS file system version information ..."
{ "${ZFS}" upgrade ; "${ECHO}" "\n" ; } &> ${data_directory_path}/"ZFS file systems and properties.txt" &
add_timeout_pid $! 30
"${ECHO}" " listing all ZFS file systems ..."
#"${ECHO}" "ZFS file systems:" >> ${data_directory_path}/"ZFS file systems and properties.txt"
"${ZFS}" list >> ${data_directory_path}/"ZFS file systems and properties.txt" &
add_timeout_pid $! 30
"${ECHO}" " all properties of each file system"
OLD_IFS=$IFS
IFS=$'\n'
# If cut or zfs can not progress, then at this point: sysdiagnose will not progress
# <https://superuser.com/q/540939/84988>
for zfsfilesystem in 'zfs list -H | cut -f 1'
do
{ echo "\n*********************\n" ; "${ZFS}" get all "$zfsfilesystem" ; } >> ${data_directory_path}/"ZFS file systems and properties.txt"
done
IFS=$OLD_IFS
#
# Directory listings
#
"${ECHO}" "Listing the contents of /dev/dsk"
{ "${ECHO}" "Directory listing for /dev/dsk" ; echo "\n"; } >> ${data_directory_path}/"ZEVO-oriented directory listings.txt"
{ "${LS}" -@ael /dev/dsk ; echo "\n*********************\n" ; } >> ${data_directory_path}/"ZEVO-oriented directory listings.txt" &
add_timeout_pid $! 30
"${ECHO}" "Listing the contents of /var/zfs/dsk"
{ "${ECHO}" "Directory listing for /var/zfs/dsk" ; echo "\n" ; } >> ${data_directory_path}/"ZEVO-oriented directory listings.txt"
"${LS}" -@ael /var/zfs/dsk >> ${data_directory_path}/"ZEVO-oriented directory listings.txt" &
add_timeout_pid $! 30
fi
Observe o comentário:
# If cut or zpool can not progress, then at this point: sysdiagnose will not progress
Como posso escrever add_timeout_pid $! 30
nessas duas áreas?
Embora eu não possa reproduzir o script na íntegra (não é de código aberto), os usuários do Lion e do maior podem achar o script da Apple legível:
/usr/bin/sysdiagnose
sysdiagnose (1) Página manual do OS X
recortar (1) Página manual do OS X
A resposta aceita para Manipulando espaços em branco no nome de um conjunto de dados do ZFS em um script de shell
Também em Superusuário, Force um script bash a ser executado até a conclusão, onde alguns itens podem ficar
- mas a resposta não é boa para comandos (como cut
, zfs
e zpool
) que têm nenhuma opção de tempo limite .
Tags macos shell-script script