X-Git-Url: https://git.donarmstrong.com/?p=bin.git;a=blobdiff_plain;f=new_home_directory;h=57e71882b52638caa2bb7d460e459a85330704fa;hp=e6883ef135cfefdce788f44049ca44d3f049f2d5;hb=HEAD;hpb=16c52b8017da58869a9932a0f461ba73020a6c42 diff --git a/new_home_directory b/new_home_directory index e6883ef..3e492a3 100755 --- a/new_home_directory +++ b/new_home_directory @@ -1,27 +1,109 @@ #!/bin/sh +# wget -O new_home_directory 'http://git.donarmstrong.com/?p=bin.git;a=blob_plain;f=new_home_directory;hb=HEAD' +# sh new_home_directory; + + # makes a new home directory; defaults to one that does not use ssh -SVN_BASE=http://svn.donarmstrong.com/don/trunk +GIT_BASE=https://git.donarmstrong.com/ + +if [ "$1" = "ssh" ]; then + GIT_BASE=git+ssh://git.donarmstrong.com/srv/git/ +fi; -# check out bin and lib cd ~; -svn co $SVN_BASE/bin -svn co $SVN_BASE/lib - -# check out the .home modules -mkdir .home_modules; -( - cd .home_modules; - svn co $SVN_BASE/home_modules/base; - for module in $@; do - svn co $SVN_BASE/home_modules/$module; - done; -) -# make a home backup directory -mkdir home_backup; -mv .wgetrc .svn .sversionrc home_backup/; -# run the appropriate command to set the symlinks correctly -sh -c "$(awk -F "$(echo -ne '\t')" '{print $2}' ~/.home_modules/base/sa_base) ~/.home_modules;" -mkdir .sa.d; -ln -s ~/.home_modules/*/sa_* .sa.d/; -exec sa update; \ No newline at end of file + +for pkg in mr vcsh; do + if ! which $pkg >/dev/null 2>&1; then + echo "Package $pkg doesn't exist; getting it" + mkdir -p local_packages/$pkg; + (cd local_packages/$pkg; + deb_name=$pkg + if [ $pkg == "mr"; ]; then + deb_name=myrepos + fi; + if which apt-get >/dev/null 2>&1; then + apt-get download $deb_name; + dpkg-deb -x ${deb_name}*.deb . + else + # ok, this host isn't Debian. + if [ "$pkg" == "mr" ]; then + wget http://http.debian.net/debian/pool/main/m/myrepos/myrepos_1.20160123_all.deb + ar p myrepos*.deb data.tar.xz|xz --decompress|tar -x + elif [ "$pkg" == "vcsh" ]; then + wget http://http.debian.net/debian/pool/main/v/vcsh/vcsh_1.20151229-1_all.deb + ar p vcsh*.deb data.tar.xz|xz --decompress|tar -x + fi; + + fi; + ); + mkdir -p bin + ln ~/local_packages/$pkg/usr/bin/$pkg bin/$pkg -s + if [ "$pkg" == "mr" ]; then + echo -e "[DEFAULT]\ninclude = cat ~/local_packages/$pkg/usr/share/mr/*" >> ~/.mrconfig + fi; + PATH="$HOME/local_packages/$pkg/usr/bin/:$PATH" + export PATH + fi; +done; + +# .config is currently a link; this indicates that we are dealing with my old configuration system +for a in .config; do + if [ -L ${a} ]; then + mv ${a} ${a}_bak; + mkdir -p ${a}; + cp -r ${a}_bak/* ${a}/; + fi; +done; + +for a in lib bin; do + if [ -d ${a}/.svn ]; then + mv ${a} ${a}.bak + fi; +done; + +if [ "$1" = "ssh" ]; then + mkdir -p .config/; + (cd .config/; + git checkout git+ssh://git.donarmstrong.com/srv/git_private/mr.git + ); + mr --config ~/.config/mr/config.d/base.git checkout +else + vcsh clone $GIT_BASE/mr.git mr; +fi; + +mr checkout; + +for a in .zsh .ssh; do + if [ -L ${a} ]; then + mv ${a} ${a}_bak; + mr up; + mkdir -p ${a}; + cp -r ${a}_bak/* ${a}/; + fi; +done; + +if [ ! -e .ssh/authorized_keys ]; then + (cd .ssh/; ln authorized_keys_default authorized_keys -s; ) +fi; + +if [ ! -e ~/bin/.git ]; then + # OK, bin must have already existed; check it out directly + mv bin bin.tmp; + PATH=~/bin.tmp:$PATH mr checkout bin; + mv bin.tmp/* bin; + rmdir bin.tmp; +fi; + +# do some cleanup; you might want to run git reset --hard in some +# cases; we don't do so automatically in case there are local changes +# that should be kept +mr run git reset --soft origin/master +mr up + +# move mr and vcsh to ~/bin if they are in ~/bin.bak +for pkg in mr vcsh; do + if [ -e ~/bin.bak/$pkg ]; then + mv ~/bin.bak/$pkg ~/bin/; + fi; +done;