Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# bash < <(curl -s https://gist.githubusercontent.com/Jakis/edb8e65f0dc295c71535/raw/8c80ae83cd41ce5be7af92fa96c2569813ecc612/soloist.sh )
# Running the script if you have downloaded it:
# ./3rq96e.sh
#
testcli() {
res=$( xcode-select -h &>/dev/null )
local status=$?
if [ $status -ne 0 ]
@Jakis
Jakis / gist:9ba5fd8a434cabacd89b
Last active August 29, 2015 14:11
Testing ports with powershell
# Short example that's easy to paste. The original author has a more complete implementation that also tests udp:
# http://www.travisgan.com/2014/03/use-powershell-to-test-port.html
$RemoteServer = "192.168.1.20"
$Port = "8090"
$test = New-Object System.Net.Sockets.TcpClient;
Try {
Write-Host "Connecting to "$RemoteServer":"$Port" (TCP)..";
$test.Connect($RemoteServer, $Port);
Write-Host "Connection successful"; }
Catch { Write-Host "Connection failed"; }
@Jakis
Jakis / gist:0036e31a892c1fb65568
Created December 4, 2014 01:08
function to assign folder permission
function SetACL()
{
param (
[Parameter(Mandatory=$true)]
[string] $Path,
[Parameter(Mandatory=$true)]
[string] $Usertoadd
)
$Acl = (Get-Item $Path).GetAccessControl('Access')
@Jakis
Jakis / bash_parameters.sh
Created November 28, 2014 03:23
Named script parameters in bash
for ((i=1;i<=$#;i++));
do
if [ ${!i} = "-s" ]
then ((i++))
dashs=${!i};
elif [ ${!i} = "-log" ];
then ((i++))
dashlog=${!i};
@Jakis
Jakis / Banish .DS_Store
Created November 23, 2014 21:55
Banish .DS_Store
TARGET=".DS_Store"
#Find all instances of $TARGET and 'git rm' them to remove from the git index.
find . -name "${TARGET}" -print0 | xargs -0 git rm -f --ignore-unmatch
#Check for the presence of .gitignore. If it exists, verify that it contains the value for $TARGET.
#If it doesn't exist, create it, and add the value from $TARGET
if [ ! -f "./.gitignore" ]
then
@Jakis
Jakis / install-chef.ps1
Last active August 29, 2015 14:09
Install Chef
$ErrorActionPreference = "Stop"
#Variables unique to this install:
$appname = "Chef Client for windows"
#$installurl = 'http://www.opscode.com/chef/install.msi'
#$installfile = 'install.msi'
$installurl = "https://opscode-omnibus-packages.s3.amazonaws.com/windows/2008r2/x86_64/chef-windows-11.16.4-1.windows.msi"
$installfile = "chef-windows-11.16.4-1.windows.msi"
#old $options = '/passive /norestart'
@Jakis
Jakis / helpers.ps1
Last active August 29, 2015 14:09
Powershell Helper Functions
function global:Expand-ZIPFile($file, $destination) {
$shell = new-object -com shell.application
$zip = $shell.NameSpace($file)
foreach($item in $zip.items()) {
$shell.Namespace($destination).copyhere($item)
}
}
Expand-ZipFile -file "c:\temp.zip" -destination "c:\temp\"
@Jakis
Jakis / install-git.ps1
Last active August 29, 2015 14:09
Install Git for windows
$ErrorActionPreference = "Stop"
#Variables unique to this install:
$appname = "Git for Windows v1.9.4"
$installurl = "https://github.com/msysgit/msysgit/releases/download/Git-1.9.4-preview20140611/Git-1.9.4-preview20140611.exe"
$installfile = "Git-1.9.4-preview20140611.exe"
$switches = "/silent /norestart"
$pathtoadd = "C:\Program Files (x86)\Git\bin"
@Jakis
Jakis / gist:76ce3a082a7446014afb
Last active August 29, 2015 14:08
Upgrading Splunk
URL='http://www.splunk.com/page/download_track?file=6.1.1/universalforwarder/linux/splunkforwarder-6.1.1-207789-linux-2.6-x86_64.rpm&ac=ga0508_s_splunk&wget=true&name=wget&platform=Linux&architecture=x86_64&version=6.1.1&product=splunk&typed=release'
SPLUNKBINARY='splunkforwarder-6.1.1-207789-linux-2.6-x86_64.rpm'
declare -a servers=('node01' 'node02' 'node03' 'node04' 'node05' 'node06')
for i in "${servers[@]}"; do echo ----- "${i}" -----; sudo ssh "${i}" 'wget -O /tmp/"${SPLUNKBINARY}" "${URL}" && \
yum install -y /tmp/"${SPLUNKBINARY}" && \
SPLUNK="/opt/splunkforwarder/bin/splunk" && \
"${SPLUNK}" start --accept-license --answer-yes --no-prompt && \
"${SPLUNK}" restart && \
"${SPLUNK}" version';done
@Jakis
Jakis / gist:1e23ef19590c9d02f34e
Created November 2, 2014 00:47
Interacting with the Splunk binary
USER="user"
PASS="pass"
#Using the splunk binary to restart
SPLUNK="/opt/splunkforwarder/bin/splunk"
$SPLUNK list forward-server -auth "${USER}":"${PASS}"
$SPLUNK list deploy-poll -auth "${USER}":"${PASS}"
$SPLUNK restart -auth "${USER}":"${PASS}"