## include files ###
###################
-for _x in /a/bin/distro-functions/src/* /a/bin/*/*-function?(s); do
+for _x in /a/bin/distro-functions/src/* /a/bin/!(githtml)/*-function?(s); do
source "$_x"
done
unset _x
# so I can share my bashrc
-for x in /a/bin/bash_unpublished/*; do source $x; done
+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-quiet/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.
return 0
}
+feh() {
+ command feh -FzZ "$@"
+}
funce() {
# like -e for functions. returns on error.
git clean -fdx
}
+gitroot() {
+ local help="Usage: gitroot [--help]
+Print the full path to the root of the current git repo
+
+Handles being within a .git directory, unlike git rev-parse --show-toplevel,
+and works in older versions of git which did not have that."
+ if [[ $1 == --help ]]; then
+ echo "$help"
+ return
+ fi
+ local p=$(git rev-parse --git-dir) || { echo "error: not in a git repo" ; return 1; }
+ [[ $p != /* ]] && p=$PWD
+ echo "${p%%/.git}"
+}
+
gr() {
grep -iIP --color=auto "$@"
}
-
-
-
-
grr() {
if [[ ${#@} == 1 ]]; then
grep -riIP --color=auto "$@" .
pwgen() {
- apg -s -m 10 -x 14 -t
+ apg -m 12 -x 16 -t
}
}
-rspicy() { # HOST DOMAIN
+rspicy() { # usage: HOST DOMAIN
+ # connect to spice vm remote host. use vspicy for local host
local port=$(ssh $1<<EOF
sudo virsh dumpxml $2|grep "<graphics.*type='spice'" | \
sed -rn "s/.*port='([0-9]+).*/\1/p"
local x
local -a args
if type -t trash-put >/dev/null; then
- # skip args that don't exist, or else it's an err
- for x in "$@"; do [[ ! -e $x ]] || args+=("$x"); done
+ # skip args that don't exist, or else trash-put will have an error
+ for x in "$@"; do
+ if [[ -e $x || -L $x ]]; then
+ args+=("$x")
+ fi
+ done
[[ ! ${args[@]} ]] || trash-put "${args[@]}"
else
rm -rf "$@"
# 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
+ vpn_on=false
+ if [[ $pid ]]; then
+ if [[ -e /proc/$pid ]]; then
+ vpn_on=true
+ else
+ vpn_on=false
+ s rm -f /run/openvpn/client.pid
+ fi
fi
+ $vpn_on || s ip netns exec vpn /usr/sbin/openvpn --daemon ovpn --config /etc/openvpn/client.conf --cd /etc/openvpn --writepid /run/openvpn/client.pid
gksudo -- ip netns exec vpn gksudo -u ${SUDO_USER:-$USER} "$@"
}
echo "$0: tun_ip=$tun_ip"
[[ $tun_ip ]] || { e "$0: error: no tun0 addr found"; return 1; }
ssh dopub bash <<EOF
+set -e
rule="-A PREROUTING -i eth0 -p tcp -m tcp --dport 63324 -j DNAT --to-destination $tun_ip:63324"
found=false
while read -r line; do
-vspicy() {
+vspicy() { # usage: VIRSH_DOMAIN
# connect to vms made with virt-install
spicy -p $(sudo virsh dumpxml "$1"|grep "<graphics.*type='spice'"|\
sed -r "s/.*port='([0-9]+).*/\1/")
-Misc configs that I use
+Misc configs & ~1k loc in bashrc
Part of how I run GNU/Linux. I try fully automate my systems and store
all configs and scripts, except private info at
-https://iankelling.org/git. Other confguration repos are my bashrc and
-emacs config which are kept in good state and have their own repos at
-https://iankelling.org/git/?p=my-bashrc;a=tree and
-https://iankelling.org/git/?p=my-dot-emacs;a=tree.
+https://iankelling.org/git.
+
+Please email me if you have a patches, bugs, feedback, or republish this
+somewhere else: Ian Kelling <ian@iankelling.org>.