Skip to content

Instantly share code, notes, and snippets.

@srghma
Forked from kopiro/install-docker.sh
Last active May 22, 2021 11:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save srghma/6471eb472ebf3926948cbe4b422c39f3 to your computer and use it in GitHub Desktop.
Save srghma/6471eb472ebf3926948cbe4b422c39f3 to your computer and use it in GitHub Desktop.
Install Docker + Docker-compose on Ubuntu
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
apt-cache policy docker-ce
sudo apt-get install -y docker-ce
sudo curl -o /usr/local/bin/docker-compose -L "https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m)"
sudo chmod +x /usr/local/bin/docker-compose
sudo usermod -a -G docker $USER
# reenter ssh
@srghma
Copy link
Author

srghma commented Apr 23, 2018

# make swap
sudo fallocate -l 8G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

# persist it
sudo cp /etc/fstab /etc/fstab.bak
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

# show info
sudo swapon --show
free -h

@srghma
Copy link
Author

srghma commented Apr 24, 2018

sudo apt-get update -y; \
  sudo apt-get upgrade -y; \
  sudo apt-get update -qq && \
  sudo apt-get install -y build-essential libpq-dev lsb-release

echo "export TERM=xterm" >> ~/.bashrc
# edit ssh keys
vim ~/.ssh/authorized_keys

# or add your key 
cat ~/.ssh/id_rsa.pub | ssh -i ~/key.pem USER@HOST "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"

# or
echo "keys" >> ~/.ssh/authorized_keys
sudo apt-get install -y git make
sudo add-apt-repository ppa:jonathonf/python-3.6
sudo apt-get update
sudo apt-get install python3.6

# or 

sudo ln -s /usr/bin/python3 /usr/bin/python

# sudo apt install python-pip
# pip install distutils

sudo apt install -y highlight atool w3m poppler-utils caca-utils && git clone https://github.com/ranger/ranger && cd ranger/ && sudo make install && cd .. && sudo chown $USER -R ranger && rm -rfd ranger

# TO INSTALL WITHOUT SUDO ON AMAZON LINUX

git clone https://github.com/ranger/ranger && cd $HOME/ranger/
DESTDIR=$HOME/ranger_build make install
echo 'alias ranger="PYTHONPATH=$HOME/ranger_build/usr/lib/python2.7/site-packages $HOME/ranger_build/usr/bin/ranger"' >> $HOME/.bashrc

# TO INSTALL ON AMAZON LINUX
sudo yum install git make && git clone https://github.com/ranger/ranger && cd ranger/ && sudo make install && cd .. && sudo chown $USER -R ranger && rm -rfd ranger
# curl -O https://dl.eff.org/certbot-auto && chmod +x certbot-auto && sudo mv certbot-auto /usr/local/bin/certbot-auto && sudo cp /usr/local/bin/certbot-auto /usr/local/bin/certbot

rm -f /usr/local/bin/certbot /usr/local/bin/certbot-auto
sudo apt install certbot python3-certbot-nginx
# TODO
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:neovim-ppa/stable
sudo apt-get update
sudo apt-get install -y neovim python-dev python3-dev python3-pip
sudo update-alternatives --install /usr/bin/vi vi /usr/bin/nvim 60
sudo update-alternatives --config vi
sudo update-alternatives --install /usr/bin/vim vim /usr/bin/nvim 60
sudo update-alternatives --config vim
sudo update-alternatives --install /usr/bin/editor editor /usr/bin/nvim 60
sudo update-alternatives --config editor

@srghma
Copy link
Author

srghma commented May 24, 2018

Restore from tarsnap

wget https://pkg.tarsnap.com/tarsnap-deb-packaging-key.asc && sudo apt-key add tarsnap-deb-packaging-key.asc && (echo "deb http://pkg.tarsnap.com/deb/$(lsb_release -s -c) ./" | sudo tee -a /etc/apt/sources.list.d/tarsnap.list) && rm -f tarsnap-deb-packaging-key.asc && sudo apt-get update && sudo apt-get install -y tarsnap

# upload key
# cat /etc/tarsnap.conf 
# https://www.tarsnap.com/simple-usage.html#restoring-backups

chown root /root/tarsnap.key
# https://www.starryhope.com/tarsnap-online-backups-for-security-conscious-geeks/
# or
KEYFILE="/home/ubuntu/backup_tarsnap_aws/xxxxxxx.key"

tarsnap --keyfile $KEYFILE --list-archives | sort

ARCH_NAME=/xxxxx
OUT_DIR=/home/ubuntu/
mkdir -p $OUT_DIR

# list content
tarsnap --keyfile $KEYFILE -tv -f $ARCH_NAME

# restore all to dir
tarsnap --keyfile $KEYFILE -x -f $ARCH_NAME -C $OUT_DIR 

@srghma
Copy link
Author

srghma commented May 28, 2018

Install gitlab ci runner

https://about.gitlab.com/2016/04/19/how-to-set-up-gitlab-runner-on-digitalocean/

curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh | sudo bash
sudo apt-get install gitlab-runner
gitlab-runner --version

# goto project settings -> runners
sudo gitlab-runner register

# if docker executor
sudo usermod -a -G docker gitlab-runner 

# if dind
sudo vim /etc/gitlab-runner/config.toml # to add priviliged flag (https://gitlab.com/gitlab-org/gitlab-runner/issues/1544#note_13439656) 
sudo gitlab-runner restart

# in case "New runner. Has not connected yet"
# https://codereviewvideos.com/blog/how-i-solved-new-runner-has-not-connected-yet-in-gitlab-ci/#comment-5803
sudo chown -R gitlab-runner:gitlab-runner /home/gitlab-runner
sudo systemctl restart gitlab-runner.service

@srghma
Copy link
Author

srghma commented Apr 15, 2019

sudo apt-get install git-crypt

@srghma
Copy link
Author

srghma commented Jun 21, 2019

https://askubuntu.com/a/833979/696966

sudo nvim /etc/sysctl.conf
sudo sysctl -p
fs.inotify.max_user_watches=1048576

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment