Skip to content

Instantly share code, notes, and snippets.

View MParvin's full-sized avatar

Mohammad Parvin MParvin

View GitHub Profile
@MParvin
MParvin / Upgrade_Debian_9_to_10.sh
Created January 27, 2020 12:26
Simple bash scripts
#!/bin/bash
# First upgrade current packages
apt update | grep upgradable && apt upgrade -y
# Change debian repository to 10 (Buster)
sed -i 's/stretch/buster/gm' /etc/apt/sources.list
# Upgrade packages with Debian 10 repository
apt update && apt upgrade -y
@MParvin
MParvin / touchpad_manger.sh
Created August 7, 2020 10:29
Easy disable and enable touch pad from Bash
#!/bin/bash
showUsage() {
echo -e "Usage is /scripts/tochpad.sh [OPTIONS]\n\t-e To enable touch pad\n\t-d For Disable touch pad\n\t-h for this Help"
}
if [ "$#" -eq 0 ]
then
showUsage
exit 1
fi
@MParvin
MParvin / nginx_rtmp_hls.conf
Created August 27, 2020 09:57
Nginx config for rtmp and hls
daemon off;
error_log logs/error.log;
events {
worker_connections 1024;
}
rtmp {
server {
listen 1935; # Listen on standard RTMP port
chunk_size 4000;
application show {
events{}
rtmp {
server {
listen 1935;
application live {
live on;
interleave on;
hls on;
hls_path /tmp/hls;
@MParvin
MParvin / todo_finder.sh
Created December 28, 2020 00:00
Very Simple Todo finder for Python written in Bash
#!/bin/bash
# Show one line before (-B 1) and one line after (-A 1) matched
# .venv excluded
# Used -n to show line number
# -s for prevent displaying error messages
# -r for recursive, in some versions of grep -r doesn't exists
grep 'TODO' -B 1 -A 1 --color --exclude-dir=.venv -nsr ./
@MParvin
MParvin / mysql_dump.sh
Last active November 6, 2022 09:40
MySQL dump with telegram failure notification
#!/bin/bash -x
# database credentials
db_user=""
db_pass=""
db_name=""
db_host="" # e.g 127.0.0.1 or localhost
# FTP credentials
ftp_url="" e.g ftp://ftp.example.com
@MParvin
MParvin / docker-dns-bridge-fix.sh
Last active March 18, 2024 22:21
Resolve docker dns problem, with remove bridge and restart docker, I used this answer: https://serverfault.com/a/642984
#!/bin/bash
install_brctl_in_debian(){
apt update && apt install -y bridge-utils && \
}
install_brctl_in_rhell(){
yum makecache && yum install -y bridge-utils && \
}
@MParvin
MParvin / touchpad_mng.sh
Created February 24, 2022 13:34
Touchpad manager, to enable and disable Laptop touchpad from CLI.
#!/bin/bash -x
showUsage() {
echo -e "Usage is /scripts/tochpad.sh [OPTIONS]\n\t-e To enable touch pad\n\t-d For Disable touch pad\n\t-h for this Help"
}
if [ "$#" -eq 0 ]
then
showUsage
exit 1
fi
@MParvin
MParvin / manage_vpns.sh
Last active August 27, 2023 07:16
Ubuntu CLI VPN manager
#!/bin/bash
function check_status {
# $1 is VPN name
vpnName=$1
vpnIP=`nmcli connection show $vpnName | grep 'IP4.ADDRESS\[1\]' | awk '{print $2}' | cut -d'/' -f1`
vpnGateway=`nmcli connection show $vpnName | grep IP4.GATEWAY | awk '{print $2}'`
if [ "$vpnGateway" == "--" ]
then
vpnGateway=`echo $vpnIP | sed 's/\.[0-9]\{1,3\}$/\.1/'`
@MParvin
MParvin / .gitconfig
Created August 29, 2022 06:21
My git shortcuts
[user]
email = MyMail
name = Mohammad Parvin
[alias]
a = add
b = branch
s = status
c = clone
i = init
p = push