#!/bin/sh hostname="$(hostname)" umask 077 while getopts lsmM opt; do case $opt in #c) # work_tree_dir="$HOME" # meta_file="$XDG_CONFIG_HOME/myconf/cfg${opt}_meta" # cmd="git --git-dir=$HOME/.cfg$opt/ --work-tree=$HOME" # ;; l|s) work_tree_dir=/ meta_file="/etc/myconf/cfg${opt}_meta" # ib cfgs use 10.0.0.1 as remote but its wg is in a netns, so need `ip netns exec ns0` # note `sudo -E` seems needed for `gita -s`, but `cfg -s add` and then `cfg -s commit` seems no need `sudo -E` here and only sudo works fine, not sure why, need more test if [ "$opt" = s ] && [ "$hostname" = xyzib ]; then cmd="sudo -E ip netns exec ns0 git --git-dir=/etc/.cfg$opt/ --work-tree=/" else cmd="sudo -E git --git-dir=/etc/.cfg$opt/ --work-tree=/" fi ;; m) sudo gitmetap "$cmd" "$work_tree_dir" "$meta_file" $cmd diff exit ;; M) sudo gitmetar "$meta_file" exit ;; \?) exit 1;; esac done shift $((OPTIND-1)) $cmd "$@"