
<!doctype html>
<html lang='en' style='background: #111;'>
	<head>
		<meta charset='utf-8' />
		<meta name='viewport' content='width=device-width' />
		<meta http-equiv='X-UA-Compatible' content='ie=edge'>
		<title>OpenFortiVPN in your macOS menu bar</title>
		<link rel='stylesheet' href='/public/css/xbar.css?cb=08%20Mar%2021%2015%3a22%20GMT'>
		<link rel='preconnect' href='https://fonts.gstatic.com'>
		<link rel='preconnect' href='https://fonts.googleapis.com'>
		<link rel='stylesheet' href='https://fonts.googleapis.com/css2?family=Bodoni+Moda:wght@500&display=swap'>
		
	<meta name='description' content='Displays status of a OpenFortiVPN interface with option to connect/disconnect. - install xbar for free to get started.'>
	<meta name='author' content='Emran Mobaraki Novin'>
	<meta name='keywords' content='macos,menubar,xbar,bitbar'>
	<meta itemprop='image' content='https://i.imgur.com/v2aW5mo.png'>
	<meta itemprop='name' content='OpenFortiVPN in your macOS menu bar'>
	<meta itemprop='description' content='Displays status of a OpenFortiVPN interface with option to connect/disconnect. - install xbar for free to get started.'>
	<meta name='twitter:card' content='summary_large_image'>
	<meta name='twitter:title' content='OpenFortiVPN in your macOS menu bar'>
	<meta name='twitter:description' content='Displays status of a OpenFortiVPN interface with option to connect/disconnect. - install xbar for free to get started.'>
	<meta name='twitter:image' content='https://i.imgur.com/v2aW5mo.png'>
	<meta name='twitter:creator' content='matryer'>
	<meta property='og:title' content='OpenFortiVPN in your macOS menu bar'>
	<meta property='og:description' content='Displays status of a OpenFortiVPN interface with option to connect/disconnect. - install xbar for free to get started.'>
	<meta property='og:url' content='https://xbarapp.com/plugins/Network/openfortivpn.sh.html'>
	<meta property='og:site_name' content='xbar lets you put anything into your macOS menu bar'>
	<meta property='og:type' content='article'>
	<meta property='og:image' content='https://i.imgur.com/v2aW5mo.png'>
	<link rel='apple-touch-icon' sizes='180x180' href='https://i.imgur.com/v2aW5mo.png'>
	<link rel='icon' type='image/png' sizes='32x32' href='https://i.imgur.com/v2aW5mo.png'>
	<link rel='shortcut icon' href='https://i.imgur.com/v2aW5mo.png'>
	<meta name='msapplication-TileColor' content='#ffffff'>
	<meta name='msapplication-config' content='/public/browserconfig.xml'>
	<meta name='theme-color' content='#ffffff'>
	<style>
		.code-background {
			background: rgb(255,255,255);
			background: linear-gradient(to right, rgba(255,255,255,0.2) 0%, rgba(255,255,255,0.1) 100%);
		}
		.plugin-app-link {
			margin-left: -32px;
		}
	</style>

	</head>
	<body>
		<header class='flex flex-col'>
			<div class='container mx-auto'>
				<div class='flex items-center space-x-8 p-8 text-white'>
					<a href='/' class='inline-block py-2 text-2xl flex items-center space-x-2 font-bold'>
						<img alt='xbar logo: a circle with three dots inside it' src='/public/img/xbar-2048.png' style='width:48px;height:48px;' />
						<span>xbar</span>
					</a>
					<div class='flex-grow'></div>
					<div>
						<a 
							target='github'
							href='https://github.com/sponsors/matryer' 
							class='text-white px-4 py-2 whitespace-nowrap'
						><span class='mr-1'>💜</span> Sponsor</a>
					</div>
					<div class='hidden md:block'>
						<a 
							target='github'
							href='/dl' 
							class='rounded bg-white text-gray-800 hover:text-black px-4 py-2 shadow hover:shadow-lg whitespace-nowrap'
						>Coming soon</a>
					</div>
				</div>
			</div>
		</header>
		<div id='menubar' class='text-white whitespace-nowrap overflow-hidden flex flex-wrap justify-end items-center text-right'>
			
			
				<a 
					
					href='/docs/plugins/AWS.html'
				>
					AWS
				</a>
			
				<a 
					
					href='/docs/plugins/Cryptocurrency.html'
				>
					Cryptocurrency
				</a>
			
				<a 
					
					href='/docs/plugins/Dev.html'
				>
					Dev
				</a>
			
				<a 
					
					href='/docs/plugins/E-Commerce.html'
				>
					E-Commerce
				</a>
			
				<a 
					
					href='/docs/plugins/Email.html'
				>
					Email
				</a>
			
				<a 
					
					href='/docs/plugins/Environment.html'
				>
					Environment
				</a>
			
				<a 
					
					href='/docs/plugins/Finance.html'
				>
					Finance
				</a>
			
				<a 
					
					href='/docs/plugins/Games.html'
				>
					Games
				</a>
			
				<a 
					
					href='/docs/plugins/IoT.html'
				>
					IoT
				</a>
			
				<a 
					
					href='/docs/plugins/Lifestyle.html'
				>
					Lifestyle
				</a>
			
				<a 
					
					href='/docs/plugins/Music.html'
				>
					Music
				</a>
			
				<a 
					 class='rounded selected' 
					href='/docs/plugins/Network.html'
				>
					Network
				</a>
			
				<a 
					
					href='/docs/plugins/Politics.html'
				>
					Politics
				</a>
			
				<a 
					
					href='/docs/plugins/Science.html'
				>
					Science
				</a>
			
				<a 
					
					href='/docs/plugins/Sports.html'
				>
					Sports
				</a>
			
				<a 
					
					href='/docs/plugins/System.html'
				>
					System
				</a>
			
				<a 
					
					href='/docs/plugins/Time.html'
				>
					Time
				</a>
			
				<a 
					
					href='/docs/plugins/Tools.html'
				>
					Tools
				</a>
			
				<a 
					
					href='/docs/plugins/Travel.html'
				>
					Travel
				</a>
			
				<a 
					
					href='/docs/plugins/Weather.html'
				>
					Weather
				</a>
			
				<a 
					
					href='/docs/plugins/Web.html'
				>
					Web
				</a>
			
		</div>
		
	<div class='container mx-auto flex flex-wrap space-x-8 justify-start items-start mt-16'>
		<div class='flex flex-col justify-start'>
			<div class='px-8 py-2 max-w-3xl'>
				<h1 class='fancy-font text-white text-6xl'>OpenFortiVPN</h1>
			</div>
			<div class='p-8 text-sm'>
				
					
						
							<div class='flex space-x-4 pb-8'>
								<div class='tiny-photo'>
									<a 
										href='/docs/contributors/emranovin.html'
									>
										<img class='rounded shadow primary' src='https://avatars.githubusercontent.com/u/24988058?v=4'>
									</a>
								</div>
								<div>
									<a 
										href='/docs/contributors/emranovin.html'
										class='light-background rounded-sm shadow-md px-4 py-2 text-white' 
										style='text-decoration: none;'
									>
										Emran (<code style='color:white;'>@emranovin</code> on GitHub)
									</a>
								</div>
							</div>
						
					
				
				
					<p class='my-8 text-white opacity-75 text-lg max-w-lg'>
						Displays status of a OpenFortiVPN interface with option to connect/disconnect.
					</p>
				
				<div class='plugin-app-link hidden md:flex items-end p-8 m-8 mb-16 bg-black bg-opacity-25 rounded-lg shadow max-w-md'>
					<div>
						<a 
							href='xbar://app.xbarapp.com/openPlugin?path=Network%2fopenfortivpn.sh'
							class='rounded bg-white text-gray-800 hover:text-black px-4 py-2 shadow hover:shadow-lg whitespace-nowrap'
						><span class='mr-1'>🖥</span> Open in xbar app</a>
					</div>
					<div class='opacity-50 text-sm text-white ml-3'>Requires <a target='github' href='/dl' class='underline'>xbar app</a></div>
				</div>
				
			</div>
		</div>
		<div 
			class='flex flex-col justify-center mb-16'
		>
			<img 
				class='max-w-md w-full'
				src='https://i.imgur.com/v2aW5mo.png' 
				alt='Image preview of OpenFortiVPN plugin.'
				onerror='this.onerror=null;this.src="/public/img/xbar-2048.png";'
			/>
		</div>
	</div>

	
		<div class='code-background text-white p-8 pb-24'>
			<div class='container mx-auto'>
				<div class='flex flex-wrap py-8 space-x-4 justify-end'>
					<div>
						<h2 class='md:text-2xl text-bold'>
							<code>openfortivpn.sh</code>
						</h2>
					</div>
					<div class='flex-grow'></div>
					<div>
						<a class='text-sm text-white hover:text-black hover:bg-white px-4 py-2 rounded' target='github' href='https://github.com/matryer/bitbar-plugins/edit/master/Network/openfortivpn.sh'>Edit</a>
					</div>
					<div>
						<a class='text-sm text-gray-700 bg-white hover:bg-gray-100 active:text-black px-4 py-2 rounded' target='github' href='https://github.com/matryer/bitbar-plugins/blob/master/Network/openfortivpn.sh'>Open on GitHub</a>
					</div>
				</div>
				<div>
					<pre class='text-sm whitespace-pre-wrap'><code class='break-all '>#!/bin/bash

