eqgo() {
local -a array tmpstr delayon
delayon=true
- if grep -qFx all /etc/exim4/no-delay-eximids; then
+ if grep -qFx all /var/spool/exim4/gw/.no-delay-eximids; then
delayon=false
fi
if $delayon; then
- echo all >/etc/exim4/no-delay-eximids
+ echo all >/var/spool/exim4/gw/.no-delay-eximids
fi
tmpstr=$(exiqgrep -i -r.\*)
mapfile -t array <<<"$tmpstr"
enn -M "${array[@]}"
if $delayon; then
- echo >/etc/exim4/no-delay-eximids
+ echo >/var/spool/exim4/gw/.no-delay-eximids
fi
}
eqgo1() {
local eid
eid="$(exipick -i -r.\*|h1)"
- sed -n "/^all$/p;\$a $eid" /etc/exim4/no-delay-eximids
+ sed -n "/^all$/p;\$a $eid" /var/spool/exim4/gw/.no-delay-eximids
enn -M "$eid"
}
+# exim -M (in namespace and without delay)
ennm() {
local eid
for eid; do
- printf "%s\n" "$eid" >>/etc/exim4/no-delay-eximids
+ printf "%s\n" "$eid" >>/var/spool/exim4/gw/.no-delay-eximids
done
enn -M "$@"
}
for f in $(find . -type f -maxdepth 1); do if head -n1 "$f"| grep -E '^#!/bin/bash\b' &>/dev/null; then { head -n 20 $f | tac | sed '/^# limitations under the License.$/,/^# Copyright.*Ian Kelling$/d' | tac; tail -n+21 $f; } |sponge $f; fi ; done
}
-chrome() {
+chro() {
if type -p chromium &>/dev/null; then
cmd=chromium
else
cd /
- cmd="schroot -c bullseye chromium"
+ cmd="schroot -c bookworm chromium"
CHROMIUM_FLAGS='--enable-remote-extensions' $cmd & r
fi
}
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
)
}
+# sudo maybe
+#
+# passes on any initial -* args to sudo.
+sudm() {
+ local arg
+ local -a sudo_opts
+ for arg; do
+ if [[ $arg == -* ]]; then
+ sudo_opts+=("$arg")
+ shift
+ else
+ break
+ fi
+ done
+ if [[ $EUID == 0 ]]; then
+ "$@"
+ else
+ sudo "${sudo_opts[@]}" "$@"
+ fi
+}
-mns() { # mount namespace
+mns-setup() {
+ local ns
ns=$1
- shift
- s mkdir -p /root/mount_namespaces
- if ! sudo mountpoint /root/mount_namespaces >/dev/null; then
- m sudo mount --bind /root/mount_namespaces /root/mount_namespaces
+ sudm mkdir -p /root/mount_namespaces
+ if ! sudm mountpoint /root/mount_namespaces >/dev/null; then
+ m sudm mount --bind /root/mount_namespaces /root/mount_namespaces
fi
- m sudo mount --make-private /root/mount_namespaces
- if [[ ! -e /root/mount_namespaces/$ns ]]; then
- m sudo touch /root/mount_namespaces/$ns
+ m sudm mount --make-private /root/mount_namespaces
+ if ! sudm test -e /root/mount_namespaces/$ns; then
+ m sudm touch /root/mount_namespaces/$ns
fi
- if ! sudo mountpoint /root/mount_namespaces/$ns >/dev/null; then
- m sudo unshare --propagation slave --mount=/root/mount_namespaces/$ns /bin/true
+ if ! sudm mountpoint /root/mount_namespaces/$ns >/dev/null; then
+ m sudm unshare --propagation slave --mount=/root/mount_namespaces/$ns /bin/true
fi
- m sudo -E /usr/bin/nsenter --mount=/root/mount_namespaces/$ns "$@"
+
+}
+
+mns() { # mount namespace
+ local ns
+ ns=$1
+ shift
+ mns-setup $ns
+ m sudm -E /usr/bin/nsenter --mount=/root/mount_namespaces/$ns "$@"
}
mnsd() { # mount namespace + systemd namespace
+ local ns unit
ns=$1
unit=$2
shift 2
- s mkdir -p /root/mount_namespaces
- if ! sudo mountpoint /root/mount_namespaces >/dev/null; then
- m sudo mount --bind /root/mount_namespaces /root/mount_namespaces
- fi
- m sudo mount --make-private /root/mount_namespaces
- if [[ ! -e /root/mount_namespaces/$ns ]]; then
- m sudo touch /root/mount_namespaces/$ns
- fi
- if ! sudo mountpoint /root/mount_namespaces/$ns >/dev/null; then
- m sudo unshare --propagation slave --mount=/root/mount_namespaces/$ns /bin/true
- fi
+ mns-setup $ns
pid=$(servicepid $unit)
tmpf=$(mktemp --tmpdir $unit.XXXXXXXXXX)
}
eless2() {
- less /var/log/exim4/mymain
+ less /var/log/exim4/nondmain
}
enn() {
local ecmd pid
- ecmd="/usr/sbin/exim4 -C /etc/exim4/my.conf"
+ ecmd="/usr/sbin/exim4 -C /etc/exim4/nn-mainlog.conf"
if ip a show veth1-mail &>/dev/null; then
s $ecmd "$@"
else
}
+# systemd network namespace (not mount) cmd
+# usage: UNIT CMD...
+sdnncmd() {
+ local unit pid tmpf
+ if (( $# <= 1 )); then
+ echo $0: error wrong number of args >&2
+ return 1
+ fi
+ unit=$1
+ shift
+ pid=$(servicepid $unit)
+ tmpf=$(mktemp --tmpdir $unit.XXXXXXXXXX)
+ export -p >$tmpf
+ printf "%s " "${@@Q}" >>$tmpf
+ echo >>$tmpf
+ m sudo nsenter -t $pid -n sudo -u $USER -i bash -c ". $tmpf & rm $tmpf"
+}
+
+
mailnnbash() {
sdnbash mailnn
}
# --no-messages because of annoying errors on broken symlinks
# -z = search .gz etc files
# -. = search dotfiles
- rg() { command rg -. -z --no-messages -L -i -M 900 --no-ignore-parent --no-ignore-vcs -g '!.git' -g '!auto-save-list' -g '!.savehist' "$@" || return $?; }
+ # -n --no-heading: show files and line numbers together allowing for clicking
+ rg() {
+ local path_arg
+ if [[ ${#@} == 1 ]]; then
+ path_arg=.
+ fi
+
+ command rg -. -z --no-messages -Lin --no-heading -M 900 --no-ignore-parent --no-ignore-vcs -g '!.git' -g '!auto-save-list' -g '!.savehist' "$@" $path_arg || return $?
+ }
#fails if not exist. ignore
complete -r rg 2>/dev/null ||:
else
# rg with respecting vcs ignore files
rgv() {
- ret=0
+ local path_arg ret=0
+ if [[ ${#@} == 1 ]]; then
+ path_arg=.
+ fi
# settings that are turned off for pipes, keep them on.
# Found by searching for "terminal" in --help
# --heading
# -z = search zipped files
# -i = case insensitive
# -M = max columns
+ # -n --no-heading: show files and line numbers together allowing for clicking
# --no-messages because of annoying errors on broken symlinks
# --no-ignore-parent because i have /a/.git which ignores almost everything under it.
- command rg -n --heading -. -z --no-messages -i -M 900 --no-ignore-parent -g '!.git' -g '!auto-save-list' -g '!.savehist' "$@" || ret=$?
+ command rg -n --no-heading -. -z --no-messages -i -M 900 --no-ignore-parent -g '!.git' -g '!auto-save-list' -g '!.savehist' "$@" $path_arg || ret=$?
return $ret
}
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
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() {
}
+# 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