3 autoload colors ; colors
7 print "$fg[cyan]OK.${reset_color}"
9 print -n "$fg[green]$@...${reset_color} "
13 # We can be executed to install ourself to the final destination
14 if [[ $1 == "MAGIC" ]]; then
15 local anon=${2:-"true"}
16 plog "Installing basic dotfile support"
19 mkdir -p ${HOME}/.certs
20 for file in mr vcsh; do
21 cp bin/${file} ${HOME}/bin/${file}
23 cp .certs/ganneff.pem ${HOME}/.certs/ganneff.pem
27 if [[ -d "${HOME}/.config/vcsh/" ]]; then
29 echo "$fg[blue]Looks like there is a vcsh controlled config already."
30 echo "I can get rid of it and all its files before fetching the new one.${reset_color}"
31 echo "$fg[red]This will move ALL files from ANY vcsh controlled repository into '~/.oldhome'!${reset_color}"
32 vared -p "Want to do this it? [N/y] " answer
35 # Replace, get rid of old
36 plog "Moving files from vcsh"
37 mkdir ${HOME}/.oldhome
38 for delfile in $(vcsh list-tracked); do
40 mkdir -p "${HOME}/.oldhome/${dirpart}"
41 mv --target-directory="${HOME}/.oldhome/${dirpart}" ${HOME}/${delfile}
44 mkdir -p "${HOME}/.oldhome/.config/"
45 mv --target-directory="${HOME}/.oldhome" "${HOME}/.config/vcsh/"
46 mv --target-directory="${HOME}/.oldhome" "${HOME}/.config/mr/"
47 mv --target-directory="${HOME}/.oldhome" "${HOME}/.mrconfig"
53 plog "Not deleting old vcsh directories, trying to continue with existing stuff\n"
60 if [[ $answer = "y" ]]; then
61 plog "Fetching mr config "
62 if [[ $anon = "true" ]]; then
63 plog "using the anonymous version\n"
64 GIT_SSL_CAINFO=${HOME}/.certs/ganneff.pem vcsh clone https://kosh.ganneff.de/git/mr.git
65 cd ${HOME}/.config/mr/config.d
66 for file in *.vcsh; do
68 ln -s ../available.d/${file}-anon
72 plog "using the ssh version\n"
73 vcsh clone git@git.ganneff.de:mr.git
77 plog "Pulling all dotfile repositories\n"
79 # The GIT_SSL_CAINFO variable isn't used when using the ssh version.
80 # But it also doesn't hurt, so leave it in, less code than an if clause
81 GIT_SSL_CAINFO=${HOME}/.certs/ganneff.pem mr update
83 if [[ $anon = "true" ]]; then
84 plog "Setup ssl certs for all dotfile repositories\n"
85 mr run git config --local --add http.sslCAInfo ${HOME}/.certs/ganneff.pem
88 plog "Hard resetting dotfiles to ensure all files are there and the VCS versions\n"
89 mr run git reset --hard
92 plog "Now sourcing parts of the new zsh config"
93 # Shut up "helper" function
95 source ${HOME}/.zsh/zshenv.home
96 source ${HOME}/.zsh/00_Basics.zsh
97 source ${HOME}/.zsh/30_Options.zsh
101 plog "Running udh to setup the rest\n"
109 # install my dotfiles in a remote host.
110 # needs makeself locally and git remotely.
119 plog "Building archive..."
121 cp $(which mr) ${work}/bin
122 cp $(which vcsh) ${work}/bin
123 mkdir -p ${work}/.certs
124 cp ~/.TinyCA/Ganneff_CA/cacert.pem ${work}/.certs/ganneff.pem
125 cp ~/.zsh/functions/dist-config ${work}/dist-config
127 plog "Building installer..."
128 makeself --gzip $work ${TMPDIR}/dotfiles-install.sh \
129 "$USER dotfiles" zsh ./dist-config MAGIC ${anon}
132 plog "Remote install..."
133 scp $TMPDIR/dotfiles-install.sh ${remote}:
134 ssh -t $remote sh ./dotfiles-install.sh
138 # Always clean up behind us