-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move auto-sync/commit stuff here from pim repo
- Loading branch information
Showing
12 changed files
with
472 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
# if ! groups | grep -q systemd-journal; then | ||
# echo >&2 "Need to be in systemd-journal group; aborting!" | ||
# exit 1 | ||
# fi | ||
|
||
jcfuu 'auto-*' -n 1000 | \ | ||
lnavf \ | ||
-f $0.filters \ | ||
"$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# These are (at least mostly) not needed now we have git-annex-clean-sync | ||
|
||
# :filter-out auto-sync-org\[\d+\]: remote: error: refusing to update checked out branch: refs/heads/master | ||
# :filter-out auto-sync-org\[\d+\]: To ssh://aegean-wifi/home/adam/org | ||
# :filter-out auto-sync-org\[\d+\]: ! \[remote rejected\] master -> master \(branch is currently checked out\) | ||
# :filter-out auto-sync-org\[\d+\]: error: failed to push some refs to 'ssh://adam@aegean-wifi/home/adam/org' | ||
|
||
# These are the kinds of errors seen from auto-sync-org when there are | ||
# merge conflicts: | ||
# | ||
# push aegean | ||
# To ssh://aegean-wifi/home/adam/org | ||
# ! [rejected] master -> synced/master (non-fast-forward) | ||
# error: failed to push some refs to 'ssh://adam@aegean-wifi/home/adam/org' | ||
# hint: Updates were rejected because a pushed branch tip is behind its remote | ||
# hint: counterpart. Check out this branch and integrate the remote changes | ||
# hint: (e.g. 'git pull ...') before pushing again. | ||
# hint: See the 'Note about fast-forwards' in 'git push --help' for details. | ||
# To ssh://aegean-wifi/home/adam/org | ||
# ! [rejected] master -> master (non-fast-forward) | ||
# error: failed to push some refs to 'ssh://adam@aegean-wifi/home/adam/org' | ||
# hint: Updates were rejected because the tip of your current branch is behind | ||
# hint: its remote counterpart. Integrate the remote changes (e.g. | ||
# hint: 'git pull ...') before pushing again. | ||
# hint: See the 'Note about fast-forwards' in 'git push --help' for details. | ||
# Pushing to aegean failed. | ||
# (non-fast-forward problems can be solved by setting receive.denyNonFastforwards to false in the remote's git config) | ||
# failed | ||
# push adamspiers.org |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
if [ -z "$1" ]; then | ||
if name=$( mrname 2>/dev/null ); then | ||
set -- "$name" | ||
else | ||
set -- org | ||
fi | ||
fi | ||
|
||
for repo in "$@"; do | ||
systemctl list-unit-files --user | | ||
awk '/^auto-(sync|commit)-'"$repo"'\.service/ {print $1}' | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
austa | ||
|
||
cd ~/org | ||
echo | ||
export GIT_PAGER_MODE=none | ||
ggl1 -n5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
|
||
ausys stop | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
|
||
ausys restart | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
ausys start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
ausys status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
|
||
systemctl list-unit-files --user | | ||
awk '/^auto-(sync|commit)-[^ ]+\.service/ {print $1}' | | ||
xargs systemctl --user --no-pager "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env zsh | ||
|
||
debug= | ||
if [[ "$1" == '-d' ]]; then | ||
debug=-d | ||
shift | ||
fi | ||
|
||
if [ $# != 3 ]; then | ||
cat <<EOF >&2 | ||
Usage: $(basename $0) [-d] REPO-DIR SLEEP MIN-AGE | ||
EOF | ||
exit 1 | ||
fi | ||
|
||
repo_dir="$1" | ||
sleep="$2" | ||
min_age="$3" | ||
|
||
cd "$repo_dir" | ||
|
||
for var in name email; do | ||
if ! git config user.$var >/dev/null; then | ||
echo >&2 "Error: user.$var not set in git config; aborting" | ||
exit 1 | ||
fi | ||
done | ||
|
||
while true; do | ||
git auto-commit $debug -m "$min_age" | ||
sleep "$sleep" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#!/usr/bin/env zsh | ||
|
||
BRANCH=master # FIXME: parameterise at some point | ||
|
||
process_inotify_batch () { | ||
while read dir action file; do | ||
try_sync | ||
|
||
# This should not be unnecessary since we are relying on inotifywait | ||
# to only return a single event; the filtering is done by that | ||
# process, not this loop. | ||
break | ||
done | ||
} | ||
|
||
try_sync () { | ||
if detect_ssh_agent; then | ||
# Do a sync regardless of whether auto-commit did anything, | ||
# because another remote may have pushed changes to our | ||
# synced/master branch. First give other remotes a chance | ||
# to completely finish their push, just in case of any races. | ||
sleep 5 | ||
git-annex-clean-sync | ||
else | ||
echo >&2 "WARNING: can't connect to ssh-agent; skipping annex sync" | ||
fi | ||
} | ||
|
||
main () { | ||
if ! inotifywait --help | grep -q -- '--include'; then | ||
echo >&2 "inotifywait doesn't support --include; aborting!" | ||
exit 1 | ||
fi | ||
|
||
if [ $# != 1 ]; then | ||
cat <<EOF >&2 | ||
Usage: $(basename $me) REPO-DIR | ||
EOF | ||
exit 1 | ||
fi | ||
|
||
repo_dir="$1" | ||
cd "$repo_dir" | ||
|
||
if [[ -e HEAD ]] && [[ -e info ]] && [[ -e objects ]] && [[ -e refs ]] && | ||
[[ -e branches ]] | ||
then | ||
mode=bare | ||
git_dir=. | ||
elif [[ -d .git ]]; then | ||
mode=worktree | ||
git_dir=.git | ||
else | ||
echo >&2 "`pwd` isn't a git repo; aborting!" | ||
exit 1 | ||
fi | ||
|
||
# Do this at startup to allow easy checking at startup time that | ||
# the agent was detected correct. | ||
detect_ssh_agent | ||
|
||
# This was a massive PITA to get right. It seems that if you | ||
# specify specific files then it will look up the inodes on | ||
# start-up and only monitor those. There's some similar weirdness | ||
# with moves too. Suffice to say that it's necessary to use | ||
# --include and watch the whole directory. -r is needed to catch | ||
# the synced/ subdirectory too. For more clues see | ||
# https://unix.stackexchange.com/questions/164794/why-doesnt-inotifywatch-detect-changes-on-added-files | ||
while true; do | ||
inotifywait \ | ||
-q -r \ | ||
--include "/($BRANCH|synced/($BRANCH|git-annex))\$" \ | ||
-e create -e modify -e move -e delete \ | ||
"$git_dir/refs/heads" | | ||
process_inotify_batch | ||
done | ||
} | ||
|
||
me="$0" | ||
main "$@" |
Oops, something went wrong.