Skip to content

Instantly share code, notes, and snippets.

Avatar

Eduardo Leggiero leggiero

View GitHub Profile
@leggiero
leggiero / hub-upgrade
Last active May 30, 2020
Install or upgrade hub; ideal to run via cron, e.g. /etc/cron.weekly/hub-upgrade
View hub-upgrade
#!/bin/sh
set -e
arch=amd64
if [ -f /usr/local/bin/hub ]; then
current_version=$(/usr/local/bin/hub --version | grep "hub version" | cut -d' ' -f3)
fi
latest_version=$(curl -s https://api.github.com/repos/github/hub/releases/latest | grep -oP '"tag_name": "v?\K(.*)(?=")')
@leggiero
leggiero / npm-upgrade
Last active Jun 14, 2020
Install or upgrade npm; ideal to run via cron
View npm-upgrade
#!/bin/sh
set -e
if [ "$EUID" = "0" ] && [ ! -f /usr/etc/npmrc ]; then
mkdir -p /usr/etc
echo "prefix = /usr/local" > /usr/etc/npmrc
fi
npm install --global --no-progress --quiet npm >/dev/null
@leggiero
leggiero / composer-upgrade
Last active May 30, 2020
Install or upgrade compose; ideal to run via cron, e.g. /etc/cron.weekly/composer-upgrade
View composer-upgrade
#!/bin/sh
set -e
if [ ! -f /usr/local/bin/composer ]; then
setup_file=$(mktemp /tmp/$(basename "$0").XXXXXX)
trap "{ rm -f $setup_file; }" EXIT
php -r "copy('https://getcomposer.org/installer', '$setup_file');"
eval "php $setup_file --quiet --install-dir=/usr/local/bin --filename=composer"
else
composer --quiet self-update
@leggiero
leggiero / .zshenv
Created Apr 8, 2020
Start ssh-agent on login
View .zshenv
SSH_ENV="$HOME/.ssh/environment"
function start_agent {
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
chmod 600 "${SSH_ENV}"
. "${SSH_ENV}" > /dev/null
/usr/bin/ssh-add 2> /dev/null;
}
if [ -z "$SSH_AUTH_SOCK" ]; then
View sudoers
# Default in Debian
Defaults env_reset
# Addded to share ssh agent between user and root when using sudo
Defaults env_keep+="SSH_AUTH_SOCK"
View ssh_config_proxy_example
Host host
HostName hostname.test
User username
Host subhost
User subhost_username
ProxyCommand ssh -q hostalias nc -q0 subhost 22
Host *
ForwardAgent yes