]> git.donarmstrong.com Git - bin.git/blob - new_home_directory
add reset usb bus command
[bin.git] / new_home_directory
1 #!/bin/sh
2
3 # wget -O new_home_directory 'http://git.donarmstrong.com/?p=bin.git;a=blob_plain;f=new_home_directory;hb=HEAD'
4 # sh new_home_directory;
5
6
7 # makes a new home directory; defaults to one that does not use ssh
8 GIT_BASE=https://git.donarmstrong.com/
9
10 if [ "$1" = "ssh" ]; then
11     GIT_BASE=git+ssh://git.donarmstrong.com/srv/git/
12 fi;
13
14 cd ~;
15
16 for pkg in mr vcsh; do
17     if ! which $pkg >/dev/null 2>&1; then
18         echo "Package $pkg doesn't exist; getting it"
19         mkdir -p local_packages/$pkg;
20         (cd local_packages/$pkg;
21          deb_name=$pkg
22          if [ $pkg == "mr"; ]; then
23              deb_name=myrepos
24          fi;
25          if which apt-get >/dev/null 2>&1; then
26              apt-get download $deb_name;
27              dpkg-deb -x ${deb_name}*.deb .
28          else
29              # ok, this host isn't Debian.
30              if [ "$pkg" == "mr" ]; then
31                  wget http://http.debian.net/debian/pool/main/m/myrepos/myrepos_1.20160123_all.deb
32                  ar p myrepos*.deb data.tar.xz|xz --decompress|tar -x
33              elif [ "$pkg" == "vcsh" ]; then
34                  wget http://http.debian.net/debian/pool/main/v/vcsh/vcsh_1.20151229-1_all.deb
35                  ar p vcsh*.deb data.tar.xz|xz --decompress|tar -x
36              fi;
37              
38          fi;
39         );
40         mkdir -p bin
41         ln ~/local_packages/$pkg/usr/bin/$pkg bin/$pkg -s
42         if [ "$pkg" == "mr" ]; then
43             echo -e "[DEFAULT]\ninclude = cat ~/local_packages/$pkg/usr/share/mr/*" >> ~/.mrconfig
44         fi;
45         PATH="$HOME/local_packages/$pkg/usr/bin/:$PATH"
46         export PATH
47     fi;
48 done;
49
50 # .config is currently a link; this indicates that we are dealing with my old configuration system
51 for a in .config; do
52     if [ -L ${a} ]; then
53         mv ${a} ${a}_bak;
54         mkdir -p ${a};
55         cp -r ${a}_bak/* ${a}/;
56     fi;
57 done;
58
59 for a in lib bin; do 
60     if [ -d ${a}/.svn ]; then
61         mv ${a} ${a}.bak
62     fi;
63 done;
64
65 if [ "$1" = "ssh" ]; then
66     mkdir -p .config/;
67     (cd .config/;
68         git checkout git+ssh://git.donarmstrong.com/srv/git_private/mr.git
69     );
70     mr --config ~/.config/mr/config.d/base.git checkout
71 else 
72     vcsh clone $GIT_BASE/mr.git mr;
73 fi;
74
75 mr checkout;
76
77 for a in .zsh .ssh; do
78     if [ -L ${a} ]; then
79         mv ${a} ${a}_bak;
80         mr up;
81         mkdir -p ${a};
82         cp -r ${a}_bak/* ${a}/;
83     fi;
84 done;
85
86 if [ ! -e .ssh/authorized_keys ]; then
87     (cd .ssh/; ln authorized_keys_default authorized_keys -s; )
88 fi;
89
90 if [ ! -e ~/bin/.git ]; then
91     # OK, bin must have already existed; check it out directly
92     mv bin bin.tmp;
93     PATH=~/bin.tmp:$PATH mr checkout bin;
94     mv bin.tmp/* bin;
95     rmdir bin.tmp;
96 fi;
97
98 # do some cleanup; you might want to run git reset --hard in some
99 # cases; we don't do so automatically in case there are local changes
100 # that should be kept
101 mr run git reset --soft origin/master
102 mr up
103
104 # move mr and vcsh to ~/bin if they are in ~/bin.bak
105 for pkg in mr vcsh; do
106     if [ -e ~/bin.bak/$pkg ]; then
107         mv ~/bin.bak/$pkg ~/bin/;
108     fi;
109 done;