# Get current status of a OpenFortiVPN connection with options to connect/disconnect.
# Commands that require admin permissions should be whitelisted with &#39;visudo&#39;, e.g.:
# YOURUSERNAME ALL=(ALL) NOPASSWD: /usr/local/bin/openfortivpn
# YOURUSERNAME ALL=(ALL) NOPASSWD: /usr/bin/killall -2 openfortivpn
# To use openfortivpn in an easy way you can create file like: /Documents/.fortivpn-config and put your crential in it as following:
#
# host=123.45.678.9
# port=1234
# username=FOO
# password=MYPASSWORDCHARACHTERS
# trusted-cert=MYCERTIFICATECHARACHTERS

# &lt;bitbar.title&gt;OpenFortiVPN&lt;/bitbar.title&gt;
# &lt;bitbar.version&gt;v1.0&lt;/bitbar.version&gt;
# &lt;bitbar.author&gt;Emran Mobaraki Novin&lt;/bitbar.author&gt;
# &lt;bitbar.author.github&gt;emranovin&lt;/bitbar.author.github&gt;
# &lt;bitbar.desc&gt;Displays status of a OpenFortiVPN interface with option to connect/disconnect.&lt;/bitbar.desc&gt;
# &lt;bitbar.image&gt;https://i.imgur.com/v2aW5mo.png&lt;/bitbar.image&gt;

