blob: bf05ebc2f717322922e5bee835846fb95789c4fa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#!/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 "$@"
|