Skip to content

Instantly share code, notes, and snippets.

@jezman
jezman / check_mounts.sh
Created August 21, 2020 11:21
Сhecking mounted resources by ip.
#!/bin/bash
grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}" /etc/fstab | uniq | sort > mount_on_boot
df -h | grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}" | uniq | sort > already_mounted
DIFF=$(diff mount_on_boot already_mounted)
if [ "$DIFF" != "" ]
then
logger "do something"
@jezman
jezman / restart-network.sh
Last active October 24, 2024 07:55
PROXMOX: Apply network settings without reboot.
#/bin/bash
if [[ "$EUID" -ne 0 ]]; then
echo "Permission denied"
exit 1
fi
cp /etc/network/interfaces /etc/network/interfaces.new
systemctl restart networking.service
@jezman
jezman / wgadd.sh
Created February 28, 2020 06:07
Add wireguard peer.
#!/bin/bash
if [[ "$EUID" -ne 0 ]]; then
echo "Permission denied"
exit
fi
WG_CONFIG="/etc/wireguard/wg0.conf"
[ -f $WG_CONFIG ] || echo "Wireguard config not found"; exit 86
@jezman
jezman / switch.expect
Created December 10, 2019 08:42
Dlink switch backup. 1210 and 1510 series.
#!/usr/bin/expect
#==============
# 1510 series =
#==============
set switch "DGS-1510-52"
set ip "switch_ip"
set tftp_host "remote_tftp_server"
set password "pass"
@jezman
jezman / qna.monit.rc
Last active March 7, 2019 07:17
Monit configuration
# Nginx
check process nginx
with pidfile /run/nginx.pid
start program = "/bin/systemctl start nginx.service"
stop program = "/bin/systemctl stop nginx.service"
if cpu > 60% for 2 cycles then alert
if cpu > 80% for 5 cycles then restart
if memory usage > 80% for 5 cycles then restart
if failed host 127.0.0.1 port 80 protocol http
then restart
-- Создайте базу данных test_guru
CREATE DATABASE test_guru;
-- Таблицу categories с атрибутом title
CREATE TABLE categories(
id SERIAL PRIMARY KEY,
title VARCHAR(50) NOT NULL
);
-- Таблицу tests в которой должны быть атрибуты title, level, внешний ключ к таблице categories
======================================
GET /anything HTTP/1.1
Host: httpbin.org
HTTP/1.1 200 OK
Connection: keep-alive
Server: gunicorn/19.9.0
Date: Mon, 01 Oct 2018 14:10:05 GMT
Content-Type: application/json
Content-Length: 247
@jezman
jezman / github_repo_create.sh
Created October 1, 2018 12:42
Create blank repo on github via bash
#!/usr/bin/env bash
curl -XPOST -H "Authorization: token $GITHUB_TOKEN"\
https://api.github.com/user/repos -d "{\"name\":\"$1\"}"
mkdir ~/github/$1
cd ~/github/$1
echo "# $1" >> README.md
git init
git add README.md
git commit -m "first commit"
@jezman
jezman / create_repo
Last active August 14, 2018 11:51 — forked from simbalinux/create_repo
create_repo
#!/usr/bin/env bash
repo_name=$1
test -z $repo_name && echo "Repo name required." 1>&2 && exit 1
curl -XPOST -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/user/repos -d "{\"name\":\"$repo_name\"}"
@jezman
jezman / mover.py
Last active April 27, 2018 11:29
Moves files with numbers in the file to subfolder.
#!/usr/bin/env python3
import argparse
import os
from sys import argv
parser = argparse.ArgumentParser()
parser.add_argument("file", help='file with shots numbers')
parser.add_argument("folder", help='folder to scan')
args = parser.parse_args()