#!/bin/sh _install_dir="/usr/local/bin/" _uninstall=0 for _arg in "$@" ; do if [ "$_arg" = "-u" ] || [ "$_arg" = "--uninstall" ] ; then _uninstall=1 else echo "warning: unknown option." exit 1 fi done echo "Install directory: '$_install_dir'" echo "" for _file in ./src/* ; do _destination="$_install_dir"$(basename "$_file") if [ $_uninstall -eq 0 ] ; then if ! [ -e "$_destination" ] ; then echo "installing: $_file" sudo cp "$_file" "$_install_dir" else echo "file present - skipping: $_file" fi elif [ $_uninstall -eq 1 ] ; then # WARNING - need to ensure $_filename is not empty (/usr/local/bin will be deleted) if [ -n "$_destination" ] ; then echo "uninstalling: $_destination" sudo rm "$_install_dir$_destination" fi fi done if [ $_uninstall -eq 0 ] ; then echo "" echo "Install complete -- uninstall with" echo " ./install -u" else echo "" echo "Uninstall complete" fi