Skip to content

Instantly share code, notes, and snippets.

View kapb14's full-sized avatar
😤

Aleksandr Karushin kapb14

😤
View GitHub Profile
@kapb14
kapb14 / wget_fetch_repo.sh
Created June 16, 2018 16:39
wget: recursively download packages from repository
#!/bin/bash
##
## wget -r -np -nH –cut-dirs=3 -R index.html http://hostname/aaa/bbb/ccc/ddd/
## Explanation:
## It will download all files and subfolders in ddd directory:
## recursively (-r),
## not going to upper directories, like ccc/… (-np),
## not saving files to hostname folder (-nH),
## but to ddd by omitting first 3 folders aaa, bbb, ccc (–cut-dirs=3),
## excluding index.html files (-R index.html)
@kapb14
kapb14 / upgrade-nodejs-version.sh
Created June 16, 2018 16:40
upgrade nodejs and npm version with "n"
#!/bin/bash
check_ver(){
node --version
npm --version
}
check_ver
npm cache clean -f
npm update npm -g
npm install -g n
@kapb14
kapb14 / .snippets.bash
Last active June 16, 2018 16:45
Some useful bash snippets
# current script base name
SCRIPTNAME=$(basename $0)
# get full path to directory where THIS script placed
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
@kapb14
kapb14 / Dockerfile
Created June 18, 2018 11:24
Dante proxy with docker-compose setup
FROM vimagick/dante
ARG proxy_user
ARG proxy_pass
ADD ./sockd.conf /etc/sockd.conf
RUN echo "\n\tCreating a new user for proxy\n\t\tusername: $proxy_user\n\t\tpassword: $proxy_pass\n\n" \
&& useradd $proxy_user \
&& echo $proxy_user:$proxy_pass | chpasswd
EXPOSE 3333
@kapb14
kapb14 / README.md
Last active December 20, 2021 20:12
Nginx HTTP status code monitoring with Zabbix and Lua
  1. нужен LUA модуль для Nginx, он есть в репах Debian

apt-get install nginx-extras

  1. используется lua скрипт для мониторинга Nginx при помощи prometheus (а че - он удобный вполне)
mkdir /etc/nginx/lua
git clone https://github.com/knyar/nginx-lua-prometheus /etc/nginx/lua/nginx-lua-prometheus
@kapb14
kapb14 / fpm-status
Created July 2, 2018 15:04
php fpm status commandline script with pool name as argument
#!/bin/bash
if [[ -z $1 ]]; then
pool_name="www"
elif [[ "$1" == "--help" ]] || [[ "$1" == "-h" ]] || [[ "$1" == "help" ]]; then
echo "Usage: $(basename $0) [FPM_POOL_NAME]"
exit 1
elif [[ "$1" == "--list" ]] || [[ "$1" == "-l" ]] || [[ "$1" == "list" ]]; then
for p in $(grep -h "^\[" /etc/php/7.1/fpm/pool.d/*.conf | tr -d '[|]'); do
echo " ${p}"
@kapb14
kapb14 / mnt-mail-var.automount
Created September 13, 2018 13:30
Automount SSHFS share with systemd
[Unit]
Description=SSHFS share with logs
Requires=network-online.target
[Automount]
Where=/mnt/mail/var
TimeoutIdleSec=301
[Install]
WantedBy=graphical.target
@kapb14
kapb14 / editrc.bash
Created September 14, 2018 09:14
Bash function to select, edit and then source one of .bashrc* files in user's home directory
function editrc () {
if [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]] || [[ "$1" == "help" ]]; then
cat <<EOF
Usage: editrc [--help|-h|help] [ID]
[ID] - first column in output (index number)
It may be executed without arguments and select the file with interactive prompt.
EOF
return
@kapb14
kapb14 / README.md
Last active September 24, 2018 10:44
Simple and useful interactive menu for ssh-config with percol
@kapb14
kapb14 / run_powershell_cmdlet.py
Created September 28, 2018 07:28
Run PowerShell commandlet or .ps1 file with parameters from python (2.7) script
#-*- coding: utf-8 -*- .
import subprocess, os, sys, json
MY_PROCESS = "chrome"
print("MY_PROCESS: %s" % MY_PROCESS)
p = subprocess.Popen([
"C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\powershell.exe",
"-ExecutionPolicy", "Bypass",
"-NoLogo",