summaryrefslogtreecommitdiff
path: root/mrmovein
blob: 658c33d99c4b8741f16c5d59e56969e59af355f9 (plain)
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/sh
#
# move in script - set up a newly created account with sensible configuration
#
# Copyright © 2011 Tobias Klauser <tklauser@distanz.ch>
# Released under the terms of the Artistic Licence 2.0
#
# Based on mrsetup by martin f. krafft which is:
# Copyright © 2008 martin f. krafft <madduck@madduck.net>
#

set -eu

GIT_SERVER=ssh://git.distanz.ch
GIT_REPOS='srv/git/git.distanz.ch'
MR_CODE=$HOME/src/mr
MR_REPO_URL=$GIT_SERVER/$GIT_REPOS/mr.git
MR_DOTFILES_REPO_URL=$GIT_SERVER/$GIT_REPOS/dotfiles/mr.git
DOTFILES=$HOME/src/dotfiles
MR_DOTFILES=src/dotfiles/mr.git

if [ ! -x "$(command -v git)" ]; then
  echo "E: git is not installed." >&2
  exit 2
fi

cd $HOME

if [ -e .mrconfig ]; then
  echo "E: .mrconfig already exists." >&2
  exit 2
fi

if [ -d "$DOTFILES" ]; then
  echo "E: $DOTFILES already exists." >&2
  exit 3
fi

if [ -d .git ]; then
  echo "E: .git already exists." >&2
  exit 4
fi

if [ -d $MR_CODE ]; then
  if [ -x $MR_CODE/mr ]; then
    echo "W: $MR_CODE already exists, let's hope for the best." >&2
  else
    echo "E: $MR_CODE already exists but doesn't provide mr." >&2
    exit 5
  fi
else
  echo "I: cloning mr into $MR_CODE..."
  mkdir -p ${MR_CODE%/*}
  git clone --no-checkout $MR_REPO_URL $MR_CODE
  (cd $MR_CODE && git checkout -b vcsh origin/vcsh)
  echo
fi

cat << EOF > .mrconfig.movein
[DEFAULT]
include = cat $MR_CODE/lib/*

[$MR_DOTFILES]
checkout = git_fake_bare_checkout $MR_DOTFILES_REPO_URL ${MR_DOTFILES##*/} ../../../
EOF

cat << EOF > .mrtrust
.mrconfig.movein
EOF

echo "I: initial .mrconfig:"
cat .mrconfig.movein
echo

echo "I: cloning mr configuration..."
$MR_CODE/mr --config .mrconfig.movein co
echo

echo "I: setting up base..."
$MR_CODE/mr co

echo "I: spawning a shell..."
$SHELL -i -l </dev/tty >/dev/tty

echo "I: back from shell..."

exit 0