Skip to content

Instantly share code, notes, and snippets.

View honzahommer's full-sized avatar
🎯
Focusing

Honza Hommer honzahommer

🎯
Focusing
View GitHub Profile
@honzahommer
honzahommer / autostart.sh
Created May 11, 2020 11:28
XS vApp autostart
#!/bin/bash
# Crontab
# @reboot root /path/to/autostart.sh 60
xe_param() {
awk -v param="$1" '$1 == param' | awk -F': ' '{ print $NF }'
}
if [[ $1 -gt 0 ]]; then
@honzahommer
honzahommer / dirname.min.sh
Last active March 4, 2019 23:40
Get the source directory of a Bash script from within the script itself
#!/usr/bin/env bash
__dirname(){ local d s="$0";while [ -h "$s" ];do d="$(cd -P "$(dirname "$s")">/dev/null 2>&1&&pwd)";s="$(readlink "$s" 2>&1)";[[ $s != /* ]]&&s="$d/$s";done;echo "$(cd -P "$(dirname "$s")">/dev/null 2>&1&&pwd)";}
@honzahommer
honzahommer / repo-get-upstream-url.sh
Last active March 4, 2019 23:04
Get GitHub or GitLab upstream repo URL
#!/usr/bin/env bash
repo_upstream_url() {
local repo_url
local repo_host
local repo_path
local repo_upstream
local repo_api_private_token
local repo_api_url
local repo_api_key
#!/bin/sh
REPO_URL=https://github.com/feathersjs-ecosystem/feathers-sequelize.git
git remote add upstream $REPO_URL
git fetch upstream
git checkout ${BRANCH:-master}
git merge upstream/master
git push
@honzahommer
honzahommer / timeout.sh
Created February 24, 2019 05:55
timeout.sh - run a command with a time limit
#!/bin/sh
duration="${1}"; shift
if [ "$#" -eq 0 ] || [ "$(echo "$duration" | tr -dc '0-9')" != "$duration" ]; then
echo "Usage: $0 DURATION COMMAND [ARG]..."
exit 1
fi
( "$@" &
@honzahommer
honzahommer / opennet_find_site_aps.sh
Created January 30, 2019 14:49
Opennet find site APs
#!/usr/bin/env bash
{ # this ensures the entire script is downloaded #
for i in {0..9}; do
for j in {10..30}; do
icmp=$(ping -o -t1 10.0.$i.$j)
if [ $? = 0 ]; then
echo 10.0.$i.$j
@honzahommer
honzahommer / isversion.sh
Last active January 28, 2019 21:27
isversion.sh
#!/usr/bin/env bash
isversion() {
if [[ $# -lt 2 ]] ; then
local opd='`=`'
local ops='`<` or `>` or `=`'
echo "usage: $0 <versions> <versions> [operator=$opd]"
echo -e "\tversions - Versions to compare"
echo -e "\toperator - Operator to compare, $ops. Default to $opd."
@honzahommer
honzahommer / ismac.sh
Last active January 28, 2019 21:36
ismac.sh
#!/usr/bin/env bash
_ver=$(echo $BASH_VERSION | awk -F. '{ printf "%i%i", $1, $2 }')
ismac() {
if [[ $# -eq 0 ]] ; then
return 1
fi
if [[ $# -gt 1 ]] ; then
@honzahommer
honzahommer / isipv4.sh
Last active January 28, 2019 21:33
isipv4.sh
#!/usr/bin/env bash
isipv4() {
if [[ $# -eq 0 ]] ; then
return 1
fi
if [[ $# -gt 1 ]] ; then
local this="${FUNCNAME[0]}"
@honzahommer
honzahommer / nvm.md
Last active September 20, 2017 05:59
FreeBSD scripts

Install nvm and create hotfix for nvm install command on FreeBSD.

Install packages, require root (wheel) privileges.

echo "y" | pkg install bash git gmake wget

There is an issue with autodetection C++ and C compiler, export paths manunally.

cat &lt;&gt; $HOME/.profile