From 6a01765147f9845a59f9ee15ac870fcccdd29839 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Tue, 25 Jul 2023 22:25:59 +0200 Subject: update.sh -> setup.sh --- README.md | 9 +++++---- setup.sh | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ update.sh | 58 ---------------------------------------------------------- 3 files changed, 63 insertions(+), 62 deletions(-) create mode 100755 setup.sh delete mode 100755 update.sh diff --git a/README.md b/README.md index c629fa8..03d5233 100644 --- a/README.md +++ b/README.md @@ -3,15 +3,16 @@ linux-home My dotfiles. -The files are maintained in this repository and shared across different -machines using [config-links]. +The files are maintained in this repository and deployed on different machines +using [config-links]. [config-links]: https://github.com/egor-tensin/config-links Deployment ---------- -Go to the top directory and execute `links-update` (from [config-links]). +Go to the top directory and execute `./setup.sh`. +This uses [config-links] internally. Issues ------ @@ -20,7 +21,7 @@ Some utilities (notably, GHC) may not work if its configuration files are group-writable. To fix this, run `chmod g-w` for every file & directory in this repository (you can do this by running `links-chmod go-w`; this call is included in the -update.sh script). +setup.sh script). License ------- diff --git a/setup.sh b/setup.sh new file mode 100755 index 0000000..b3bbe05 --- /dev/null +++ b/setup.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +set -o errexit -o nounset -o pipefail +shopt -s inherit_errexit 2> /dev/null || true +shopt -s lastpipe + +script_dir="$( dirname -- "${BASH_SOURCE[0]}" )" +script_dir="$( cd -- "$script_dir" && pwd )" +readonly script_dir + +repo_dir='' + +cleanup_repo() { + if [ -n "$repo_dir" ]; then + echo "Cleaning up directory: $repo_dir" + rm -rf -- "$repo_dir" + fi +} + +config_links_in_path() { + # Make sure the links-* utils are available. + + if command -v links-update &> /dev/null; then + return 0 + fi + + # This is a common directory to clone config-links for me. + if [ -d "$script_dir/../config-links" ]; then + export PATH="$script_dir/../config-links:$PATH" + return 0 + fi + + # If config-links is unavailable, clone it. + readonly repo_url=https://github.com/egor-tensin/config-links.git + trap cleanup_repo EXIT + repo_dir="$( mktemp -d )" + + git clone -q -- "$repo_url" "$repo_dir" + export PATH="$repo_dir:$PATH" +} + +links_update() { + cd -- "$script_dir" + links-update + + # Some utilities (for example, ssh) fix too relaxed file permissions + # automatically. Others (GHCi is the reason this exists) just spit out a + # warning and ignore such files. This script simply removes the write + # permission for everybody except myself for every file in this repository. + links-chmod go-w +} + +main() { + config_links_in_path + links_update +} + +main diff --git a/update.sh b/update.sh deleted file mode 100755 index b3bbe05..0000000 --- a/update.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -o nounset -o pipefail -shopt -s inherit_errexit 2> /dev/null || true -shopt -s lastpipe - -script_dir="$( dirname -- "${BASH_SOURCE[0]}" )" -script_dir="$( cd -- "$script_dir" && pwd )" -readonly script_dir - -repo_dir='' - -cleanup_repo() { - if [ -n "$repo_dir" ]; then - echo "Cleaning up directory: $repo_dir" - rm -rf -- "$repo_dir" - fi -} - -config_links_in_path() { - # Make sure the links-* utils are available. - - if command -v links-update &> /dev/null; then - return 0 - fi - - # This is a common directory to clone config-links for me. - if [ -d "$script_dir/../config-links" ]; then - export PATH="$script_dir/../config-links:$PATH" - return 0 - fi - - # If config-links is unavailable, clone it. - readonly repo_url=https://github.com/egor-tensin/config-links.git - trap cleanup_repo EXIT - repo_dir="$( mktemp -d )" - - git clone -q -- "$repo_url" "$repo_dir" - export PATH="$repo_dir:$PATH" -} - -links_update() { - cd -- "$script_dir" - links-update - - # Some utilities (for example, ssh) fix too relaxed file permissions - # automatically. Others (GHCi is the reason this exists) just spit out a - # warning and ignore such files. This script simply removes the write - # permission for everybody except myself for every file in this repository. - links-chmod go-w -} - -main() { - config_links_in_path - links_update -} - -main -- cgit v1.2.3