Skip to content

Instantly share code, notes, and snippets.

@danijeljw
Last active December 24, 2015 17:39
Show Gist options
  • Save danijeljw/6836939 to your computer and use it in GitHub Desktop.
Save danijeljw/6836939 to your computer and use it in GitHub Desktop.
No-IP DUC Uninstall Script for Mac OS X
#!/bin/bash
###############################################################################
# Load All Functions #
###############################################################################
# Function Show script help
function showHelp() {
echo "No-IP Uninstaller v2.0a"
echo ""
echo "Usage: sh $0 [option]"
echo ""
echo "Option:
echo " -h This help file"
echo " -r Remove No-IP, no restart"
echo " -u Completely uninstall. Restart required."
echo ""
echo "Advised Usage: sh $0 -u"
echo ""
}
# Function request `sudo` access
function reqSudo() {
sudo -v
}
# Function keep-alive
function keepAlive() {
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
}
# Function Kill `No-IP DUC`
function killNoIP() {
sudo killall "No-IP DUC"
}
# Function Remove `No-IP` only
function noRestart() {
sudo rm -rf /Applications/No-IP\ DUC.app
sudo rm -f /usr/local/bin/noip2
sudo rm -f /usr/local/bin/noip2-boot.sh
echo
echo "No-IP has been removed. Restart or logout is advised."
}
# Function Complete Uninstall
function yesRestart() {
sudo rm -rf /Applications/No-IP\ DUC.app
sudo rm -f /usr/local/bin/noip2
sudo rm -f /usr/local/bin/noip2-boot.sh
sudo shutdown -r now
}
###############################################################################
# Standard UI #
###############################################################################
case "$1" in
'-h'|'-H')
showHelp
;;
'-r'|'-R')
reqSudo
keepAlive
killNoIp
noRestart
;;
'-u'|'-U')
reqSudo
keepAlive
killNoIP
yesRestart
;;
*)
echo "No-IP Uninstaller v2.0a"
echo
echo "Usage: sh $0 [option]"
echo
echo "Option:"
echo " -h This help file"
echo " -r Remove No-IP, no restart"
echo " -u Completely uninstall. Restart required."
echo
echo "Advised Usage: sh $0 -u"
echo
esac
###############################################################################
# Depreciated Code #
###############################################################################
# UI did not function as expected, depreciated 2013-10-05
:<<supercalifragilisticexpialidocious
# Check on minimal command line argument count
REQ_ARG_COUNT=0
if [[ $# -lt $REQ_ARG_COUNT ]]; then
echo \"Use \"./$0 -h\" to show help information.\" #>&2
exit 1
fi
# Start the script by option selected
for option in $*; do
case \"$option\" in
-h|-H)
showHelp
exit 0
;;
-r|-R)
reqSudo
keepAlive
killNoIP
noRestart
exit 0
;;
-u|-U)
reqSudo
keepAlive
killNoIP
yesRestart
exit 0
;;
*)
esac
done
supercalifragilisticexpialidocious
# :<<supercalifragilisticexpialidocious
# via http://www.unix.com/302124672-post4.html
exit
@danijeljw
Copy link
Author

When I try to run this file, this is the error I get:

iMac:no-ip_uninstaller danijelj$ ./noip-remove.sh 
./noip-remove.sh: line 87: unexpected EOF while looking for matching `"'
./noip-remove.sh: line 136: syntax error: unexpected end of file
iMac:no-ip_uninstaller danijelj$ 

Does anybody have any idea why line 87 is causing that problem, or 136 is giving the unexpected end of file issue to me? There isn't even 136 lines in this. It is a rip from the original file on my computer as above.

@danijeljw
Copy link
Author

In the end I changed the whole script around, and it's now in a final revision, and ready to be converted into a Mac App, but this is what I ended up doing:

# Function Show script help
function showHelp {
        clear
        echo "No-IP Uninstaller $version"
        echo 
        echo 'Usage: sh $1 [option]'
        echo 
        echo 'Option:'
        echo '   -h    This help file'
        echo '   -r    Remove No-IP, no restart'
        echo '   -u    Completely uninstall, restart required'
        echo 
        echo "Advised Usage: sh $0 -u"
        echo 
}   # end of showHelp

The updated file looks nothing like the version above, so it's hard to compare. What a shame.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment