Initial commit.
This commit is contained in:
17
etckeeper/commit.d/10vcs-test
Executable file
17
etckeeper/commit.d/10vcs-test
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
not_enabled_warning() {
|
||||
echo "etckeeper warning: etckeeper is not yet enabled for $(pwd)" >&2
|
||||
echo "etckeeper warning: run etckeeper init to enable it" >&2
|
||||
}
|
||||
|
||||
if [ "$VCS" = git ] && [ ! -d .git ]; then
|
||||
not_enabled_warning
|
||||
elif [ "$VCS" = hg ] && [ ! -d .hg ]; then
|
||||
not_enabled_warning
|
||||
elif [ "$VCS" = bzr ] && [ ! -d .bzr ]; then
|
||||
not_enabled_warning
|
||||
elif [ "$VCS" = darcs ] && [ ! -d _darcs ]; then
|
||||
not_enabled_warning
|
||||
fi
|
||||
1
etckeeper/commit.d/20store-metadata
Symbolic link
1
etckeeper/commit.d/20store-metadata
Symbolic link
@@ -0,0 +1 @@
|
||||
../pre-commit.d/30store-metadata
|
||||
8
etckeeper/commit.d/30bzr-add
Executable file
8
etckeeper/commit.d/30bzr-add
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
if [ "$VCS" = bzr ] && [ -d .bzr ]; then
|
||||
if ! bzr add -q .; then
|
||||
echo "etckeeper warning: bzr add failed" >&2
|
||||
fi
|
||||
fi
|
||||
14
etckeeper/commit.d/30darcs-add
Executable file
14
etckeeper/commit.d/30darcs-add
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
if [ "$VCS" = darcs ] && [ -d _darcs ]; then
|
||||
rc=0
|
||||
res=$( darcs add -qr . 2>&1 ) || rc=$?
|
||||
if test $rc -ne 0; then
|
||||
if ! test $rc -eq 2 -a "${res%No files were added}" != "$res"; then
|
||||
printf "%s" "$res"
|
||||
echo "etckeeper warning: darcs add failed" >&2
|
||||
fi
|
||||
fi
|
||||
unset rc res
|
||||
fi
|
||||
8
etckeeper/commit.d/30git-add
Executable file
8
etckeeper/commit.d/30git-add
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
if [ "$VCS" = git ] && [ -d .git ]; then
|
||||
if ! git add --all; then
|
||||
echo "etckeeper warning: git add --all" >&2
|
||||
fi
|
||||
fi
|
||||
8
etckeeper/commit.d/30hg-addremove
Executable file
8
etckeeper/commit.d/30hg-addremove
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
if [ "$VCS" = hg ] && [ -d .hg ]; then
|
||||
if ! hg addremove .; then
|
||||
echo "etckeeper warning: hg addremove failed" >&2
|
||||
fi
|
||||
fi
|
||||
142
etckeeper/commit.d/50vcs-commit
Executable file
142
etckeeper/commit.d/50vcs-commit
Executable file
@@ -0,0 +1,142 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
cleanup () {
|
||||
if [ -n "$logfile" ]; then
|
||||
rm -f "$logfile"
|
||||
fi
|
||||
}
|
||||
if [ -n "$1" ]; then
|
||||
trap cleanup EXIT
|
||||
logfile="$(mktemp -t etckeeper-$VCS.XXXXXXXXXX)"
|
||||
if [ "x$1" = "x--stdin" ]; then
|
||||
cat > "$logfile"
|
||||
else
|
||||
sed '1s/^-m \{0,1\}//' >"$logfile" <<-EOF
|
||||
$*
|
||||
EOF
|
||||
fi
|
||||
else
|
||||
logfile=""
|
||||
fi
|
||||
|
||||
hostname=`hostname 2>/dev/null || cat /etc/hostname`
|
||||
hostname="${hostname%%.*}"
|
||||
dnsdomainname=`dnsdomainname 2>/dev/null || true`
|
||||
if [ -n "$dnsdomainname" ]; then
|
||||
hostname="$hostname.$dnsdomainname"
|
||||
fi
|
||||
|
||||
ORIG_USER=$USER
|
||||
USER=
|
||||
if [ -n "$SUDO_USER" ]; then
|
||||
USER="$SUDO_USER"
|
||||
else
|
||||
# try to check tty ownership, in case user su'd to root
|
||||
TTY="$(tty 2>/dev/null || true)"
|
||||
if [ -n "$TTY" ] && [ -c "$TTY" ]; then
|
||||
USER="$(find "$TTY" -printf "%u")"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$VCS" = git ] && [ -d .git ]; then
|
||||
# When not su'd to root, still set environment variables,
|
||||
# since git's own code to determine the author and committer
|
||||
# has several edge cases where it fails and would prevent the
|
||||
# commit.
|
||||
if [ -z "$USER" ]; then
|
||||
USER="$(whoami)"
|
||||
fi
|
||||
if [ -n "$USER" ]; then
|
||||
# Use user.name and user.email from the gitconfig belonging
|
||||
# to USER.
|
||||
USER_HOME="$(getent passwd "$USER" | cut -d: -f6)"
|
||||
if [ -n "$USER_HOME" ] && [ -e "$USER_HOME/.gitconfig" ]; then
|
||||
if [ -z "$GIT_AUTHOR_NAME" ]; then
|
||||
GIT_AUTHOR_NAME="$(git config -f "$USER_HOME/.gitconfig" user.name)" || true
|
||||
export GIT_AUTHOR_NAME
|
||||
fi
|
||||
if [ -z "$GIT_AUTHOR_EMAIL" ]; then
|
||||
GIT_AUTHOR_EMAIL="$(git config -f "$USER_HOME/.gitconfig" user.email)" || true
|
||||
export GIT_AUTHOR_EMAIL
|
||||
fi
|
||||
fi
|
||||
if [ -z "$GIT_AUTHOR_NAME" ] || [ -z "$GIT_AUTHOR_EMAIL" ]; then
|
||||
if [ -n "$USER_HOME" ] && [ -e "$USER_HOME/.config/git/config" ]; then
|
||||
if [ -z "$GIT_AUTHOR_NAME" ]; then
|
||||
GIT_AUTHOR_NAME="$(git config -f "$USER_HOME/.config/git/config" user.name)" || true
|
||||
export GIT_AUTHOR_NAME
|
||||
fi
|
||||
if [ -z "$GIT_AUTHOR_EMAIL" ]; then
|
||||
GIT_AUTHOR_EMAIL="$(git config -f "$USER_HOME/.config/git/config" user.email)" || true
|
||||
export GIT_AUTHOR_EMAIL
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$GIT_COMMITTER_EMAIL" ]; then
|
||||
GIT_COMMITTER_EMAIL="$(git config --global user.email)" || true
|
||||
export GIT_COMMITTER_EMAIL
|
||||
fi
|
||||
if [ -z "$GIT_AUTHOR_NAME" ]; then
|
||||
GIT_AUTHOR_NAME="$USER"
|
||||
export GIT_AUTHOR_NAME
|
||||
fi
|
||||
if [ -z "$GIT_AUTHOR_EMAIL" ]; then
|
||||
GIT_AUTHOR_EMAIL="$USER@$hostname"
|
||||
export GIT_AUTHOR_EMAIL
|
||||
fi
|
||||
if [ -z "$GIT_COMMITTER_EMAIL" ]; then
|
||||
GIT_COMMITTER_EMAIL=`whoami`"@$hostname"
|
||||
export GIT_COMMITTER_EMAIL
|
||||
fi
|
||||
fi
|
||||
|
||||
# gc ten times more frequently than the default
|
||||
# (unless some other config is set)
|
||||
GIT_GC_OPTIONS=
|
||||
if ! git config gc.auto >/dev/null; then
|
||||
GIT_GC_OPTIONS="-c gc.auto=670"
|
||||
fi
|
||||
|
||||
if [ -n "$logfile" ]; then
|
||||
git $GIT_GC_OPTIONS commit $GIT_COMMIT_OPTIONS -F "$logfile"
|
||||
else
|
||||
git $GIT_GC_OPTIONS commit $GIT_COMMIT_OPTIONS
|
||||
fi
|
||||
elif [ "$VCS" = hg ] && [ -d .hg ]; then
|
||||
if [ -n "$USER" ]; then
|
||||
LOGNAME="$USER"
|
||||
export LOGNAME
|
||||
fi
|
||||
if [ -z "$HGUSER" ]; then
|
||||
HGUSER="$USER@$hostname"
|
||||
export HGUSER
|
||||
fi
|
||||
if [ -n "$logfile" ]; then
|
||||
hg commit $HG_COMMIT_OPTIONS -l "$logfile"
|
||||
else
|
||||
hg commit $HG_COMMIT_OPTIONS
|
||||
fi
|
||||
elif [ "$VCS" = bzr ] && [ -d .bzr ]; then
|
||||
if [ -z "$EMAIL" ] && [ -n "$USER" ]; then
|
||||
EMAIL="$USER <$USER@$hostname>"
|
||||
export EMAIL
|
||||
else
|
||||
bzr whoami >/dev/null 2>&1 || export EMAIL="$ORIG_USER <$ORIG_USER@$hostname>"
|
||||
fi
|
||||
if [ -n "$logfile" ]; then
|
||||
bzr commit $BZR_COMMIT_OPTIONS -F "$logfile"
|
||||
else
|
||||
bzr commit $BZR_COMMIT_OPTIONS
|
||||
fi
|
||||
elif [ "$VCS" = darcs ] && [ -d _darcs ]; then
|
||||
if [ -z "$USER" ]; then
|
||||
USER=root
|
||||
fi
|
||||
if [ -n "$logfile" ]; then
|
||||
darcs record --author="$USER" $DARCS_COMMIT_OPTIONS --logfile="$logfile"
|
||||
else
|
||||
darcs record --author="$USER" $DARCS_COMMIT_OPTIONS
|
||||
fi
|
||||
fi
|
||||
14
etckeeper/commit.d/99push
Executable file
14
etckeeper/commit.d/99push
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
if [ -n "$PUSH_REMOTE" ]; then
|
||||
if [ "$VCS" = git ] && [ -d .git ]; then
|
||||
for REMOTE in $PUSH_REMOTE; do
|
||||
git push "$REMOTE" || true
|
||||
done
|
||||
elif [ "$VCS" = hg ] && [ -d .hg ]; then
|
||||
for REMOTE in $PUSH_REMOTE; do
|
||||
hg push "$REMOTE" || true
|
||||
done
|
||||
else
|
||||
echo "PUSH_REMOTE not yet supported for $VCS" >&2
|
||||
fi
|
||||
fi
|
||||
3
etckeeper/commit.d/README
Normal file
3
etckeeper/commit.d/README
Normal file
@@ -0,0 +1,3 @@
|
||||
Files in this directory are run when there might be changes to commit.
|
||||
(Before and after packages are installed, upgraded, etc.)
|
||||
They should commit changes and new files in /etc to repository.
|
||||
Reference in New Issue
Block a user