Skip to content

Instantly share code, notes, and snippets.

View BorysVrublevskyi's full-sized avatar

BorysVrublevskyi

View GitHub Profile
@BorysVrublevskyi
BorysVrublevskyi / amazon-cloudwatch-agent.md
Created July 3, 2024 13:13
How to install and configure amazon cloudwatch agent

Source https://devopscube.com/how-to-setup-and-push-serverapplication-logs-to-aws-cloudwatch/

sudo yum install collectd
sudo yum install amazon-cloudwatch-agent
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-config-wizard
ll /opt/aws/amazon-cloudwatch-agent/bin/config.json
sudo cp /opt/aws/amazon-cloudwatch-agent/bin/config.json /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json
sudo systemctl start amazon-cloudwatch-agent.service
sudo systemctl status amazon-cloudwatch-agent.service
@BorysVrublevskyi
BorysVrublevskyi / README.md
Last active November 22, 2023 14:23
MailCow Postfix regex catch mail redirect

This will allow you to match incoming mail by regex and redirect it to any other mail but will break the Catch-ALL rule in the Aliases.

(Assume that you are root and repo was cloned into the /root/mailcow-dockerized)

Override main.cf

nano /root/mailcow-dockerized/data/conf/postfix/extra.cf
@BorysVrublevskyi
BorysVrublevskyi / pritunl-docker-compose.yml
Last active April 21, 2023 23:03
Pritunl VPN Server with MongoDB and Traefik
version: "3"
services:
mongo:
image: mongo:latest
restart: always
volumes:
- ./db:/data/db
pritunl:
@BorysVrublevskyi
BorysVrublevskyi / hyper-v.ps1
Last active February 1, 2023 19:46
Some handy Hyper-V commands for PowerShell
# Get info
Get-VM -VMname * | Select-Object VMname,State,AutomaticStartAction #,AutomaticStartDelay,AutomaticStopAction
# Start all VMs that must be running
Get-VM -VMname * | Select-Object VMname,State,AutomaticStartAction | `
Where-Object {($_.State -eq 'Off') -and ($_.AutomaticStartAction -eq 'Start')} | `
select -ExpandProperty VMname | Start-VM
# Turn off critical VMs
Get-VM -VMname * | Select-Object VMname,State,AutomaticStartAction | `
@BorysVrublevskyi
BorysVrublevskyi / import-k8s-contexts.ps1
Last active February 8, 2023 18:29
Script to import all *.yaml Kubernetes configs. Works only in the current terminal.
# export KUBECONFIG=$(for YAML in $(find ${HOME}/.kube -name '*.yaml') ; do echo -n ":${YAML}"; done) # bash example
function importctx {
$list=Get-ChildItem -Path $HOME\.kube\ -Filter *.yaml -File -Name #-Recurse
$env:KUBECONFIG="$HOME\.kube\config"
foreach ($contect in $list) {
$env:KUBECONFIG=("$env:KUBECONFIG;$HOME\.kube\$contect")
}}
importctx
@BorysVrublevskyi
BorysVrublevskyi / mysql-backup-restore.md
Last active November 17, 2022 09:05
MySQL backup and restore
mysqldump --routines --single-transaction EventLogging | gzip -c > eventlogging.sql.gz
gunzip < /tmp/eventlogging.sql.gz | mysql -u root -p EventLogging

For big backup file

mysql -u root -p
set global net_buffer_length=1000000; --Set network buffer length to a large byte number
@BorysVrublevskyi
BorysVrublevskyi / create-shortcut.ps1
Created September 20, 2022 07:29
Create Firefox shortcuts for multiple profiles
# Amount of needed Firefox profiles
$amount=2
# if ( Test-Path -Path "C:\Program Files\Mozilla Firefox\" ){
# curl.exe -O firefox.exe https://download.mozilla.org/?product=firefox-latest-ssl&os=win64&lang=uk
# }
# Create $amount profiles
while($num -lt $amount){

HowTo install sqlsrv

HowTo install pcntl

php -v
wget http://php.net/distributions/php-7.4.27.tar.gz
tar zxvf php-7.4.27.tar.gz
ll
cd php-7.4.27/ext/pcntl
phpize
@BorysVrublevskyi
BorysVrublevskyi / ansible-cheatsheet.md
Last active February 7, 2024 14:26
Ansible-cheatsheet.md

Vault

ansible-vault create --vault-id zabbix@~/ans-ps-file ~/ans-vault-zabbix.yml
ansible-vault view --vault-id zabbix@~/ans-ps-file ~/ans-vault-zabbix.yml
ansible-vault view --vault-pass-file ~/ans-ps-file ~/ans-vault-zabbix.yml
# rekey it!

Local dynamic inventory (nmap)

@BorysVrublevskyi
BorysVrublevskyi / k8s-backup-SonarQube.yml
Last active November 30, 2021 06:04
Backup SonarQube Posgres DB to NFS share
apiVersion: batch/v1
# apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: sonar-postgres-backup
spec:
# schedule: "0 2 * * *"
schedule: "@daily"
jobTemplate:
spec: