Skip to content

Instantly share code, notes, and snippets.

@pi-aej
pi-aej / kestrel.service
Created August 1, 2016 07:41
Start dotnet core app as background service in ubuntu
#!/bin/sh
### BEGIN INIT INFO
# Provides: kestrel
# Required-Start: $local_fs $network $named $time $syslog
# Required-Stop: $local_fs $network $named $time $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Script to run asp.net 5 application in the background
### END INIT INFO
#!/bin/bash
#
#First, prompt user to set the timezone
sudo dpkg-reconfigure tzdata
#Restart NTP service, force time update
sudo service ntp stop
export NTPDATE_USE_NTP_CONF
sudo ntpdate-debian -t 10
@pi-aej
pi-aej / debian_add_locale.sh
Created May 13, 2016 04:51
dpkg-reconfigure locales locale-gen non-interactive
#Adds a locale to a debian system in non-interactive mode
sudo sed -i '/^#.* en_US.* /s/^#//' /etc/locale.gen
sudo locale-gen
# The sed script strips off all the comments so that we can
# document what we're doing in-line with the actual commands
# Note that a blank line (commented as "defualt" will send a empty
# line terminated with a newline to take the fdisk default.
sed -e 's/\t\([\+0-9a-zA-Z]*\)[ \t].*/\1/' << EOF | fdisk /dev/sdb
d # delete existing partition
n # new partition
p # primary partition
1 # partition number 1
# default - start at beginning of disk
@pi-aej
pi-aej / jenkins_upstream_build_number.sh
Created December 11, 2015 03:16
Get upstream build number from Jenkins
UPSTREAM=`curl "http://jenkins:8080/job/upstreamjob/lastBuild/api/xml?depth=1&xpath=/freeStyleBuild/number"`
NUMBER=`echo "$UPSTREAM" | sed "s/[^0-9]//g"`
wget http://jenkins:8080/job/upstreamjob/$NUMBER/artifact/workspace/VERSION -O VERSION
@pi-aej
pi-aej / jenkins_build_slave.sh
Last active November 13, 2015 03:36
Requirements for jenkins build slaves
apt-get install git curl chromedriver
sudo ln -s /usr/lib/chromium/chromedriver /usr/bin
#Run rvm plugin 1.9.3
cd $WORKSPACE
bash -c "source ~/.rvm/scripts/rvm && rvm use --install --create 1.9.3 && export > rvm.env"
@pi-aej
pi-aej / pg_auto_shared_buffers.sh
Created November 12, 2015 23:48
Auto set postgresql shared_buffers to fraction of available memory
#!/bin/bash
## Adjust shared_buffer size for system (25% of available)
SYS_MEM=`cat /proc/meminfo | grep MemTotal | sed "s/[^0-9]//g"`
PG_MEM=`echo $(( $SYS_MEM / 4 ))`
RE="s/##PG_MEM##/$PG_MEM/g"
## Substitute shared_buffers in your config with ##PG_MEM##
## e.g: shared_buffers = ##PG_MEM##kB