Author Archives: aek82

.NET Core – Compiling applications for multiple platforms

Modify project.json

"frameworks": {
  "netcoreapp1.0": {
    "dependencies": {
      "Microsoft.NETCore.App": {
        "version": "1.0.1"
      }
    }
  } 
}
"runtimes": {
     "win10-x64": {},
     "osx.10.10-x64": {},
     "ubuntu.14.04-x64": {}
   }

From the CLI run:

dotnet restore
dotnet build -r win10-x64
dotnet build -r osx.10.10-x64
dotnet build -r ubuntu.14.04-x64

dotnet publish -c release -r win10-x64
dotnet publish -c release -r osx.10.10-x64
dotnet publish -c release -r ubuntu.14.04-x64

Reference: Self-Contained NET Core Applications

Upgrade Mobility Controller / ArubaOS from the CLI

It’s not completely obvious that upgrading the partition means upgrading the OS on the controller. Use this if the Web UI gives you an error about running out of space.

To upgrade partition 0 in enable mode:

copy tftp: <IP ADDRESSS> <FILENAME> system: partition 0

Example:

copy tftp: 1.1.1.1 A800_3.4.2.4_23915 system: partition 0

Other useful commands

dir

show storage

show memory

Airheads Thread

HP 2530 Pro Curve Switch – Exporting and Importing Switch Configuration via SFTP

Import Switch Configuration

copy sftp startup-config user <username> <IP Address> <Path to File>

Example:

copy sftp startup-config user alexkuo 1.1.1.1 /var/home/alexkuo/switch-import.cfg

Export Switch Configuration

copy running-config sftp user <username> <IP Address> <Path to File>

Example: 

copy running-config sftp user alexkuo 1.1.1.1 /var/home/alexkuo/switch-exported.cfg

ASP.NET Web Server Here Context Option

open.asp

You can download here the updated registry entry for opening the ASP.NET Development Web Server using context menu in Explorer. The path has been updated to use Visual Studio 2015’s development web server.

This is used to quickly open a web server in a directory. After merging the registry, just do the following:

  1. Open explorer and navigate to the target directory
  2. Right click and select the ASP.NET Web Server Here option

I have not tested this in Windows 10.

Reference: http://haacked.com/archive/2009/10/27/aspnet4-webserver-here-shell-extension.aspx/

Aruba IAP 4.1.X – Setting up the Guest PreAuth Role in ClearPass 6.5 and Instant

When setting up the guest network between an IAP with ClearPass, the older guides direct the user to setup a PreAuth role for guest and deny all traffic.

It’s assumed a firewall exception or something similar is automatically put into the IAP firewall rules to let the IAP, client, and the ClearPass server communicate, but this isn’t the case currently. In addition to denying traffic to all servers, you need to add additional rules to let the client communicate with ClearPass AND the IAP – or else radius requests will fail.

The PreAuth role looks similar to the following:

IAP

  • 192.168.99.111 is the IAP’s Virtual Controller
  • 192.168.99.103 is the ClearPass server

 

Ubuntu Server – Delete empty directories except parent directory

I needed a bash script to delete empty directories, excluding the parent directory. The following does this:

find /home/alex/target mindepth 1 -maxdepth 1 -type d -empty -print0 | xargs -0 rm -R

And the crontab that does this every few hours

0 */12 1-31/2 * * find /home/alex/target -mindepth 1 -maxdepth 1 -type d -empty -print0 | xargs -0 rm -R >/dev/null 2>&1

Ubuntu Server and Rsync – SSH into remote server and download latest files except files with a .part extension and email output

After reading through a bunch of troubleshooting threads, the following:

  1. Runs a shell  script via cron
  2. SSH into a remote server using a SSH key for a password
  3. Executes Rysnc with the options to delete source files after download, and skip files with the extension .part

Bash Script:

#!/bin/sh

/usr/bin/rsync -havzPe 'ssh -i /home/alex/.ssh/id_rsa' --rsync path='/usr/bin/rsync' --remove-source-files --exclude='*.part' --stats bob@10.10.10.10:/home/alex/target /home/alex | /usr/bin/mail -s 'Rsync Output' root

Link Explain Shell

Crontab consisted of the following:

0 */2 * * * /home/alex/sync.sh >/dev/null 2>&1

This runs the shell script every 2 hours.  This was created using a this crontab generator.

Generating a SSH key for passwordless SSH login and exporting it remotely is explained here.

Generate the keys on your host server:

ssh-keygen -t dsa

Export the keys to the target server:

ssh-copy-id -i ~/.ssh/id_dsa.pub ross@remotehost [or enter ip address instead of hostname, e.g."remotehost"]

Configure email server so mail command works.

Digital Ocean’s Guide to PostFix

 

Google Protobuf – Generate C# POCO from .proto files using Protobuf-net

Google’s Protobuf code generator uses an API that many .NET developers may find a bit different than the usual MO.

An alternative to Google’s Protobuf implementation is Marc Gravell’s protobuf-net library, which uses an implementation that may make more sense to .NET developers. However, the code generator for this library is nowhere to be found in the nuget package. You can download it here.

The following is an example of executing the CLI tool

protogen -i:input.proto -o:output.cs

Google Protobuf: C# Generating a Class from a .proto file

The example found on the csharp tutorial page doesn’t work. Instead do the following

  1. Open visual studio, open nuget command line, type :Install-Package Google.ProtocolBuffers , link : ProtocolBuffers 2.4.1.555
  2. Find Package/Google.ProtocolBuffers.2.4.1.555/tools/ProtoGen.exe
  3. Use command line, type : ProtoGen.exe addressbook.proto -output_directory=C:\trash

Source: Stackoverflow Post

Update 6/13/2017

Marc Gravell has an online tool for generating C# code from a .proto file.

http://protogen.marcgravell.com/