Skip to content

Instantly share code, notes, and snippets.

View rajeshisnepali's full-sized avatar
:octocat:
Focused

Rajesh Chaudhary rajeshisnepali

:octocat:
Focused
View GitHub Profile
@rajeshisnepali
rajeshisnepali / remove-server.sh
Created November 25, 2018 01:29
This script remove server blocks [nginx]
#!/bin/bash
# to be able to work this function globally, copy or create link in /usr/local/bin
# remove domain if found
sudo sed -i '/'$1'/d' /etc/hosts
# remove sites-available & sites-enabled if found
file=$1
@rajeshisnepali
rajeshisnepali / create-db.sh
Created February 6, 2019 14:07
create database (mysql or maria db)
#!/bin/bash
#format
# create-db.sh '`test-1234`'
mysql -u root -p <<MYSQL_SCRIPT
CREATE DATABASE $1 CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
MYSQL_SCRIPT
echo Mysql Database $1 created
@rajeshisnepali
rajeshisnepali / synclient.sh
Created February 6, 2019 14:09
disable keyboard while typing (synclient)
#!/bin/bash
# synclient
# Disable touchpad while typing
synclient PalmDetect=1
synclient PalmMinWidth=8
synclient PalmMinZ=100
@rajeshisnepali
rajeshisnepali / drop-db.sh
Created February 27, 2019 04:19
drop database in mysql
#!/bin/bash
#format
# drop-db.sh '`test-1234`'
mysql -u root -p <<MYSQL_SCRIPT
DROP DATABASE $1;
MYSQL_SCRIPT
echo Mysql Database $1 dropped
@rajeshisnepali
rajeshisnepali / project-create.sh
Last active February 28, 2019 05:04 — forked from francoisromain/project-create.sh
A bash script to create a Git post-receive hook to deploy after a Git push
#!/bin/bash
# Call this file with `bash ./project-create.sh project-name [service-name]`
# - project-name is mandatory
# - service-name is optional
# This will creates 4 directories and a git `post-receive` hook.
# The 4 directories are:
# - $GIT: a git repo
# - $TMP: a temporary directory for deployment
@rajeshisnepali
rajeshisnepali / deploy-to-server.sh
Created March 9, 2019 11:48
automatically deploy to server with git
#!/bin/bash
# set up automatic deployment with git to VPS
# format :::: ./deploy-to-server.sh <project-name>
project=$1
server_www_dir=/var/www/html/$project
server_repo=/srv/git/$project.git
# create server_repo if not exists
@rajeshisnepali
rajeshisnepali / laravel-permissions.sh
Created February 6, 2019 14:08
Give permission and change ownership to run Laravel application
#!/bin/bash
# to be able to work this function globally, copy or create link in /usr/local/bin
# Change ownership for .env
sudo chown $USER:$USER .env
# Give write Permission to /bootstrap/cache & /storage
sudo chown -R $USER:www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache
@rajeshisnepali
rajeshisnepali / Envoy.blade.php
Created June 12, 2019 08:12
Zero Downtime deploy project to server (production)
@servers(['production' => 'ubuntu@X.X.X.X'])
@setup
$repo = 'git@gitlab.com:<username>/<project-name>.git';
date_default_timezone_set('Asia/Kathmandu');
$release = date('YmdHis');
$releases_dir = '/var/www/html/final/releases';
$app_dir = '/var/www/html/final';
$new_release_dir = $releases_dir .'/'. $release;
@rajeshisnepali
rajeshisnepali / install-oh-my-zsh.sh
Last active June 19, 2019 03:31
install oh-my-zsh including `zsh-autosuggestions`
#!/bin/bash
# colors
YELLOW='\e[43m'
LRED='\e[101m'
NC='\033[0m' # No Color
getOSArchitecture() {
arch=$(awk -F= '/^ID_LIKE/{print $2}' /etc/os-release)
if [ "$arch" = "debian" ];
@rajeshisnepali
rajeshisnepali / db-backup.sh
Last active October 24, 2019 05:37
mysql dump database with specific database [folder name].
#!/bin/bash
# colors
GREEN='\033[0;32m'
NC='\033[0m' # No Color
# dbDump functions
dbDump() {
# backup location
LOCATION=~/dumps/