aboutsummaryrefslogtreecommitdiffstats
path: root/terminaldweller.com/cgit/bootstrap/bootstrap.sh
blob: 8e054edb25f123fc06e97dc72cc8a4a771b8b1cf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/sh
set -e
set -x

GIT_REPO_DIR=/etc/gitrepos
ORIGIN_HTTPS=https://github.com/terminaldweller
ORIGIN_SSH=git@github.com:terminaldweller
REPOS="cgrep \
  mutator \
  delf \
  dwasm \
  colo \
  blog \
  devourer \
  hived \
  mdrtl \
  scripts \
  vagrantboxes \
  dockerimages \
  st \
  dmenu \
  tabbed \
  dwm \
  w3m \
  leetcode \
  irssi-scripts \
  jupyter-notebook-docker-compose \
  seer \
  devi-githooks \
  kaminokumo \
  grpc \
  faultreiber \
  luatablegen \
  magni \
  virttop \
  tunneltop \
  memdump \
  lclip \
  icanhazallips \
  cfe-extra"

bootstrap() {
  for REPO in ${REPOS}; do
    if [ ! -d ${GIT_REPO_DIR}/${REPO}.git ]; then
        (cd "${GIT_REPO_DIR}" && git clone --bare "${ORIGIN_HTTPS}/${REPO}")
    fi
  done
}

update_repos() {
  for REPO in ${REPOS}; do
    (cd "${GIT_REPO_DIR}/${REPO}".git && git fetch origin *:*)
  done
}

on_startup() {
  dir_list=$(ls -A "$1")
  if [ -z "$dir_list" ]; then
    bootstrap
  else
    update_repos
  fi
}

if [ "$1" = "--startup" ]; then
  on_startup "$@"
elif [ "$1" = "--update" ]; then
  update_repos
elif [ "$1" = "--bootstrap" ]; then
  bootstrap
fi