]> git.donarmstrong.com Git - bin.git/commitdiff
add aws_run_as master
authorDon Armstrong <don@donarmstrong.com>
Wed, 5 Jun 2024 15:18:50 +0000 (08:18 -0700)
committerDon Armstrong <don@donarmstrong.com>
Wed, 5 Jun 2024 15:18:50 +0000 (08:18 -0700)
aws_run_as [new file with mode: 0755]
new_home_directory
reset_usb_bus [new file with mode: 0755]

diff --git a/aws_run_as b/aws_run_as
new file mode 100755 (executable)
index 0000000..01be0cb
--- /dev/null
@@ -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 "$@"
index 3e492a37c7da0ff6bf9a4fc72a2349f38b44a489..51f3f867409d688b17c032e9a69f8984c51ed232 100755 (executable)
@@ -19,7 +19,7 @@ for pkg in mr vcsh; do
         mkdir -p local_packages/$pkg;
         (cd local_packages/$pkg;
          deb_name=$pkg
         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
              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.
              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
                  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;
                  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
         );
         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
         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 (executable)
index 0000000..590e51d
--- /dev/null
@@ -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