Skip to content

Instantly share code, notes, and snippets.

@entrity
Last active August 28, 2018 18:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save entrity/5462105 to your computer and use it in GitHub Desktop.
Save entrity/5462105 to your computer and use it in GitHub Desktop.
# Usage:
# curl https://gist.githubusercontent.com/entrity/5462105/raw/..linux-setup.sh | bash
# Installs
# - .gitconfig
# - .ssh/config
# - .bash_aliases
src=https://gist.githubusercontent.com/entrity/5462105/raw
wget -O ~/.gitconfig $src/.gitconfig
wget -O ~/.bash_aliases $src/.bash_aliases
cd $HOME
mkdir -p .ssh
chmod 700 .ssh
which curl && curl $src/ssh-config >> ~/.ssh/config
ADDENDUM_COMMENT='# Addednum from Entrity sys_setup'
if ! grep -q ".bash_aliases" ~/.bashrc; then
curl $src/.bashrc_addendum >> ~/.bashrc
fi
alias ga='git add -u; git status'
alias gs='git status'
alias ga.='git add -u .; git status .'
alias gs.='git status .'
alias gl='git log'
alias gb='git branch'
alias gd='git diff'
alias gdc='git diff --cached'
alias tp="trash-put"
alias ml="matlab -nosplash -nodesktop"
alias subla="subl ~/.bash_aliases"
alias virt=". activate gen"
alias ipy="python -c 'import IPython; IPython.terminal.ipapp.launch_new_instance()'"
alias ipy3="source activate gen; python3 -c 'import IPython; IPython.terminal.ipapp.launch_new_instance()'"
alias ipy2="source activate p2; python2 -c 'import IPython; IPython.terminal.ipapp.launch_new_instance()'"
alias chx='chmod +x'
alias yt="youtube-dl -f '244+bestaudio/135+bestaudio/243+bestaudio/134+bestaudio' --yes-playlist"
alias yt="youtube-dl -o \"%(playlist_index)s-%(title)s.%(ext)s\" <playlist_link> --yes-playlist"
alias myapt="fakeroot dpkg --force-not-root --instdir=$HOME/tools/apt --admindir=$HOME/tools/apt/db"
alias bracketed_paste_off="printf \"\e[?2004l\"" # Turn off shell putting 0~ and 1~ around your pastes
function rmorig ()
{
find . -type f -name \*_ORIGIN_\* -exec rm {} \;
find . -type f -name \*_REMOTE_\* -exec rm {} \;
find . -type f -name \*_LOCAL_\* -exec rm {} \;
find . -type f -name \*_BACKUP_\* -exec rm {} \;
find . -type f -name \*.orig -exec rm {} \;
}
export rmorig
function playpcm()
{
fin=$1
chan="${2:-2}"
srate="${3:-48000}"
ffplay -ar $srate -ac $chan -f f64le $fin
}
export playpcm
function rot13 ()
{
if [[ -z $1 ]]; then
read -r arg
else
arg=$1
fi
echo "$arg" | tr '[A-Za-z]' '[N-ZA-Mn-za-m]'
}
alias lastlog='ls /home/markham/proj/weakly-vrd/log -t | head -n1 | sed "s/\n//"'
[[ -e ~/.bash_aliases ]] && source ~/.bash_aliases
[user]
name = Markham
email = quinesquines@gmail.com
[credential]
helper = cache
[alias]
s = status
l = log
h = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cgreen\\ [%cn]" --decorate --graph
hl = log --pretty=format:"%C(yellow)%cD%Cgreen\\ [%cn]\\ %Creset%s\\ %Cred%d" --decorate --graph
m = merge --no-ff
b = branch
co = checkout
a = add -u
ce = commit -e
ca = commit -ae
cm = commit -m
cam = commit -am
p = push origin
[push]
default = current
[merge]
conflictstyle = diff3
tool = kdiff3
[color]
ui = true
sudo apt install -y python3-pip python3-dev python3-tk
pip3 install virtualenv ipython matplotlib
ENV=python-env-tensorflow
virtualenv --system-site-packages -p python3 $ENV
>>$HOME/.bash_aliases cat <<HEREDOC
alias virt="source $ENV/bin/activate"
alias ipy="virt; python3 -c 'import IPython; IPython.terminal.ipapp.launch_new_instance()'"
HEREDOC
. $HOME/.bash_aliases
virt && \
pip3 install tensorflow-gpu
# CUDA
# http://docs.nvidia.com/cuda/cuda-installation-guide-linux/#axzz4VZnqTJ2A
verify_cuda_compat ()
{
sudo update-pciids
lspci | grep -i nvidia
# Then check http://developer.nvidia.com/cuda-gpus for compatibility
}
download_cuda ()
{
echo see http://developer.nvidia.com/cuda-downloads for url for your distro\'s cuda
printf 'please enter url for cuda: '
read -r url
wget "$url"
md5sum $(basename "$url")
}
install_cuda ()
{
sudo apt-get install linux-headers-$(uname -r)
sudo dpkg -i $(basename "$url")
sudo apt-get update
sudo apt-get install cuda
>>/etc/profile echo 'export PATH=/usr/local/cuda-8.0/bin${PATH:+:${PATH}}'
>>/etc/profile echo 'export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}'
}
verify_cuda_installation ()
{
cuda-install-samples-8.0.sh &&\
cd NVIDIA_CUDA-8.0_Samples && \
make &&\
# make may fail to find library libnvcuvid
# 1. try to find the lib: sudo find /usr -name libnvcuvid\*
# 2. use the path: LIBRARY_PATH=<dir>:$LIBRARY_PATH make
# See https://devtalk.nvidia.com/default/topic/769578/cuda-6-5-cannot-find-lnvcuvid/
bin/x86_64/linux/release/deviceQuery
}
# When running my python script, I got error:
# ImportError: libcudnn.so.5: cannot open shared object file: No such file or directory
#
# So I went back to https://developer.nvidia.com/rdp/cudnn-download and downloaded cuDNN v5.1 for CUDA 8.0
# and installed that.
# Usage:
# echo export http_proxy=http://proxy-chain.intel.com:911 >> /etc/environment
# echo export https_proxy=https://proxy-chain.intel.com:911 >> /etc/environment
# source /etc/environment
# curl https://gist.githubusercontent.com/entrity/5462105/raw/..sys_setup.sh | bash
#
#
# Files to drop in
# - .gitconfig
# - .bash_aliases
#
# Files to update
# - .bashrc
src=https://gist.githubusercontent.com/entrity/5462105/raw
prompt 'Intel server?' 1
ISINTEL=$choice
[[ $ISINTEL ]] && prompt 'Install pip?'
[[ $choice ]] && sudo apt-get install -y python-pip
[[ $ISINTEL ]] && prompt 'Install trash-cli?'
[[ $choice ]] && sudo easy_install trash-cli
[[ $ISINTEL ]] && prompt 'Install mysql client?'
[[ $choice ]] && sudo apt-get install -y mysql
[[ $ISINTEL ]] && prompt 'Install ruby?'
[[ $choice ]] && sudo apt-get install -y ruby
[[ $ISINTEL ]] && prompt 'Install nodejs?'
if [[ $choice ]]; then
sudo curl -sL https://deb.nodesource.com/setup_4.x | bash
sudo apt-get -qq install -y nodejs
npm config set proxy $http_proxy
npm config set https_proxy $https_proxy
fi
if [[ $ISINTEL ]]; then
# Install CA Certs
sudo "apt-get install unzip &&\
cd /usr/local/share/ca-certificates &&\
wget http://certificates.intel.com/repository/certificates/Intel%20Root%20Certificate%20Chain%20Base64.zip &&\
wget http://certificates.intel.com/repository/certificates/IntelSHA2RootChain-Base64.zip &&\
unzip '*.zip' &&\
rm *.zip &&\
rm *.pem &&\
update-ca-certificates" || ( echo fail && exit 3 )
# Install Docker
# Usage: sudo docker login icapp-dockreg.icloud.intel.com
apt-get update
sudo apt-get install apt-transport-https ca-certificates
sudo -E apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
echo 'deb https://apt.dockerproject.org/repo ubuntu-trusty main' | sudo tee -a /etc/apt/sources.list.d/docker.list >/dev/null
sudo apt-get update
sudo apt-get purge lxc-docker
sudo apt-get install linux-image-extra-$(uname -r)
sudo apt-get install docker-engine
echo "export proxy=\"$http_proxy\"" | sudo tee -a /etc/default/docker >/dev/null
sudo service docker restart
# Install Cloudfoundry
# Usage: cf login -a https://api.apps1-fm-int.icloud.intel.com/
# cf orgs # will list available ORGs
# cf spaces # will list available SPACEs
wget -O cloudfoundry-cli.deb https://cli.run.pivotal.io/stable?release=debian64&source=github
sudo dpkg -i cloudfoundry-cli.deb
cf target -O markhama # ORG
cf target -S Development # SPACE : may need to set up a SPACE at cloudservices.intelcloud.intel.com
fi
source ~/.bashrc
#!/bin/bash
sudo pip install matplotlib
sudo apt install -y libfreetype6-dev
sudo pip install IPython
sudo pip install scipy
sudo pip install sklearn
#!/bin/bash
touch .ssh/authorized_keys
chmod 600 .ssh/authorized_keys
# This file is meant to be sourced, not run as an executable
export src=https://gist.githubusercontent.com/entrity/5462105/raw
prompt()
{
printf "$1"
if [[ $2 ]]; then
printf ' [Y/n] '
read -r choice </dev/tty
[[ ! $choice = n ]] && [[ ! $choice = N ]]
else
printf ' [y/N] '
read -r choice </dev/tty
[[ $choice = y ]] || [[ $choice = Y ]]
fi
choice=$?
}
export -f prompt
Host vision
HostName vision6.idav.ucdavis.edu
Host vision2
HostName vision2.idav.ucdavis.edu
Host pc
HostName pc13.cs.ucdavis.edu
CheckHostIP no
StrictHostKeyChecking no
Host dod
HostName markhamanderson.com
Host tipsy
HostName tipsyology.com
Host godot
HostName godot.cs.ucdavis.edu
Host hpc
HostName hpc1.engr.ucdavis.edu
IdentityFile ~/.ssh/hpc_rsa
Host mycloud
HostName 10.0.0.16
User mar
Host sorgenfrei
HostName 169.237.108.223
Port 4022
#!/bin/bash
# Assuming the that folder share is named 'tmp' (in the vbox shared folders config?)
# and the destination on the guest is tmp:
mkdir -p $HOME/tmp
sudo mount -t vboxsf -o uid=$(whoami) tmp ~/tmp
# FIRST DOWNLOAD AND SET UP CMDER WHICH COMES (OPTIONALLY) WITH GIT BASH
# .bashrc addendum
echo http_proxy=http://proxy-chain.intel.com:911 >> ~/.bashrc
echo https_proxy=https://proxy-chain.intel.com:911 >> ~/.bashrc
# Install nodejs
wget -O ~/Downloads/node.msi https://nodejs.org/dist/v4.4.7/node-v4.4.7-x64.msi
~/node.msi
npm config set proxy $http_proxy
npm config set https_proxy $https_proxy
npm config registry http://registry.npmjs.org/ # It seems that even with the proxy configured, I can't connect to the SSL (default) registry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment