Just a quick post (I know, it’s been a while).
Was having a heck of a time getting SourceTree to push to GitHub via ssh and oauth. It would just hang at pushing and never complete. I’d saved my pubkey from SourceTree into Github, so the trust relationship should have been there.
Finally went into the local repo in terminal, and did a “git push”. That then grabbed the SSH key from GitHub and prompted to save to known hosts, then pushed.
Went back into SourceTree after making a simple change to a file, and was able to successfully Commit and push to Github. So for whatever reason, the issue was SourceTree wasn’t prompting to save the ssh key so it was just getting stuck waiting for confirmation.
Hopefully this helps someone!
PHP 5.6.4 upgrade (from 5.3.x) and MySQL 5.6
I’ve been meaning to do this for a while, but a slashdot linked article about the large number of insecure PHP installs in the world got me off my ass to upgrade my stock Mac OS X php install from 5.3.x to 5.6.x. Thankfully, the process was pretty painless with the scripts provided here.
I did have to modify my http conf (since I’m not running a stock Apple install) to point to the new php, as well as set the new install location in my .profile, both of which were pretty easy. The biggest annoyance with the upgrade to PHP 5.6, however, was having to fix anywhere where objects were being set via reference “=&” rather than just =. So most of my PDO DB queries were being set via “$result =& $db->query(‘select blah from blah where blah’)”. This no longer worked with 5.6, as you can only set variables that way. Why I was doing it that way is because I’m a hack, and most of my PHP is copied and pasted from previous PHP I’ve done… so that practice just spread throughout. *shrugs* I also had to adjust some settings relating to APC no longer being supported, and opcache being the new PHP object cache setup. The real big change is, since I use W3TC, I had to DISABLE the Database and Object caches. Since these rely on no-longer supported APC calls, things would work fine for about an hour, then WordPress would just stop responding altogether (guessing when it would try to issue a garbage cleanup call) ((Sadly, the author of this plugin has been rather quiet about adding Zend opcache support)). Interestingly, my site sped up significantly after this change. Cool.
Since my server is a Mac, I had already been running MySQL 5.6 for some time (since OS X doesn’t ship with MySQL anymore), but I wanted to take this opportunity to “upgrade” all my tables from MyISAM to InnoDB. This, actually, was a bit more of a pain than I thought it would be.
Scripting Cisco AnyConnect through powershell
This is my first post on Powershell. Hopefully it won’t be too painful. Anyway, Campus recently mandated that we get away from the Cisco IPSec client, and move to the AnyConnect client. Problem is, the IPSec client was REALLY easy to put the username and password in the launch shortcut (just switches), and it’d connect. That doesn’t seem to be the case with the AnyConnect client, so I had to figure out how to do this in powershell. The script below (the fold) does this, and seems to work quite well. The reason for automating it is because we’re an almost 100% Mac shop, and there is a piece of “Banner” that is PC only. So we provide a Terminal Services/RDC Server that Mac users connect to, VPN fires up, and they’re able to connect to this package ((Note, our VPN admin had to allow VPN connections from a Multiuser environment, and Remote Desktop Connection)).
I just dropped this script into C:\powershell\vpn.ps1, and then created a shortcut in the user account start menu, startup, and had the path be: “%windir%\system32\windowspowershell\v1.0\powershell.exe C:\powershell\vpn.ps1” ((this is windows server 2003, sadly)).
Good luck. And thanks to the forums here, and it’s users, for the base code that I modified to work with my environment.
#Please change following variables
#IP address or host name of cisco vpn
[string]$CiscoVPNHost = “vpn.example.com”
[string]$Login = “username”
[string]$Password = “password”
[string]$agree = “y”
#Please check if file exists on following paths
[string]$vpncliAbsolutePath = ‘C:\Program Files (x86)\Cisco\Cisco AnyConnect Secure Mobility Client\vpncli.exe’
[string]$vpnuiAbsolutePath = ‘C:\Program Files (x86)\Cisco\Cisco AnyConnect Secure Mobility Client\vpnui.exe’
#****************************************************************************
#**** Please do not modify code below unless you know what you are doing ****
#****************************************************************************
Add-Type -AssemblyName System.Windows.Forms -ErrorAction Stop
#Set foreground window function
#This function is called in VPNConnect
Add-Type @’
using System;
using System.Runtime.InteropServices;
public class Win {
[DllImport(“user32.dll”)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetForegroundWindow(IntPtr hWnd);
}
‘@ -ErrorAction Stop
#quickly start VPN
#This function is called later in the code
Function VPNConnect()
{
Start-Process -FilePath $vpncliAbsolutePath -ArgumentList “connect $CiscoVPNHost”
$counter = 0; $h = 0;
while($counter++ -lt 1000 -and $h -eq 0)
{
sleep -m 10
$h = (Get-Process vpncli).MainWindowHandle
}
#if it takes more than 10 seconds then display message
if($h -eq 0){echo “Could not start VPNUI it takes too long.”}
else{[void] [Win]::SetForegroundWindow($h)}
}
#Check if VPN is running, but disconnected, and if so, kill the process so we can reconnect.
if ((“$vpncliAbsolutePath state”) -like “*Disconnected*”) {
#Terminate all vpnui processes.
Get-Process | ForEach-Object {if($_.ProcessName.ToLower() -eq “vpnui”)
{$Id = $_.Id; Stop-Process $Id; echo “Process vpnui with id: $Id was stopped”}}
#Terminate all vpncli processes.
Get-Process | ForEach-Object {if($_.ProcessName.ToLower() -eq “vpncli”)
{$Id = $_.Id; Stop-Process $Id; echo “Process vpncli with id: $Id was stopped”}}
}
#Connect to VPN
echo “Connecting to VPN address ‘$CiscoVPNHost’ as user ‘$Login’.”
VPNConnect
#Write login and password
[System.Windows.Forms.SendKeys]::SendWait(“$Login{Enter}”)
[System.Windows.Forms.SendKeys]::SendWait(“$Password{Enter}”)
[System.Windows.Forms.SendKeys]::SendWait(“$agree{Enter}”)
#Start vpnui
start-Process -FilePath $vpnuiAbsolutePath