maybe chmod 0755 'etckeeper/commit.d/50vcs-commit'
maybe chmod 0755 'etckeeper/commit.d/99push'
maybe chmod 0644 'etckeeper/commit.d/README'
+maybe chmod 0755 'etckeeper/daily'
maybe chmod 0644 'etckeeper/etckeeper.conf'
maybe chmod 0755 'etckeeper/init.d'
maybe chmod 0755 'etckeeper/init.d/10restore-metadata'
#!/bin/sh
set -e
-if [ -x /usr/bin/etckeeper ] && [ -e /etc/etckeeper/etckeeper.conf ]; then
+if [ -e /etc/etckeeper/daily ] && [ -e /etc/etckeeper/etckeeper.conf ]; then
. /etc/etckeeper/etckeeper.conf
if [ "$AVOID_DAILY_AUTOCOMMITS" != "1" ]; then
- # avoid autocommit if an install run is in progress
- lockfile=/var/cache/etckeeper/packagelist.pre-install
- if [ -e "$lockfile" ] && [ -n "$(find "$lockfile" -mtime +1)" ]; then
- rm -f "$lockfile" # stale
- fi
- if [ ! -e "$lockfile" ]; then
- AVOID_SPECIAL_FILE_WARNING=1
- export AVOID_SPECIAL_FILE_WARNING
- if etckeeper unclean; then
- etckeeper commit "daily autocommit" >/dev/null
- fi
- fi
+ /etc/etckeeper/daily
fi
fi
--- /dev/null
+../pre-commit.d/30store-metadata
\ No newline at end of file
hostname="$hostname.$dnsdomainname"
fi
+ORIG_USER=$USER
USER=
if [ -n "$SUDO_USER" ]; then
USER="$SUDO_USER"
if [ -n "$USER" ]; then
# Use user.name and user.email from the gitconfig belonging
# to the user who became root.
- USER_HOME="$(perl -e 'print ((getpwnam(shift()))[7])' "$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_EMAIL
fi
fi
- if [ -z "$GIT_COMMITTER_EMAIL" ]; then
- GIT_COMMITER_EMAIL="$(git config --global user.email)" || true
- export GIT_COMMITER_EMAIL
+ 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
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"
--- /dev/null
+#!/bin/sh
+# Script that can be run daily to autocommit /etc changes.
+set -e
+if [ -x /usr/bin/etckeeper ] && [ -e /etc/etckeeper/etckeeper.conf ]; then
+ # avoid autocommit if an install run is in progress
+ lockfile=/var/cache/etckeeper/packagelist.pre-install
+ if [ -e "$lockfile" ] && [ -n "$(find "$lockfile" -mtime +1)" ]; then
+ rm -f "$lockfile" # stale
+ fi
+ if [ ! -e "$lockfile" ]; then
+ AVOID_SPECIAL_FILE_WARNING=1
+ export AVOID_SPECIAL_FILE_WARNING
+ if etckeeper unclean; then
+ etckeeper commit "daily autocommit" >/dev/null
+ fi
+ fi
+fi
# Options passed to darcs record when run by etckeeper.
DARCS_COMMIT_OPTIONS="-a"
-# Uncomment to avoid etckeeper committing existing changes
-# to /etc automatically once per day.
+# Etckeeper includes both a cron job and a systemd timer, which each
+# can commit exiting changes to /etc automatically once per day.
+# To enable the systemd timer, run: systemctl enable etckeeper.timer
+# The cron job is enabled by default; to disable it, uncomment this next line.
#AVOID_DAILY_AUTOCOMMITS=1
# Uncomment the following to avoid special file warning
-# (the option is enabled automatically by cronjob regardless).
+# (the option is enabled automatically for daily autocommits regardless).
#AVOID_SPECIAL_FILE_WARNING=1
# Uncomment to avoid etckeeper committing existing changes to
#AVOID_COMMIT_BEFORE_INSTALL=1
# The high-level package manager that's being used.
-# (apt, pacman-g2, yum, dnf, zypper etc)
+# (apt, pacman, pacman-g2, yum, dnf, zypper, apk etc)
#HIGHLEVEL_PACKAGE_MANAGER=apt
-# Gentoo specific:
+# Gentoo specific:
# For portage this is emerge
# For paludis this is cave
HIGHLEVEL_PACKAGE_MANAGER=emerge
# The low-level package manager that's being used.
-# (dpkg, rpm, pacman, pacman-g2, etc)
+# (dpkg, rpm, pacman, pacmatic, pacman-g2, apk etc)
#LOWLEVEL_PACKAGE_MANAGER=dpkg
# Gentoo specific:
rpm -qa --qf "%|epoch?{%{epoch}}:{0}|:%{name}-%{version}-%{release}.%{arch}\n" | sort
elif [ "$LOWLEVEL_PACKAGE_MANAGER" = pacman ]; then
pacman -Q
+ elif [ "$LOWLEVEL_PACKAGE_MANAGER" = pacmatic ]; then
+ pacmatic -Q
+ elif [ "$LOWLEVEL_PACKAGE_MANAGER" = pkgng ]; then
+ pkg info -E "*"
+ elif [ "$LOWLEVEL_PACKAGE_MANAGER" = apk ]; then
+ apk info -v | sort
elif [ "$LOWLEVEL_PACKAGE_MANAGER" = qlist ]; then
qlist -ICv
elif [ "$LOWLEVEL_PACKAGE_MANAGER" = cave ]; then
set -e
exclude_internal () {
- egrep -v '(^|/)(.git|.hg|.bzr|_darcs)/'
+ egrep -v '(^|/)(\.git|\.hg|\.bzr|_darcs)/'
}
if [ "$VCS" = bzr ] || [ "$VCS" = darcs ]; then
special=$(find . ! -type d ! -type f ! -type l | exclude_internal) || true
hardlinks=$(find . -type f ! -links 1 -exec hg status {} \; | exclude_internal ) || true
elif [ "$VCS" = git ]; then
- special=$(find . ! -type d ! -type f ! -type l -exec git ls-files --exclude-standard --cached --others {} \; | exclude_internal) || true
- hardlinks=$(find . -type f ! -links 1 -exec git ls-files --exclude-standard --cached --others {} \; | exclude_internal) || true
+ special=$(find . ! -type d ! -type f ! -type l -exec git ls-files --exclude-standard --cached --others {} + | exclude_internal) || true
+ hardlinks=$(find . -type f ! -links 1 -exec git ls-files --exclude-standard --cached --others {} + | exclude_internal) || true
else
special=""
fi
#!/bin/sh
set -e
-# Filters out UNKNOWN users and groups, prints a warning on stderr.
-filter_unknown() {
- CMD=$1
- while read line; do
- # if the first n chars of $line equal "$CMD UNKNOWN "...
- if [ "$(printf %.$((9+${#CMD}))s "$line")" = "$CMD UNKNOWN " ]; then
- echo Bad "$2" for "$line" >&2
- else
- echo "$line"
- fi
- done
-}
+# Make sure sort always sorts in same order.
+LANG=C
+export LANG
filter_ignore() {
case "$VCS" in
comment "new and old versions of conffiles, stored by apt/rpm"
ignore "*.rpm*"
nl
- elif [ "$LOWLEVEL_PACKAGE_MANAGER" = "pacman-g2" -o "$LOWLEVEL_PACKAGE_MANAGER" = "pacman" ]; then
+ elif [ "$LOWLEVEL_PACKAGE_MANAGER" = "pacman-g2" -o "$LOWLEVEL_PACKAGE_MANAGER" = "pacman" -o "$LOWLEVEL_PACKAGE_MANAGER" = "pacmatic" ]; then
comment "new and old versions of conffiles, stored by pacman"
ignore "*.pacnew"
ignore "*.pacorig"
ignore "*.pacsave"
nl
+ elif [ "$LOWLEVEL_PACKAGE_MANAGER" = "apk" ]; then
+ comment "new versions of conffiles, stored by apk"
+ ignore "*.apk-new"
+ nl
elif [ "$LOWLEVEL_PACKAGE_MANAGER" = "qlist" -o "$LOWLEVEL_PACKAGE_MANAGER" = "cave" ]; then
comment "new and old versions of conffiles, stored by emerge"
ignore "._cfg*"