Skip to content

Instantly share code, notes, and snippets.

@denoww
Last active January 13, 2021 14:17
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 denoww/08f7abbed2ea46475d24a7e9b51fb70d to your computer and use it in GitHub Desktop.
Save denoww/08f7abbed2ea46475d24a7e9b51fb70d to your computer and use it in GitHub Desktop.
config_erp_production
# execute no servidor o comando
# wget -O - https://gist.githubusercontent.com/denoww/08f7abbed2ea46475d24a7e9b51fb70d/raw/config_sc_rails_server.sh | bash
#!/bin/bash
# pt-BR
sudo locale-gen pt_BR.UTF-8
# postgresql-client-12 - psql
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" |sudo tee /etc/apt/sources.list.d/pgdg.list
sudo apt-get update
sudo apt-get -y install postgresql-client-12
# wkhtmltopdf
# sudo apt-get install -y xfonts-75dpi;
# sudo rm -rf wkhtmltox*;
# so_version_code=$(lsb_release -cs)
# wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.${so_version_code}_amd64.deb;
# sudo dpkg -i wkhtmltox*;
# chmods
sudo chmod 7777 -R /tmp; sudo chmod 7777 -R /tmp/*;
# wkhtmltopdf fix - resolver erro de "too many open files" - causado por cabeçalho e rodapém em PDFs com muitas páginas
sudo sh -c "echo '# Sets the open file maximum here.' >> /etc/security/limits.conf"
sudo sh -c "echo '# Generating large PDFs hits the default ceiling (1024) quickly. ' >> /etc/security/limits.conf"
sudo sh -c "echo '* hard nofile 65535' >> /etc/security/limits.conf"
sudo sh -c "echo '* soft nofile 65535' >> /etc/security/limits.conf"
sudo sh -c "echo 'root hard nofile 65535 # Need these two lines because the wildcards (above)' >> /etc/security/limits.conf"
sudo sh -c "echo 'root soft nofile 65535 # are not applied to the root user as well.' >> /etc/security/limits.conf"
# permissao para converter imagem em pdf
sudo sed -i 's#<policy domain="coder" rights="none" pattern="PDF" />#<policy domain="coder" rights="read|write" pattern="PDF" />#' /etc/ImageMagick-6/policy.xml
# Aumentar o swap -> 30 Gb
tamanho_swap=30720
sudo swapoff -a
sudo rm -f /c66-swapfile
echo "Creating your swap file"
sudo dd if=/dev/zero of=/c66-swapfile count=1048576 bs=$tamanho_swap
sudo mkswap /c66-swapfile
sudo chmod 600 /c66-swapfile
sudo swapon /c66-swapfile
sudo bash -c 'echo "/c66-swapfile none swap sw 0 0 " >> /etc/fstab'
sudo chown root:root /c66-swapfile
sudo chmod 0600 /c66-swapfile
echo "Swap file successfully created"
# de 1 em 1 minuto checar se ngix está OK - caso não estiver reiniciar
sudo mkdir /sc_scripts
sudo chmod 777 -R /sc_scripts
sudo mkdir /sc_scripts/logs
sudo chmod 777 -R /sc_scripts/logs
touch /sc_scripts/logs/restart_nginx_on_crash.log
cat << 'EOF' > /sc_scripts/restart_nginx_on_crash.sh
/usr/bin/pgrep nginx;
if [ $? -ne 0 ]; then
sudo service nginx stop
sudo service nginx start
sudo service nginx restart
echo 'Ressucitando Nginx'
else
echo "Nginx em estado Normal";
fi
EOF
sudo chmod 777 /sc_scripts/restart_nginx_on_crash.sh
sudo sh -c "echo \*/1 \* \* \* \* root /sc_scripts/restart_nginx_on_crash.sh '>>' /sc_scripts/logs/restart_nginx_on_crash.log '2>&1' >> /etc/crontab"
# scaliasupdate
wget https://gist.githubusercontent.com/denoww/4a53c2fe43e67979a433f6ef446d11a2/raw -O ~/.bash_aliases && source ~/.bash_aliases
# reboot
sudo reboot -f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment