Mercurial > hg > anonet-resdb
annotate scripts/update-git-remotes @ 1202:306a7562f05e draft
????????: abs <post@abslimit.info>
?? ????? master
???? ????? ????????? ? ???????????? ? ?origin/master?.
?????????, ??????? ????? ???????? ? ??????:
????? ????: db/as/49608/owner
????? ????: db/dom/ano/abslimit/owner
????? ????: db/dom/ano/netstalking/owner
????? ????: db/ip/15/0A/0B/00/cidr
????? ????: db/ip/15/0A/0B/00/owner
????? ????: db/usr/abslimit/git
author | abs <abs@abslimit.info> |
---|---|
date | Sun, 13 May 2018 14:57:04 +0300 |
parents | 79ed5d9678a8 |
children | 2dcb03d77b03 |
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 | 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 |
1193
2f57d4d36759
add muh nameserver, some script tweaks
cathugger <cathugger@cock.li>
parents:
389
diff
changeset
|
6 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
|
7 exit 1 |
3531789e64ef
Add a very basic script which creates a git remote for each resdb user
Anonymous Coward <nobody@nowhere>
parents:
diff
changeset
|
8 fi |
3531789e64ef
Add a very basic script which creates a git remote for each resdb user
Anonymous Coward <nobody@nowhere>
parents:
diff
changeset
|
9 |
3531789e64ef
Add a very basic script which creates a git remote for each resdb user
Anonymous Coward <nobody@nowhere>
parents:
diff
changeset
|
10 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
|
11 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
|
12 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
|
13 |
1197
e083c616cf04
tweak update-git-remotes script
cathugger <cathugger@cock.li>
parents:
1193
diff
changeset
|
14 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
|
15 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
|
16 |
1197
e083c616cf04
tweak update-git-remotes script
cathugger <cathugger@cock.li>
parents:
1193
diff
changeset
|
17 if [ -f "$git_url_file" ]; then |
e083c616cf04
tweak update-git-remotes script
cathugger <cathugger@cock.li>
parents:
1193
diff
changeset
|
18 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
|
19 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
|
20 |
1197
e083c616cf04
tweak update-git-remotes script
cathugger <cathugger@cock.li>
parents:
1193
diff
changeset
|
21 if [ -d "$GIT_REMOTES_DIR/$git_remote_name" ]; then |
e083c616cf04
tweak update-git-remotes script
cathugger <cathugger@cock.li>
parents:
1193
diff
changeset
|
22 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
|
23 echo "changing $u" >&2 |
e083c616cf04
tweak update-git-remotes script
cathugger <cathugger@cock.li>
parents:
1193
diff
changeset
|
24 git remote set-url "$git_remote_name" "$git_url" |
e083c616cf04
tweak update-git-remotes script
cathugger <cathugger@cock.li>
parents:
1193
diff
changeset
|
25 else |
e083c616cf04
tweak update-git-remotes script
cathugger <cathugger@cock.li>
parents:
1193
diff
changeset
|
26 # The remote already exists and is the same |
e083c616cf04
tweak update-git-remotes script
cathugger <cathugger@cock.li>
parents:
1193
diff
changeset
|
27 echo "skipping $u" >&2 |
e083c616cf04
tweak update-git-remotes script
cathugger <cathugger@cock.li>
parents:
1193
diff
changeset
|
28 fi |
389
3531789e64ef
Add a very basic script which creates a git remote for each resdb user
Anonymous Coward <nobody@nowhere>
parents:
diff
changeset
|
29 else |
1197
e083c616cf04
tweak update-git-remotes script
cathugger <cathugger@cock.li>
parents:
1193
diff
changeset
|
30 echo "adding $u" >&2 |
e083c616cf04
tweak update-git-remotes script
cathugger <cathugger@cock.li>
parents:
1193
diff
changeset
|
31 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
|
32 fi |
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 done |
1197
e083c616cf04
tweak update-git-remotes script
cathugger <cathugger@cock.li>
parents:
1193
diff
changeset
|
35 |
e083c616cf04
tweak update-git-remotes script
cathugger <cathugger@cock.li>
parents:
1193
diff
changeset
|
36 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
|
37 u=`echo $r | sed 's/^anonet_//'` |
e083c616cf04
tweak update-git-remotes script
cathugger <cathugger@cock.li>
parents:
1193
diff
changeset
|
38 if [ ! -f "$USR_DB_DIR/$u/git" ]; then |
e083c616cf04
tweak update-git-remotes script
cathugger <cathugger@cock.li>
parents:
1193
diff
changeset
|
39 echo "deleting $u" >&2 |
e083c616cf04
tweak update-git-remotes script
cathugger <cathugger@cock.li>
parents:
1193
diff
changeset
|
40 git remote rm "$r" |
e083c616cf04
tweak update-git-remotes script
cathugger <cathugger@cock.li>
parents:
1193
diff
changeset
|
41 rm -rf "$GIT_REMOTES_DIR/$r" |
e083c616cf04
tweak update-git-remotes script
cathugger <cathugger@cock.li>
parents:
1193
diff
changeset
|
42 fi |
e083c616cf04
tweak update-git-remotes script
cathugger <cathugger@cock.li>
parents:
1193
diff
changeset
|
43 done |