-
-
Save otzoran/d7724778c01164477811 to your computer and use it in GitHub Desktop.
Fixes annoying brew doctor messages caused by Truecrypt - tested on Yosemite
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Author: Ori Tzoran, based on idea and gist by aaronzirbes (see evolution below) | |
# Tested on Mac OS X 10.10.2 (14C109) | |
set -e | |
## verify root runs this | |
[[ $(id -u) == 0 ]] || { echo need root; exit 1; } | |
#set -vx | |
## verify TrueCrypt doesn't run | |
# - ps COMMAND should "/Applications/TrueCrypt.app/Contents/MacOS/TrueCrypt" | |
# - the 'true' in end of the pipe escapes the check on grep's return (which in !=0 if TrueCrypt doesnt run) | |
num_procs=$(ps -eo command | sed -n '/^sed/d;/TrueCrypt.app/p;' | grep -c 'MacOS/TrueCrypt' || true ) | |
if [[ $num_procs > 0 ]]; then | |
printf "TrueCrypt is running, quit it and start over...\n"; | |
exit 1 | |
fi | |
truecrypt=/Applications/TrueCrypt.app/Contents/Resources | |
cd /usr/local/lib | |
## list of files (obtained by `find . -user root` ) | |
fuse_libs=" | |
libfuse.0.dylib | |
libfuse.2.dylib | |
libfuse.dylib | |
libfuse_ino64.2.dylib | |
libfuse_ino64.dylib | |
libmacfuse_i32.2.dylib | |
libmacfuse_i32.dylib | |
libmacfuse_i64.2.dylib | |
libmacfuse_i64.dylib | |
libosxfuse.2.7.3.dylib | |
libosxfuse.2.dylib | |
libosxfuse.dylib | |
libosxfuse.la | |
libosxfuse_i32.2.7.3.dylib | |
libosxfuse_i32.2.dylib | |
libosxfuse_i32.dylib | |
libosxfuse_i32.la | |
libosxfuse_i64.2.7.3.dylib | |
libosxfuse_i64.2.dylib | |
libosxfuse_i64.dylib | |
libosxfuse_i64.la | |
pkgconfig/fuse.pc | |
pkgconfig/osxfuse.pc | |
" | |
## check all files exist | |
for ff in $fuse_libs; do | |
[[ -e $ff ]] || { printf "File not found \"$ff\". Abroting\n"; exit 1; } | |
done | |
printf "This script moves OSXFUSE files from /usr/local/lib under TrueCrypt's App dir.\n" | |
printf "All verifications passed. Hit enter to continue [or ^C to abort now] " | |
read ANS | |
## create Library subdir - dest | |
if [[ -d $truecrypt ]]; then | |
mkdir -p $truecrypt/Library | |
else | |
printf "Dir not found \"$truecrypt\". Abroting\n" | |
exit 1 | |
fi | |
## copy the files, preserving the pkgconfig subdir | |
tar cf - $fuse_libs | tar xvf - -C $truecrypt/Library | |
## rm & symlink | |
for ff in $fuse_libs; do | |
rm $ff | |
ln -s $truecrypt/Library/$ff $ff | |
done | |
echo | |
printf "Successfully moved OSXFUSE libfiles from /usr/local/lib to $truecrypt/Library\n" | |
echo | |
printf "You should run brew now from your own account (not as root):\n" | |
cat <<-EOCC | |
brew prune | |
brew doctor | |
brew update | |
EOCC | |
exit | |
## Motivation: fix brew doctor complaints on fuse libs | |
# sources: | |
# 1. Aaron J. Zirbes, Created on Aug 2, 2012 | |
# https://gist.github.com/aaronzirbes/3239033 | |
# 2. James Cuzella, aka "trinitronx", last edit Apr 22, 2013 forked to add cond. dir create | |
# https://gist.github.com/trinitronx/5437061 | |
# 3. Yiufung Cheong, Nov 13, 2013 forked trinitronx to fix rm | |
# https://gist.github.com/yiufung/7445219 | |
# Errors/mistakes | |
# - no verif ran by root | |
# - no verif TrueCrypt is NOT running | |
# - no verif all libfiles exist beforehand | |
# - pkgconfig is not recreated on dest, the 2 *.pc files are not copied to the right location | |
# - symlinks not copied: he handles only the 7 files, there are 16 symlinks that become orphans | |
# | |
# Read this article: https://lazymind.me/2014/10/install-truecrypt-on-mac-osx-yosemite-10-10/ | |
# Opened an "old" 7.1a dmg (e.g. dump the "insecure" FUD) | |
# Copy out "TrueCrypt 7.1a.mpkg" to ~/Downloads | |
# Edited `distribution.dist` as explained in above url | |
# Opened the the mpkg/Contents/Packages | |
# Confirmed 23 lib entries in the 2 Fuse pkgs. OSXFUSECore.pkg OSXFUSEMacFUSE.pkg | |
# * The 3rd pkg, MacFUSE.pkg, doesnt carry lib files | |
# Installed TrueCrypt (after hacking the distribution.dist file) | |
# - tested that it opens an existing vol, creating new vol == ok (before moving libs) | |
# - wrote script and run | |
# - repeat tests | |
# | |
# Includes | |
# There're 9 files under /usr/local/include, they can be moved under /Apps.../Include | |
# osxfuse/fuse/fuse.h | |
# osxfuse/fuse/fuse_common.h | |
# osxfuse/fuse/fuse_common_compat.h | |
# osxfuse/fuse/fuse_compat.h | |
# osxfuse/fuse/fuse_darwin.h | |
# osxfuse/fuse/fuse_lowlevel.h | |
# osxfuse/fuse/fuse_lowlevel_compat.h | |
# osxfuse/fuse/fuse_opt.h | |
# osxfuse/fuse.h | |
# | |
# caveats | |
# This script isn't idempotent. If ran a 2nd time, we have symlinks under lib ... | |
# and it will end up in infinite symlink loop .... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment