summaryrefslogtreecommitdiff
path: root/modules/40-git/install.sh
blob: 61374e94d6837b4e88a537cb66162644373df2c6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
_script="$(realpath ${BASH_SOURCE[0]})"
_scriptname="$(basename $_script)"
_scriptdir="$(dirname $_script)"
_modulename="$(basename $_scriptdir)"
DOT_MODULE_NAME="git"

function preinstall() {
	if ! [[ -x "$(command -v git)" ]]; then
		PACKAGES+=("git")
	fi
}

function install() {
	# backup old file if it exists and we haven't backed it up before
	if [[ -f "$HOME/.gitconfig" ]] && ! [[ -f "$HOME/.gitconfig.bak" ]] && ! [[ -f "$_scriptdir/.firstrun" ]]; then
		log verbose "making backup"
		cp "$HOME/.gitconfig" "$HOME/.gitconfig.bak"
		touch "$_scriptdir/.firstrun"
	fi

	log info "linking gitconfig"
	ln -f "$_scriptdir/gitconfig" "$HOME/.gitconfig"
}