#!/bin/bash version=0.9.8 arch=`uname -m` case $arch in "x86_64") arch="64" ;; "i386" | "i586" | "i486" | "i686") arch="32" ;; "armv5tel" | "armv6l" | "armv7l") features=`cat /proc/cpuinfo | grep Features` if [[ ! "$features" =~ "vfp" ]]; then #arm without vfp must use GOARM=5 binary #see https://github.com/golang/go/wiki/GoArm arch="-armv5tel" else arch="-$arch" fi ;; *) echo "$arch currently has no precompiled binary" ;; esac os=`uname -s` case $os in "Darwin") os="mac" ;; "Linux") os="linux" ;; *) echo "$os currently has no precompiled binary" exit 1 esac exit_on_fail() { if [ $? != 0 ]; then echo $1 exit 1 fi } while true; do # Get install directory from environment variable. if [[ -n $COW_INSTALLDIR && -d $COW_INSTALLDIR ]]; then install_dir=$COW_INSTALLDIR break fi # Get installation directory from user echo -n "Install cow binary to which directory (absolute path, defaults to current dir): " read install_dir $la_dir/$plist || \ exit_on_fail "Download startup plist file to $la_dir failed" fi # Move binary to install directory echo "Move $tmpbin to $install_dir (will run sudo if no write permission to install directory)" if [ -w $install_dir ]; then mv $tmpbin $install_dir else sudo mv $tmpbin $install_dir fi exit_on_fail "Failed to move $tmpbin to $install_dir" rmdir $tmpdir # Done echo if $is_update; then echo "Update finished." else echo "Installation finished." echo "Please edit $config_dir/rc according to your own settings." echo 'After that, execute "cow &" to start cow and run in background.' fi