Skip to content

Instantly share code, notes, and snippets.

View bbichero's full-sized avatar

Baptiste bbichero

View GitHub Profile
@bbichero
bbichero / mbr2gpt.md
Created March 19, 2019 17:18 — forked from holms/mbr2gpt.md
Create GPT partition table and Create logical volumes

Create GPT partition table

Sorry but you HAVE to go with rescue disk.

parted /dev/sdb
(parted) mklabel gpt
(parted) mkpart primary 0GB 100%
(parted) print
#!/bin/bash
SCRIPTNAME="${0##*/}"
# if the archive file does not exist,
# call this function with a message
err() {
printf >&2 "$SCRIPTNAME: $*\n"
exit 1
}
@bbichero
bbichero / fw.stop
Created November 25, 2017 18:31
Remove all iptables rules
#!/bin/bash
# Script must be run as root, so check EUID in user's env
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit 1
fi
echo "Stopping firewall and allowing everyone..."
ipt="/sbin/iptables"
#!/bin/bash
# Script must be run as root, so check EUID in user's env
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit 1
fi
iptables_repo="https://gist.github.com/2fdddd8fc0a62b7fb58b8cc9701f952b.git"
@bbichero
bbichero / ftp.sh
Last active September 24, 2017 15:40
Send file to ftp remote server
#!/bin/bash
# Take one arg, and int, return 1 if variable is an INT or 0 if not
function ft_is_int()
{
# Check if value is numeric
if [ "$1" -eq "$1" ] 2>/dev/null
then
return 0
else
@bbichero
bbichero / fw.start
Last active November 28, 2018 22:26
Simple Iptable rules to protect you from scan, DDOS and flood
#!/bin/bash
#TODO: external configuration file with all wanted config
# Your DNS servers you use: cat /etc/resolv.conf
DNS_SERVER="80.67.169.12 80.67.169.40"
# ssh port for vm
ssh_port=22
@bbichero
bbichero / iptables.sh
Last active September 13, 2017 16:46 — forked from thomasfr/iptables.sh
iptable rules to allow outgoing DNS lookups, outgoing icmp (ping) requests, outgoing connections to configured package servers, outgoing connections to all ips on port 22, all incoming connections to port 22, 80 and 443 and everything on localhost
#!/bin/bash
#TODO: external configuration file with all wanted config
###
#
# IF you want to EDIT this file but also want futur update
# A suggest you to create another git branch
# Do the following:
# git checkout -b peronal
@bbichero
bbichero / ssh_rsa_connection.sh
Last active September 6, 2017 18:06
Script for ssh connection with rsa key between 2 host, you must edit library_path and download librayr at => https://github.com/bbichero/shell_library
#!/bin/bash
# TODO: Handle hostname + IPv4 instead of only IPv4
library_path=".."
# Check if library exist in current path
if [ -f "${library_path}/shell_library/type_functions.sh" ]
then
# Include library
. ${library_path}/shell_library/type_functions.sh
@bbichero
bbichero / 2repos-sync.sh
Created April 12, 2017 14:40 — forked from yorammi/2repos-sync.sh
Sync 2 remote repositories script - Just define the 3 variables (use export command for that!)
#!/bin/bash
# REPO_NAME=<repo>.git
# ORIGIN_URL=git@<host>:<project>/$REPO_NAME
# REPO1_URL=git@<host>:<project>/$REPO_NAME
rm -rf $REPO_NAME
git clone --bare $ORIGIN_URL
if [ "$?" != "0" ]; then
echo "ERROR: failed clone of $ORIGIN_URL"