annotate scripts/update-git-remotes @ 1236:4291c23e1fba draft

Merge branch 'master' of http://git.volatile.ano/wowaname/resdb
author epoch <epoch@hack.thebackupbox.net>
date Thu, 05 Sep 2019 02:13:25 +0000
parents 2dcb03d77b03
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
389
3531789e64ef Add a very basic script which creates a git remote for each resdb user
Anonymous Coward <nobody@nowhere>
parents:
diff changeset
1 #!/bin/sh
3531789e64ef Add a very basic script which creates a git remote for each resdb user
Anonymous Coward <nobody@nowhere>
parents:
diff changeset
2 #
1200
79ed5d9678a8 something useless
cathugger <cathugger@cock.li>
parents: 1197
diff changeset
3 # Synchronizes git remotes with the user db
389
3531789e64ef Add a very basic script which creates a git remote for each resdb user
Anonymous Coward <nobody@nowhere>
parents:
diff changeset
4 #
3531789e64ef Add a very basic script which creates a git remote for each resdb user
Anonymous Coward <nobody@nowhere>
parents:
diff changeset
5
1204
2dcb03d77b03 scripts/check_db_safety: don't complain so much about missing things
cathugger <cathugger@cock.li>
parents: 1200
diff changeset
6 echo "checking database safety" >&2
1193
2f57d4d36759 add muh nameserver, some script tweaks
cathugger <cathugger@cock.li>
parents: 389
diff changeset
7 if ! `dirname "$0"`/check_db_safety; then
389
3531789e64ef Add a very basic script which creates a git remote for each resdb user
Anonymous Coward <nobody@nowhere>
parents:
diff changeset
8 exit 1
3531789e64ef Add a very basic script which creates a git remote for each resdb user
Anonymous Coward <nobody@nowhere>
parents:
diff changeset
9 fi
3531789e64ef Add a very basic script which creates a git remote for each resdb user
Anonymous Coward <nobody@nowhere>
parents:
diff changeset
10
3531789e64ef Add a very basic script which creates a git remote for each resdb user
Anonymous Coward <nobody@nowhere>
parents:
diff changeset
11 USR_DB_DIR=./db/usr
3531789e64ef Add a very basic script which creates a git remote for each resdb user
Anonymous Coward <nobody@nowhere>
parents:
diff changeset
12 GIT_REPO=./.git
3531789e64ef Add a very basic script which creates a git remote for each resdb user
Anonymous Coward <nobody@nowhere>
parents:
diff changeset
13 GIT_REMOTES_DIR=$GIT_REPO/refs/remotes
3531789e64ef Add a very basic script which creates a git remote for each resdb user
Anonymous Coward <nobody@nowhere>
parents:
diff changeset
14
1197
e083c616cf04 tweak update-git-remotes script
cathugger <cathugger@cock.li>
parents: 1193
diff changeset
15 for u in `ls -1 "$USR_DB_DIR"`; do
389
3531789e64ef Add a very basic script which creates a git remote for each resdb user
Anonymous Coward <nobody@nowhere>
parents:
diff changeset
16 git_url_file="$USR_DB_DIR/$u/git"
3531789e64ef Add a very basic script which creates a git remote for each resdb user
Anonymous Coward <nobody@nowhere>
parents:
diff changeset
17
1197
e083c616cf04 tweak update-git-remotes script
cathugger <cathugger@cock.li>
parents: 1193
diff changeset
18 if [ -f "$git_url_file" ]; then
e083c616cf04 tweak update-git-remotes script
cathugger <cathugger@cock.li>
parents: 1193
diff changeset
19 git_url=`cat "$git_url_file"`
389
3531789e64ef Add a very basic script which creates a git remote for each resdb user
Anonymous Coward <nobody@nowhere>
parents:
diff changeset
20 git_remote_name="anonet_$u"
3531789e64ef Add a very basic script which creates a git remote for each resdb user
Anonymous Coward <nobody@nowhere>
parents:
diff changeset
21
1197
e083c616cf04 tweak update-git-remotes script
cathugger <cathugger@cock.li>
parents: 1193
diff changeset
22 if [ -d "$GIT_REMOTES_DIR/$git_remote_name" ]; then
e083c616cf04 tweak update-git-remotes script
cathugger <cathugger@cock.li>
parents: 1193
diff changeset
23 if [ x"$git_url" != x`git remote get-url "$git_remote_name"` ]; then
e083c616cf04 tweak update-git-remotes script
cathugger <cathugger@cock.li>
parents: 1193
diff changeset
24 echo "changing $u" >&2
e083c616cf04 tweak update-git-remotes script
cathugger <cathugger@cock.li>
parents: 1193
diff changeset
25 git remote set-url "$git_remote_name" "$git_url"
e083c616cf04 tweak update-git-remotes script
cathugger <cathugger@cock.li>
parents: 1193
diff changeset
26 else
e083c616cf04 tweak update-git-remotes script
cathugger <cathugger@cock.li>
parents: 1193
diff changeset
27 # The remote already exists and is the same
e083c616cf04 tweak update-git-remotes script
cathugger <cathugger@cock.li>
parents: 1193
diff changeset
28 echo "skipping $u" >&2
e083c616cf04 tweak update-git-remotes script
cathugger <cathugger@cock.li>
parents: 1193
diff changeset
29 fi
389
3531789e64ef Add a very basic script which creates a git remote for each resdb user
Anonymous Coward <nobody@nowhere>
parents:
diff changeset
30 else
1197
e083c616cf04 tweak update-git-remotes script
cathugger <cathugger@cock.li>
parents: 1193
diff changeset
31 echo "adding $u" >&2
e083c616cf04 tweak update-git-remotes script
cathugger <cathugger@cock.li>
parents: 1193
diff changeset
32 git remote add -t master -m master "$git_remote_name" "$git_url"
389
3531789e64ef Add a very basic script which creates a git remote for each resdb user
Anonymous Coward <nobody@nowhere>
parents:
diff changeset
33 fi
3531789e64ef Add a very basic script which creates a git remote for each resdb user
Anonymous Coward <nobody@nowhere>
parents:
diff changeset
34 fi
3531789e64ef Add a very basic script which creates a git remote for each resdb user
Anonymous Coward <nobody@nowhere>
parents:
diff changeset
35 done
1197
e083c616cf04 tweak update-git-remotes script
cathugger <cathugger@cock.li>
parents: 1193
diff changeset
36
e083c616cf04 tweak update-git-remotes script
cathugger <cathugger@cock.li>
parents: 1193
diff changeset
37 for r in `ls -1 "$GIT_REMOTES_DIR" | grep '^anonet_'`; do
e083c616cf04 tweak update-git-remotes script
cathugger <cathugger@cock.li>
parents: 1193
diff changeset
38 u=`echo $r | sed 's/^anonet_//'`
e083c616cf04 tweak update-git-remotes script
cathugger <cathugger@cock.li>
parents: 1193
diff changeset
39 if [ ! -f "$USR_DB_DIR/$u/git" ]; then
e083c616cf04 tweak update-git-remotes script
cathugger <cathugger@cock.li>
parents: 1193
diff changeset
40 echo "deleting $u" >&2
e083c616cf04 tweak update-git-remotes script
cathugger <cathugger@cock.li>
parents: 1193
diff changeset
41 git remote rm "$r"
e083c616cf04 tweak update-git-remotes script
cathugger <cathugger@cock.li>
parents: 1193
diff changeset
42 rm -rf "$GIT_REMOTES_DIR/$r"
e083c616cf04 tweak update-git-remotes script
cathugger <cathugger@cock.li>
parents: 1193
diff changeset
43 fi
e083c616cf04 tweak update-git-remotes script
cathugger <cathugger@cock.li>
parents: 1193
diff changeset
44 done