From d5205b662cfb6043c670861776078684bbdb3ee5 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Mon, 1 Jan 2018 05:32:20 -0800 Subject: [PATCH] girocco-config.sh: new utility script When Girocco runs it uses a HOME directory set to: $Girocco::Config::chroot/etc/girocco As a result, it finds "global" Git configuration values in $Girocco::Config::chroot/etc/girocco/.gitconfig. To protect against unfriendly foreign VCS mirrors and others leaving a bunch of turds in there, that directory normally lacks write permission for anyone. However, it must have write access in order for the "git config" command to modify the contents of the .gitconfig file it contains. As a result of this, it's a tedious process to manually alter config values stored in that file as first write permission has to be added to the directory, then a longish "--file=..." argument has to be provided to the "git config" command and then write permission once again has to be removed from the directory. Provide a convenient wrapper to eliminate the tedium. The "girocco-config.sh" script semantically acts like an alias for: git config --file="$Girocco::Config::chroot/etc/girocco/.gitconfig" "$@" except that it also adds the needed write permission to the directory beforehand and removes it afterwards. It's now much more convenient to manipulate Girocco's "global" Git config defaults by using this new tool. Signed-off-by: Kyle J. McKay --- toolbox/girocco-config.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 toolbox/girocco-config.sh diff --git a/toolbox/girocco-config.sh b/toolbox/girocco-config.sh new file mode 100755 index 0000000..af5f302 --- /dev/null +++ b/toolbox/girocco-config.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +# Girocco "global" git config convenience tool +# Usage: girocco-config.sh +# The purpose of this tool is simply to provide a convenient wrapper +# for adjusting the config values in the $chroot/etc/girocco/.gitconfig file. +# Directory permissions need to be manipulated before and after and it's +# clumsy to have to provide the longish --file=... argument. +# Hence this script. it's semantically just an alias for running: +# git config --file="$Girocco::Config::chroot/etc/girocco/.gitconfig" "$@" + +set -e + +. @basedir@/shlib.sh + +trap 'chmod a-w "$cfg_chroot/etc/girocco"' EXIT +trap 'exit 129' HUP +trap 'exit 130' INT +trap 'exit 131' QUIT +trap 'exit 134' ABRT +trap 'exit 141' PIPE +trap 'exit 142' ALRM +trap 'exit 143' TERM + +ec= +chmod u+w "$cfg_chroot/etc/girocco" +git config --file="$cfg_chroot/etc/girocco/.gitconfig" "$@" && ec=0 || ec=$? +chmod a-w "$cfg_chroot/etc/girocco" +trap - EXIT +exit ${ec:-1} -- 2.11.4.GIT