|
@@ -1,13 +1,15 @@
|
|
#!/bin/bash
|
|
#!/bin/bash
|
|
|
|
|
|
-dot_dir=$HOME/.dofiles
|
|
|
|
|
|
+checkout_dir=$HOME/.dofiles
|
|
|
|
+script_dir=$checkout_dir/dotfiles
|
|
|
|
+dots_dir=$checkout_dir/dotfiles/dots
|
|
repo="https://git.capella.pro/capella/dotfiles.git"
|
|
repo="https://git.capella.pro/capella/dotfiles.git"
|
|
|
|
|
|
set -ex
|
|
set -ex
|
|
trap popd EXIT
|
|
trap popd EXIT
|
|
|
|
|
|
-mkdir -pv $dot_dir
|
|
|
|
-pushd $dot_dir
|
|
|
|
|
|
+mkdir -pv $checkout_dir
|
|
|
|
+pushd $checkout_dir
|
|
|
|
|
|
|
|
|
|
sub_help(){
|
|
sub_help(){
|
|
@@ -21,25 +23,31 @@ sub_help(){
|
|
}
|
|
}
|
|
|
|
|
|
sub_sync(){
|
|
sub_sync(){
|
|
- if [[ ! -d $dot_dir/dotfiles/.git ]]; then
|
|
|
|
|
|
+ if [[ ! -d $checkout_dir/dotfiles/.git ]]; then
|
|
git clone $repo
|
|
git clone $repo
|
|
pushd dotfiles
|
|
pushd dotfiles
|
|
git submodule init
|
|
git submodule init
|
|
- git submodule update
|
|
|
|
popd
|
|
popd
|
|
fi
|
|
fi
|
|
- mkdir -p dotfiles/dots
|
|
|
|
- cd dotfiles/dots
|
|
|
|
- git pull
|
|
|
|
|
|
+
|
|
|
|
+ cd $script_dir
|
|
|
|
+ git pull origin master
|
|
|
|
+ git checkout master
|
|
|
|
+ git submodule update
|
|
|
|
+
|
|
if [ ! -z "$1" ]; then
|
|
if [ ! -z "$1" ]; then
|
|
real_path=$(realpath $1)
|
|
real_path=$(realpath $1)
|
|
to_copy=${real_path#*$HOME}
|
|
to_copy=${real_path#*$HOME}
|
|
- cp -R $real_path $(pwd)$to_copy
|
|
|
|
- rm -rf $real_path
|
|
|
|
|
|
+ cp -R $real_path $dots_dir/$to_copy
|
|
|
|
+ mv -rf $real_path
|
|
echo "${to_copy/\//}" >> ../to_sync
|
|
echo "${to_copy/\//}" >> ../to_sync
|
|
fi
|
|
fi
|
|
- cd ..
|
|
|
|
- git add .
|
|
|
|
|
|
+
|
|
|
|
+ while read p; do
|
|
|
|
+ file="$dots_dir/$p"
|
|
|
|
+ git add $file
|
|
|
|
+ done < $script_dir/to_sync
|
|
|
|
+
|
|
if git commit -am "$(date)"; then
|
|
if git commit -am "$(date)"; then
|
|
git remote add origin $repo || true
|
|
git remote add origin $repo || true
|
|
git push -u origin master
|
|
git push -u origin master
|
|
@@ -48,8 +56,8 @@ sub_sync(){
|
|
while read p; do
|
|
while read p; do
|
|
destination="$HOME/$p"
|
|
destination="$HOME/$p"
|
|
rm -rf $destination
|
|
rm -rf $destination
|
|
- ln -s "$dot_dir/dotfiles/dots/$p" $(dirname $destination)
|
|
|
|
- done <to_sync
|
|
|
|
|
|
+ ln -s "$dots_dir/$p" $destination
|
|
|
|
+ done < $script_dir/to_sync
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|