/stdhome

To get this branch, use:
bzr branch http://bzr.ed.am/stdhome

« back to all changes in this revision

Viewing changes to tools/reset

  • Committer: Tim Marston
  • Date: 2014-04-18 14:42:00 UTC
  • Revision ID: tim@ed.am-20140418144200-ksbr3l58p2v3jhy2
fixed bugs in command.expand_files, where results could be not unique, nor
sorted, and make sure the last component of the files is not resolved if it is a
symlink

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/bash
2
 
 
3
 
CURRENT=
4
 
if [ -d ~/.stdhome.orig -a ! -d ~/.stdhome.dev ]; then
5
 
        CURRENT=on
6
 
elif [ ! -d ~/.stdhome.orig -a -d ~/.stdhome.dev ]; then
7
 
        CURRENT=off
8
 
fi
9
 
 
10
 
if [ -z "$CURRENT" ]; then
11
 
        echo "Can't determine current state" >&2
12
 
        exit 1
13
 
fi
14
 
 
15
 
if [ "$CURRENT" == "off" ]; then
16
 
        echo "Dev environment is off" >&2
17
 
        exit 1
18
 
fi
19
 
 
20
 
# revno?
21
 
REVNO=
22
 
if [ -n "$1" ]; then
23
 
        if [ $(( 0 + $1 )) -gt 0 ]; then
24
 
                REVNO=$(( 0 + $1 ))
25
 
        fi
26
 
fi
27
 
 
28
 
# check/create reset dir
29
 
if [ ! -d ~/.stdhome.dev.reset/home -a ! -d ~/.stdhome/home ]; then
30
 
        echo "No ~/.stdhome.dev/home and nothing to copy it from"
31
 
        exit 1
32
 
fi
33
 
if [ ! -d ~/.stdhome.dev.reset/home ]; then
34
 
        echo copying dev environment to initial snapshot
35
 
        rm -rf ~/.stdhome.dev.reset
36
 
        cp -a ~/.stdhome ~/.stdhome.dev.reset
37
 
fi
38
 
 
39
 
# update repo
40
 
echo updating repo snapshot
41
 
cd ~/.stdhome.dev.reset/home
42
 
bzr up
43
 
cd
44
 
 
45
 
# reset repos
46
 
echo resetting repo
47
 
rm -rf ~/.stdhome
48
 
cp -a ~/.stdhome{.dev.reset,}
49
 
 
50
 
# revert stage
51
 
if [ -n "$REVNO" ]; then
52
 
        echo applying revno $REVNO
53
 
        /usr/local/bin/stdhome stage-revert
54
 
        cd ~/.stdhome/home
55
 
        bzr up -r $REVNO
56
 
        cd
57
 
fi
58
 
 
59
 
# reset "home" dir
60
 
echo resetting homedir
61
 
rm -rf ~/tmp/stdhome-dev
62
 
cp -a ~/.stdhome/home ~/tmp/stdhome-dev