dotfiles/make.sh

105 lines
2.8 KiB
Bash
Raw Normal View History

#!/bin/sh
# make.sh
2020-07-04 22:32:01 +02:00
# Copyright 2016 Christian Baer
# https://git.debilux.org/chbaerr/dotfiles
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTI
exclude="README.md|init|Makefile|screenshot.png|.png|.git|.gitignore|.gitmodules|.DS_Store|make.sh"
self=`basename -- "$0"`
2020-07-04 22:22:47 +02:00
basedir=`dirname "$0"`
# Show help screen
# Usage: help exitcode
help () {
echo "Usage: ${self} command {params}"
echo
echo "list List all files that will be copied"
echo "update Update the git repo and the included submodules"
echo "deploy Copy the files to ~"
echo "install Update and deploy these dotfiles"
echo "help Show this screen"
exit $1
}
# Update git repo and submodules
# Usage: df_update
df_update () {
2020-07-04 22:22:47 +02:00
echo "#### Updating git repos and submodules"
git pull origin
git submodule init
git submodule update
git submodule foreach git pull origin
}
# Deploy files to ~
# Usage: df_deploy
df_deploy () {
list_dirs=$(find . -type d | cut -d "/" -f 2- | grep -vE "${exclude}")
list_files=$(find . -type f | cut -d "/" -f 2- | grep -vE "${exclude}")
for dir in ${list_dirs}; do
mkdir -p ${HOME}/${dir}
done
for file in ${list_files}; do
cp -f ${file} ${HOME}/${file}
done
}
# List files that will be copied
# Usage: df_list
df_list () {
find . -print | grep -vE "$exclude"
}
case "$1" in
######################## bootstrap.sh HELP ########################
help)
help 0
;;
######################## bootstrap.sh LIST ########################
list)
2020-07-04 22:22:47 +02:00
# Lists all files in repo, except those specified in $exclude"
df_list
;;
######################## bootstrap.sh DEPLOY ########################
deploy)
df_deploy
2020-05-11 18:17:33 +02:00
;;
######################## bootstrap.sh UPDATE ########################
update)
2020-07-04 22:22:47 +02:00
df_update
2020-05-11 18:17:33 +02:00
;;
######################## bootstrap.sh INSTALL ########################
install)
df_update
df_deploy
2020-05-11 18:17:33 +02:00
;;
*)
help 1
2020-05-11 18:17:33 +02:00
;;
2018-12-28 23:51:01 +01:00
esac