icecast improvements
[distro-setup] / brc2
diff --git a/brc2 b/brc2
index ff0d7a8c97f38dedbbd3d284df7553cef5fe3b18..104907e67c76f2d4df1f737ff986a3300d9db381 100644 (file)
--- a/brc2
+++ b/brc2
@@ -2882,8 +2882,8 @@ EOF
   tmpf=$(mktemp)
   {
     printf "%s" "Host * "
-    sed -n '/^Host /h;/^IdentityFile .*\/home/{g;s/^Host//;s/ / !/gp}' /p/c/subdir_files/.ssh/config-static | tr '\n' ' '
-    echo
+    sed -n '/^Host /h;/^IdentityFile .*\/home/{g;s/^Host//;s/ / !/gp}' /p/c/subdir_files/.ssh/config-static | tr '\n' ' ' \
+      | sed -r 's/ *$/\n/'
     echo "IdentityFile ~/.ssh/work"
   } >$tmpf
   cedit -e work-identity /p/c/subdir_files/.ssh/config-static <$tmpf
@@ -4750,9 +4750,24 @@ ftoc() {
   units "tempF($1)" tempC
 }
 
-# note: requires dns setup of live.iankelling.org, & if i'm home, port
-# forwarding in wrt-setup-local.  todo: automate that.
-local-icecast() {
+# local icecast
+localic() {
+  local mod=false
+  cedit live /p/c/machine_specific/vps/filesystem/var/lib/bind/db.iankelling.org <<'EOF' || mod=true
+live   CNAME   b8.nz.
+EOF
+  if $mod; then
+    ip=$(ip r show default | sed -r 's/.*src ([^ ]*).*/\1/' | head -n1)
+    if [[ ! $ip ]] && timeout 1 ping -c 1 $ip; then
+      echo "error: failed to get ip: $ip" >&2
+      exit 1
+    fi
+    cat >/p/c/cmc-firewall-data-http <<EOF
+http_ip=$ip
+EOF
+    bindpush
+    wrt-setup
+  fi
   web-conf -e ian@iankelling.org -f 8000 - apache2 live.iankelling.org  <<'EOF'
 <Location "/fsf.webm">
 AuthType Basic
@@ -4769,8 +4784,23 @@ AuthUserFile "/etc/icecast-fsf-tech-htpasswd"
 Require valid-user
 </Location>
 EOF
+  s cat /etc/letsencrypt/live/live.iankelling.org/{fullchain,privkey}.pem | s dd of=/etc/icecast2/fullchainpluskey.pem
+  ser start icecast2
+}
+# li icecast
+liic() {
+  cedit live /p/c/machine_specific/vps/filesystem/var/lib/bind/db.iankelling.org <<'EOF' || bindpush
+live   A       72.14.176.105
+       AAAA    2600:3c00::f03c:91ff:fe6d:baf8
+EOF
+}
+# icecast rm -r
+icrmr() {
+  find /var/icecast -type f -delete
+  ssh li.b8.nz find /var/icecast -type f -delete
 }
 
+
 # obs screen switching of
 obof() {
   ls -l /tmp/no-obs-auto-scene-switch
@@ -4854,19 +4884,55 @@ klease() {
 }
 
 # ffs and switch the bash history on this terminal.
-ffs() {
-  local last
-  last="${*: -1}"
-  if [[ $last && $last != -* && $last != sysops ]]; then
-    his
-  fi
-  command ffs "$@"
-}
+# disabled because I don't really need this and
+# the history switching is annoying for debugging.
+#
+# ffs() {
+#   local last
+#   last="${*: -1}"
+#   if [[ $last && $last != -* && $last != sysops ]]; then
+#     his
+#   fi
+#   command ffs "$@"
+# }
 
 i3gen() {
   /b/ds/i3-sway/gen
 }
 
+
+# insensitive find plus edit
+ife() {
+  local tmps found_count i char file
+  local -a found_files
+  local -A button_file
+  tmps=$(ifn "$@")
+  mapfile -t found_files <<<"$tmps"
+  found_count=${#found_files[@]}
+  if (( ${#found_files[@]} == 1 )); then
+    m g ${found_files[0]}
+  else
+    i=0
+    for button in {a..z}; do
+      button_file[$button]="${found_files[$i]}"
+      echo $button: ${found_files[$i]}
+      i=$(( i + 1 ))
+      if (( i >= found_count )); then
+        break
+      fi
+    done
+    read -rsN1 -t 5 char ||:
+    file="${button_file[$char]}"
+
+    if [[ $file ]]; then
+      g "$file"
+    else
+      echo "no selection"
+    fi
+  fi
+}
+
+
 export BASEFILE_DIR=/a/bin/fai-basefiles
 
 #export ANDROID_HOME=/a/opt/android-home