Skip to content

Instantly share code, notes, and snippets.

@alpegon
alpegon / install_vbox5.2_xenial.sh
Created February 27, 2018 09:59
Install virtual box 5.2 in ubuntu 16.05 lts distribution
#!/bin/bash
# Add vbox repo
bash -c 'echo "deb https://download.virtualbox.org/virtualbox/debian xenial contrib" >> /etc/apt/sources.list'
# Add key certificates
wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | apt-key add -
# Install vbox
apt-get update
apt-get install virtualbox-5.2
apt-get install dkms
@alpegon
alpegon / scp.sh
Created October 2, 2017 08:46
scp files via intermediate host
#!/bin/bash
# Example invocation
# ./scp.sh test_file.tar.gz ub@192.168.0.1 ub@10.0.0.2:~
FILE=$1
INTERMEDIATE_HOST=$2
END_HOST=$3
scp -oProxyCommand="ssh -W %h:%p $INTERMEDIATE_HOST" $FILE $END_HOST
@alpegon
alpegon / disable_service.sh
Created February 15, 2017 16:18
Disable auto update and upgrade Ubuntu 16.04
# From https://www.hiroom2.com/2016/05/18/ubuntu-16-04-auto-apt-update-and-apt-upgrade/
# Fix dpkg error in ubuntu 16
sudo systemctl disable apt-daily.service # disable run when system boot
sudo systemctl disable apt-daily.timer # disable timer run
#!/bin/bash
# From https://gist.github.com/earthgecko/3089509
cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 12 | head -n 1
# Edit ~/.ssh/config
# As an example, your config file could look like this:
Host database
HostName <real IP address or hostname here>
User username
# Then you can type ssh database on the command line and ssh will automatically do ssh username@ip.address for you.
# Why not dind -> https://jpetazzo.github.io/2015/09/03/do-not-use-docker-in-docker-for-ci/
# Instead of starting “child” containers, this will start “sibling” containers.
docker run -v /var/run/docker.sock:/var/run/docker.sock ...
# Find out what package install the binary that you want
yum whatprovides *bin/rpmbuild* # --> We wnat to install rpmbuild
# Find system version
lsb_release -a
# Find installed package version
dpkg -s <packagename>
# Find available package versions
apt-cache policy <packageName>
# Create intermediate folders
#!/bin/bash
# Removes docker containers then docker images and lastly clears cache
# From https://github.com/docker/docker/issues/928
docker rm $(docker ps -a -q) && docker rmi $(docker images -q) && docker ps -a | cut -c-12 | xargs docker rm
@alpegon
alpegon / update_git_branch.sh
Last active April 14, 2016 15:15
Git merge master with branch
git remote add upstream $REMOTE_REPOSITORY
git fetch upstream
git merge upstream/$BRANCH_TO_MERGE