VPN_EXECUTABLE=/usr/local/bin/openfortivpn
VPN_EXECUTABLE_PARAMS=&#34;-c$HOME/Documents/.fortivpn-config&#34; # Optional
VPN_INTERFACE=ppp0
# Command to determine if OpenFortiVPN is connected or disconnected
VPN_CONNECTED=&#34;/sbin/ifconfig | egrep -A1 $VPN_INTERFACE | grep inet&#34;
# Command to run to disconnect OpenFortiVPN
VPN_DISCONNECT_CMD=&#34;sudo killall -2 openfortivpn&#34;

case &#34;$1&#34; in
    connect)
        # VPN connection command, should eventually result in $VPN_CONNECTED,
        sudo &#34;$VPN_EXECUTABLE&#34; &#34;$VPN_EXECUTABLE_PARAMS&#34; &amp;&gt; /dev/null &amp;
        # Wait for connection so menu item refreshes instantly
        until eval &#34;$VPN_CONNECTED&#34;; do sleep 1; done
        ;;
    disconnect)
            eval &#34;$VPN_DISCONNECT_CMD&#34;
        # Wait for disconnection so menu item refreshes instantly
        until [ -z &#34;$(eval &#34;$VPN_CONNECTED&#34;)&#34; ]; do sleep 1; done
        ;;
esac

if [ -n &#34;$(eval &#34;$VPN_CONNECTED&#34;)&#34; ]; then
    echo &#34;✔&#34;
    echo &#39;---&#39;
    echo &#34;Disconnect OpenFortiVPN | bash=&#39;$0&#39; param1=disconnect terminal=false refresh=true&#34;
    exit
else
    echo &#34;✘&#34;
    echo &#39;---&#39;
    echo &#34;Connect OpenFortiVPN | bash=&#39;$0&#39; param1=connect terminal=false refresh=true&#34;
    exit
fi
</code></pre>
				</div>
			</div>
		</div>
	

		<footer class='container mx-auto text-white text-lg opacity-75 mt-8'>
			<div class='text-center p-16'>
				<p>
					<div>
						<a target='github' class='underline hover:text-white' href='https://github.com/matryer/xbar'>GitHub project</a>
						•
						<a target='github' class='underline hover:text-white' href='https://github.com/matryer/xbar#writing-plugins'>Writing plugins guide</a>
					</div>
					<div class='mt-8'>
						Copyright &copy;2021 Mat Ryer + contributors • <a target='twitter' class='underline hover:text-white' href='https://twitter.com/matryer'>@matryer</a>
					</div>
					<div class='opacity-50 mt-2'>
						Last updated on 08 Mar 21 15:22 GMT
					</div>
				</p>
			</div>
		</footer>
	</body>
</html>
