Skip to content
Vlad edited this page May 17, 2022 · 25 revisions

Vlad's Wiki

Dependencies

https://github.com/lilydjwg/nvchecker

# Install
sudo apt install libcurl4-openssl-dev libssl-dev
python3 -m pip install --user --upgrade nvchecker

# Check versions && compare
NVCHECKER_GITHUB_TOKEN=$GITHUB_TOKEN nvchecker source.ini
NVCHECKER_GITHUB_TOKEN=$GITHUB_TOKEN nvcmp source.ini

# Write old versions
NVCHECKER_GITHUB_TOKEN=$GITHUB_TOKEN nvtake --all source.ini
NVCHECKER_GITHUB_TOKEN=$GITHUB_TOKEN nvtake source.ini prometheus

Git

# GitHub Labels (deprecated). Use `github_labels.sh` scrip.
npm install -g github-label-sync
github-label-sync --dry-run --access-token "$GITHUB_TOKEN" --labels github-label-sync.json vladgh/docker_rsyslog

# Delete merged branches (MUST BE IN PRODUCTION BRANCH!!!)
for branch in $(git-show-merged-branches); do git delete-branch ${branch}; done

RSync

# Simple local (preserve permissions)
rsync -avh --progress --exclude="/lost+found" --exclude="._*" --exclude=".DS_Store" /source remote:/dest

# Fast copy
rsync -rvh --progress --size-only --exclude="/lost+found" --exclude="._*" --exclude=".DS_Store" /source remote:/dest

# Simple delete destination (`--delete` removes the files before the transfer)
rsync -avh --progress --delete-after /source remote:/dest

# Compress for network transmission
rsync -azcvh --progress /source remote:/dest

# Use sudo
rsync -azcvh --progress --rsync-path="sudo rsync" /source remote:/dest

Permissions

# Reset all permissions
FOLDER=/data
sudo chown -R vlad:vlad $FOLDER
sudo find $FOLDER -type f -exec chmod 644 {} \;
sudo find $FOLDER -type d -exec chmod 755 {} \;

# Group permissions
FOLDER=/data
mkdir -p $FOLDER
chown -R :admins $FOLDER
chmod 775 $FOLDER
setfacl -R -m 'group:share:rwx' -m 'd:group:share:rwx' $FOLDER
getfacl $FOLDER

SSH

# Create
ssh-keygen -t rsa -b 4096 -C 'TravisCI' -f ~/.ssh/deploy_rsa

# Use it in your global .env as a BASE64 encoded variable
DEPLOY_RSA=$(base64 --wrap=0 ~/.ssh/deploy_rsa)

# Decode to file
echo "$DEPLOY_RSA" | base64 --decode --ignore-garbage > ~/.ssh/deploy_rsa

# Add to host's authorized keys
ssh-copy-id -i ~/.ssh/deploy_rsa.pub [email protected]

SSHFS

sudo mkdir -p /Volumes/VNuc
sudo chown vlad:staff /Volumes/VNuc
sshfs -o volname=VNuc vnuc: /Volumes/VNuc

# Function to mount volume unless it's already mounted
vdev_fs(){
  if ! mount | grep -q 'vdev: on /Users/vlad/VDev' >/dev/null; then
    sshfs -o volname=VDev vdev: /Users/vlad/VDev
    cd /Users/vlad/VDev/projects
  fi
}

Slack

Notify Slack Hook: ./notify.sh 'la gara'

#!/usr/bin/env sh
/usr/bin/curl -X POST -H 'Content-type: application/json' --data "{\"text\":\"${1:-}\"}" 'https://hooks.slack.com/services/aaa/bbb/ccc'

Disk benchmark

# Synchronous 4K write results
fio --name=random-write --ioengine=sync --iodepth=4 --rw=randwrite --bs=4k --direct=0 --size=256m --numjobs=16 --end_fsync=1
# Asynchronous 4K write results
fio --name=random-write --ioengine=libaio --iodepth=4 --rw=randwrite --bs=4k --direct=0 --size=256m --numjobs=16 --end_fsync=1
# Synchronous 512K write results
fio --name=random-write --ioengine=sync --iodepth=4 --rw=randwrite --bs=512k --direct=0 --size=256m --numjobs=16 --end_fsync=1
# Asynchronous 512K write results
fio --name=random-write --ioengine=libaio --iodepth=4 --rw=randwrite --bs=512k --direct=0 --size=256m --numjobs=16 --end_fsync=1

Check if ports are in use

sudo lsof -i -P -n | grep LISTEN
sudo netstat -tulpn | grep LISTEN
sudo ss -tulpn | grep LISTEN
sudo lsof -i:22 ## see a specific port such as 22 ##
sudo nmap -sTU -O IP-address-Here

Vagrant

# Show all vagrant VMs
vagrant global-status

# List outdated vagrant images
vagrant box outdated --global

# Update single box
vagrant box update --box ubuntu/trusty64
vagrant box update --box ubuntu/xenial64
vagrant box update --box ubuntu/bionic64

# Prune outdated
vagrant box prune

Misc

  • Install dotfiles: SECRETS_DIR='/Users/vlad/Dropbox/Projects/.secrets' dotfiles/install.sh
  • Release: WRITE_CHANGELOG=true BUG_LABELS='Type: Bug' ENHANCEMENT_LABELS='Type: Enhancement' ../vgs/scripts/release.sh unreleased
  • Kill frozen ssh connection: [Enter] ~ .
  • known_hosts host key has changed ssh-keygen -R <hostname>/<ip> or sed -i 18d .ssh/known_hosts
  • Generate SSH Key ssh-keygen -t rsa -b 4096 -C 'Duplicacy'
  • Add public key to remote: ssh-copy-id user@remote_server
  • Start ssh-agent and load key: eval "$(ssh-agent -s)"; ssh-add - <<<"$(vault kv get -field=key secrets/ansible/rsa)"
  • Certificate info openssl x509 -text -in cert.pem
  • Certificate request info openssl req -text -in req.pem
  • Run local script remotely thorugh ssh: ssh pi@vpi 'bash -s' < ansible/bootstrap.sh
  • UMask directory: sudo chmod g+s /opt/vega && sudo setfacl -R -m default:u::rwx -m default:g::rwx -m u::rwx -m g::rwx -m o::rx /opt/vega
  • Extend partition sudo fdisk -l; sudo growpart /dev/sda 1; sudo resize2fs /dev/sda1
  • Extend LVM partition sudo fdisk -l; sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv; sudo resize2fs /dev/ubuntu-vg/ubuntu-lv
  • Remove Mac generated files: sudo find . \( -name '._*' -o -name '.DS_Store' \) -type f -delete
  • Start Chrome with a temporary profile on Windows PowerShell C:\"Program Files (x86)"\Google\Chrome\Application\chrome.exe --no-default-browser-check --user-data-dir="$(Join-Path $env:TEMP $(New-Guid) | %{ mkdir $_ })" http://www.whatismyip.com/
Clone this wiki locally