#!/bin/zsh # # Copyright (C) 2012 ... # REPO="https://github.com/bbits/tuntaposx.git" autoload colors; colors # standard output message routines # it's always useful to wrap them, in case we change behaviour later notice() { if [[ $QUIET == 0 ]]; then print "$fg_bold[green][*]$fg_no_bold[default] $1" >&2; fi } error() { if [[ $QUIET == 0 ]]; then print "$fg[red][!]$fg[default] $1" >&2; fi } func() { if [[ $DEBUG == 1 ]]; then print "$fg[blue][D]$fg[default] $1" >&2; fi } act() { if [[ $QUIET == 0 ]]; then if [ "$1" = "-n" ]; then print -n "$fg_bold[white] . $fg_no_bold[default] $2" >&2; else print "$fg_bold[white] . $fg_no_bold[default] $1" >&2; fi fi } { test "$1" = "clean" } && { notice "Cleaning up all tuntaposx build" rm -rf tuntaposx act "Done." return 0 } build_tuntap() { test -d tuntaposx || git clone $REPO notice "Cloning tuntaposx sources" cd tuntaposx/tuntap notice "Building tuntaposx" make mkdir -p ../../dist/tun.kext cp -r tun.kext/* ../../dist/tun.kext mkdir -p ../../dist/tuntaposx/StartupItems cp -r startup_item/tun ../../dist/tuntaposx/StartupItems cd ../.. } act "Building tuntap" build_tuntap