From: Ian Kelling Date: Tue, 9 Aug 2016 23:27:32 +0000 (-0700) Subject: various fixes and improvements X-Git-Url: https://iankelling.org/git/?p=distro-setup;a=commitdiff_plain;h=06acbd75ee97673742cac6b3456e9982d40e74bf various fixes and improvements --- diff --git a/.bashrc b/.bashrc index d2b80bf..f9e2305 100644 --- a/.bashrc +++ b/.bashrc @@ -204,6 +204,7 @@ unset _x for x in /a/bin/bash_unpublished/*; do source $x; done source $(dirname $(readlink -f $BASH_SOURCE))/path_add-function source /a/bin/log-quiet/logq-function +source /a/bin/log-once/log-once-function path_add /a/exe path_add --ifexists --end /a/opt/adt-bundle*/tools /a/opt/adt-bundle*/platform-tools # todo, these need to be renamed to be less generic. @@ -303,7 +304,7 @@ _khfix_common() { local h=${1##*@} ssh-keygen -R $h local x=$(timeout 0.1 ssh -v $1 |& sed -rn "s/debug1: Connecting to $h \[([^\]*)].*/\1/p"); - ssh-keygen -R $x + ssh-keygen -R $x -f $(readlink -f ~/.ssh/known_hosts) } khfix() { # known hosts fix _khfix_common "$@" @@ -385,8 +386,7 @@ chown() { if [[ $1 == -R ]]; then shift command chown -h "$@" - command chown "$@" - command chown -RH "$@" + command chown -R "$@" else command chown "$@" fi @@ -619,7 +619,7 @@ hl() { # history limit. Write extra history to archive file. if (($linecount > $max_lines)); then prune_lines=$(($linecount - $max_lines)) head -n $prune_lines "$HISTFILE" >> "$harchive" \ - && sed -ie "1,${prune_lines}d" $HISTFILE + && sed --follow-symlinks -ie "1,${prune_lines}d" $HISTFILE fi } @@ -745,6 +745,11 @@ mkc() { mkdir() { command mkdir -p "$@"; } +pithos() { + cd /a/opt/Pithosfly/ + python3 -m pithos&r +} + pakaraoke() { # from http://askubuntu.com/questions/456021/remove-vocals-from-mp3-and-get-only-instrumentals pactl load-module module-ladspa-sink sink_name=Karaoke master=alsa_output.usb-Audioengine_Audioengine_D1-00.analog-stereo plugin=karaoke_1409 label=karaoke control=-30 @@ -793,6 +798,10 @@ pub() { rld /a/h/_site/ li:/var/www/iankelling.org/html } +pubip() { curl -4s https://icanhazip.com; } +whatismyip() { pubip; } + + pwgen() { apg -s -m 10 -x 14 -t } @@ -835,6 +844,7 @@ rlu() { # [OPTS] HOST PATH opts=("${@:1:$#-2}") # 1 to last -2 path="${@:$#}" # last host="${@:$#-1:1}" # last -1 + if [[ $path == .* ]]; then echo error: need absolut path; return 1; fi # rync here uses checksum instead of time so we don't mess with # unison relying on time as much. g is for group, same reason # to keep up with unison. @@ -965,6 +975,11 @@ srm () { command srm -ll "$@" } +srun() { + scp $2 $1:/tmp + ssh $1 /tmp/${2##*/} "${@:2}" +} + t() { local x local -a args @@ -1079,6 +1094,45 @@ tx() { # toggle set -x, and the prompt so it doesn't spam fi } +vc() { + [[ $1 ]] || { e "$0: error, expected cmd to run"; return 1; } + # manually run vpn so it stays within a network namespace, + # until I get it all wired up with systemd. + newns vpn start + pid=$(< /run/openvpn/client.pid) + if [[ ! $pid ]]; then + s ip netns exec vpn /usr/sbin/openvpn --daemon ovpn --config /etc/openvpn/client.conf --cd /etc/openvpn --writepid /run/openvpn/client.pid + elif [[ ! -e /proc/$pid ]]; then + echo "$0: ERROR: pidfile pid $pid is not a process!!!" + return 1 + fi + gksudo -- ip netns exec vpn gksudo -u ${SUDO_USER:-$USER} "$@" +} + +transmission() { + vc transmission-gtk& + i=0 + while ((i < 10)); do + tun_ip=$(s ip netns exec vpn ip a show dev tun0 | sed -rn 's/^ *inet (10\.8\.\S+).*/\1/p') + [[ ! $tun_ip ]] || break + sleep 1 + done + echo "$0: tun_ip=$tun_ip" + [[ $tun_ip ]] || { e "$0: error: no tun0 addr found"; return 1; } + ssh dopub bash <