From: Don Armstrong Date: Wed, 5 Jun 2024 15:18:50 +0000 (-0700) Subject: add aws_run_as X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=HEAD;hp=79334fd20b0bf56e3c4106900c0dd23445b0fb3f;p=bin.git add aws_run_as --- diff --git a/aws_run_as b/aws_run_as new file mode 100755 index 0000000..01be0cb --- /dev/null +++ b/aws_run_as @@ -0,0 +1,13 @@ +#!/bin/sh + +# Borrowed and modified from https://stackoverflow.com/questions/63241009/aws-sts-assume-role-in-one-command + +ROLE_ARN=$1 + +shift + +export $(printf "AWS_ACCESS_KEY_ID=%s AWS_SECRET_ACCESS_KEY=%s AWS_SESSION_TOKEN=%s" \ + $(aws sts assume-role --role-arn "$ROLE_ARN" --role-session-name "${SESSION_NAME:-aws_run_as}" \ + --query "Credentials.[AccessKeyId,SecretAccessKey,SessionToken]" \ + --output text)) +exec "$@" diff --git a/new_home_directory b/new_home_directory index 3e492a3..51f3f86 100755 --- a/new_home_directory +++ b/new_home_directory @@ -19,7 +19,7 @@ for pkg in mr vcsh; do mkdir -p local_packages/$pkg; (cd local_packages/$pkg; deb_name=$pkg - if [ $pkg == "mr"; ]; then + if [ $pkg = "mr" ]; then deb_name=myrepos fi; if which apt-get >/dev/null 2>&1; then @@ -27,10 +27,10 @@ for pkg in mr vcsh; do dpkg-deb -x ${deb_name}*.deb . else # ok, this host isn't Debian. - if [ "$pkg" == "mr" ]; then + if [ "$pkg" = "mr" ]; then wget http://http.debian.net/debian/pool/main/m/myrepos/myrepos_1.20160123_all.deb ar p myrepos*.deb data.tar.xz|xz --decompress|tar -x - elif [ "$pkg" == "vcsh" ]; then + elif [ "$pkg" = "vcsh" ]; then wget http://http.debian.net/debian/pool/main/v/vcsh/vcsh_1.20151229-1_all.deb ar p vcsh*.deb data.tar.xz|xz --decompress|tar -x fi; @@ -39,8 +39,8 @@ for pkg in mr vcsh; do ); mkdir -p bin ln ~/local_packages/$pkg/usr/bin/$pkg bin/$pkg -s - if [ "$pkg" == "mr" ]; then - echo -e "[DEFAULT]\ninclude = cat ~/local_packages/$pkg/usr/share/mr/*" >> ~/.mrconfig + if [ "$pkg" = "mr" ]; then + printf '[DEFAULT]\ninclude = cat ~/local_packages/%s/usr/share/mr/*' "$pkg" >> ~/.mrconfig fi; PATH="$HOME/local_packages/$pkg/usr/bin/:$PATH" export PATH diff --git a/reset_usb_bus b/reset_usb_bus new file mode 100755 index 0000000..590e51d --- /dev/null +++ b/reset_usb_bus @@ -0,0 +1,7 @@ +#!/bin/bash + +for i in /sys/bus/pci/drivers/[uoex]hci_hcd/*:*; do + [ -e "$i" ] || continue + echo "${i##*/}" > "${i%/*}/unbind" + echo "${i##*/}" > "${i%/*}/bind" +done