Skip to content

Instantly share code, notes, and snippets.

@Agroil
Forked from jasmas/umbrellactl
Created June 13, 2021 22:15
Show Gist options
  • Save Agroil/542f0b62d5fdb2de25dbbaa7c96d0bcf to your computer and use it in GitHub Desktop.
Save Agroil/542f0b62d5fdb2de25dbbaa7c96d0bcf to your computer and use it in GitHub Desktop.

Revisions

  1. @jasmas jasmas revised this gist Aug 2, 2017. No changes.
  2. @jasmas jasmas created this gist Aug 1, 2017.
    70 changes: 70 additions & 0 deletions umbrellactl
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,70 @@
    #!/usr/bin/env bash

    PLUGIN_BASE='/opt/cisco/anyconnect/bin/plugins'

    read -r -d '' USAGE << EGASU
    Usage: `basename $0` [-s|-e|-d|-h]
    -s, --status Print Umbrella Roaming Security module status
    -e, --enable Enable Umbrella Roaming Security module
    -d, --disable Disable Umbrella Roaming Security module
    -h, --help Show this message.
    EGASU

    # Check plugin status, return 0 if enabled, 1 if disabled
    function check_status {
    [[ -f $PLUGIN_BASE/libacumbrellaapi.dylib ]] &&
    [[ -f $PLUGIN_BASE/libacumbrellactrl.dylib ]] &&
    [[ -f $PLUGIN_BASE/libacumbrellaplugin.dylib ]]
    }

    # Check if plugin disabled by utility, return 0 if yes, 1 if no
    function verify_plugin_disabled {
    [[ -f $PLUGIN_BASE/disabled/libacumbrellaapi.dylib ]] &&
    [[ -f $PLUGIN_BASE/disabled/libacumbrellactrl.dylib ]] &&
    [[ -f $PLUGIN_BASE/disabled/libacumbrellaplugin.dylib ]]
    }

    # Disable plugin
    function disable_plugin {
    sudo mkdir -p $PLUGIN_BASE/disabled
    sudo mv -f $PLUGIN_BASE/libacumbrellaapi.dylib $PLUGIN_BASE/libacumbrellactrl.dylib $PLUGIN_BASE/libacumbrellaplugin.dylib $PLUGIN_BASE/disabled
    }

    # Enable plugin
    function enable_plugin {
    sudo mv -f $PLUGIN_BASE/disabled/libacumbrellaapi.dylib $PLUGIN_BASE/disabled/libacumbrellactrl.dylib $PLUGIN_BASE/disabled/libacumbrellaplugin.dylib $PLUGIN_BASE/
    }

    case "$1" in
    '-s'|'--status')
    check_status &&
    echo Umbrella Roaming Security Module for AnyConnect is ENABLED. ||
    echo Umbrella Roaming Security Module for AnyConnect is DISABLED.
    exit 0
    ;;
    '-e'|'--enable')
    verify_plugin_disabled &&
    enable_plugin &&
    echo Umbrella Roaming Security Module for AnyConnect has been ENABLED. &&
    exit 0 ||
    echo ERROR: Umbrella Roaming Security Module for AnyConnect can only be enabled if it has previously been disabled by this utility.
    exit 1
    ;;
    '-d'|'--disable')
    check_status &&
    disable_plugin &&
    echo Umbrella Roaming Security Module for AnyConnect has been DISABLED. ||
    echo ERROR: Umbrella Roaming Security Module for AnyConnect does not appear to be enabled.
    exit 1
    ;;
    '-h'|'--help')
    echo "$USAGE"
    exit 0
    ;;
    *)
    echo "$USAGE"
    exit 1
    ;;
    esac