Skip to content

Instantly share code, notes, and snippets.

@bordeo
Last active September 24, 2020 09:36
Show Gist options
  • Save bordeo/56626698371914fc4ba6c47264f1bc3b to your computer and use it in GitHub Desktop.
Save bordeo/56626698371914fc4ba6c47264f1bc3b to your computer and use it in GitHub Desktop.
Hevelop Camup PC Setup
#!/bin/bash
# terminator
sudo add-apt-repository -y ppa:gnome-terminator
sudo apt-get update
sudo apt-get install -y terminator
# sublime text
wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -
echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list
sudo apt-get update
sudo apt-get install -y sublime-text
# vscode
sudo snap install --classic code
# data-grip
sudo snap install datagrip --classic
# git
sudo apt-get install -y git
# chrome
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt install -y ./google-chrome-stable_current_amd64.deb
rm ./google-chrome-stable_current_amd64.deb
# docker
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository -y "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
sudo apt update
apt-cache policy docker-ce
sudo apt install -y docker-ce
sudo usermod -aG docker ${USER}
# preload docker images
sudo docker pull mysql:5.7
sudo docker pull jwilder/nginx-proxy
sudo docker pull hevelop/php-devtools:7.4-1.1.0
sudo docker pull debian:stretch
sudo docker pull hevelop/php:7.4-fpm-buster
sudo docker pull nginx:mainline-alpine
sudo docker pull redis
sudo docker pull elasticsearch:7.6.2
# mysql-client
sudo apt-get install -y mysql-client
# make
sudo apt-get install -y build-essential
# docker-compose
sudo curl -L https://github.com/docker/compose/releases/download/1.26.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
# phpstorm
sudo snap install phpstorm --classic
# composer
sudo wget -O /usr/bin/composer https://getcomposer.org/composer.phar
sudo chmod +x /usr/bin/composer
# n98-magerun2
sudo wget -O /usr/bin/n98-magerun2 https://files.magerun.net/n98-magerun2.phar
sudo chmod +x /usr/bin/n98-magerun2
# ca-gen
sudo wget -O /usr/bin/ca-gen https://github.com/devilbox/cert-gen/raw/master/bin/ca-gen
sudo chmod +x /usr/bin/ca-gen
# cert-gen
sudo wget -O /usr/bin/cert-gen https://github.com/devilbox/cert-gen/raw/master/bin/cert-gen
sudo chmod +x /usr/bin/cert-gen
# certificates
mkdir -p ~/nginx/certs
sudo ca-gen -v -c IT -s Padova -l Padova -o Hevelop -u Hevelop -n hevelop.com \
-e [email protected] ~/nginx/certs/hevelop-rootCA.key ~/nginx/certs/hevelop-rootCA.crt
sudo cert-gen -v -n magento2.loc -a "*.magento2.loc" \
~/nginx/certs/hevelop-rootCA.key \
~/nginx/certs/hevelop-rootCA.crt \
~/nginx/certs/default.key \
~/nginx/certs/default.csr \
~/nginx/certs/default.crt
sudo mkdir -p /usr/share/ca-certificates/hevelop
sudo cp ~/nginx/certs/hevelop-rootCA.key /usr/share/ca-certificates/hevelop
sudo cp ~/nginx/certs/hevelop-rootCA.crt /usr/share/ca-certificates/hevelop
sudo dpkg-reconfigure ca-certificates
sudo apt-get install -y libnss3-tools
### Script installs root.cert.pem to certificate trust store of applications using NSS
### (e.g. Firefox, Thunderbird, Chromium)
### Mozilla uses cert8, Chromium and Chrome use cert9
###
### Requirement: apt install libnss3-tools
###
###
### CA file to install
###
certfile="${HOME}/nginx/certs/hevelop-rootCA.crt"
certname="Hevelop CA"
###
### For cert8 (legacy - DBM)
###
for certDB in $(find ~/ -name "cert8.db")
do
certdir=$(dirname ${certDB});
certutil -A -n "${certname}" -t "TCu,Cu,Tu" -i ${certfile} -d dbm:${certdir}
done
###
### For cert9 (SQL)
###
for certDB in $(find ~/ -name "cert9.db")
do
certdir=$(dirname ${certDB});
certutil -A -n "${certname}" -t "TCu,Cu,Tu" -i ${certfile} -d sql:${certdir}
done
# docker mysql and nginx
sudo docker network create devbox
sudo docker network create mysql
sudo docker network create redishost
mkdir -p ~/nginx/tmpl
wget -O ~/nginx/tmpl/nginx.tmpl https://gist.github.com/etessari/34ee535ab244428963f64782dc52bbff/raw/73962959d97278eec001200f000d0a1722548ac5/nginx.tmpl
sudo docker run --name mysqlhost --network="mysql" -e MYSQL_ROOT_PASSWORD=sqladm -p 3306:3306 --mount type=volume,src=mysql-data,dst=/var/lib/mysql --restart=unless-stopped -d mysql:5.7
sudo docker run --name nginx --network="devbox" -d -p 80:80 -p 443:443 -v /var/run/docker.sock:/tmp/docker.sock:ro -v ~/nginx/certs:/etc/nginx/certs:cached -v ~/nginx/tmpl/nginx.tmpl:/app/nginx.tmpl:cached --restart=unless-stopped -d jwilder/nginx-proxy
echo "127.0.0.1 magento2.loc www.magento2.loc" | sudo tee -a /etc/hosts
# necessary for elasticsearch
echo "vm.max_map_count=262144" | sudo tee -a /etc/sysctl.conf
# wait for mysql to be ready then create database
sleep 5
mysql -h 127.0.0.1 -u root -psqladm -e "CREATE DATABASE magento2_mage;"
# unzip
sudo apt-get install -y unzip
# download project files
mkdir -p ~/Projects
wget -O magento2-project.zip "https://docs.google.com/uc?export=download&id=1f_G5Im8-XkNcZe0A_0pfyEvS_8I-VIE0"
unzip magento2-project.zip -d ~/Projects
rm magento2-project.zip
# apply the new group membership
echo ""
echo ""
echo "I'm going to log out to apply new group membership"
sleep 5
kill -9 -1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment