From 6a74133b804524c451c30c64b99f0559c6d47e40 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Thu, 29 Apr 2021 03:52:09 +0300 Subject: rename the scripts For consistency with the distribution packages, mostly. --- .ci/test.sh | 4 +-- README.md | 6 ++-- links-remove | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++ links-update | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ unlink.sh | 95 --------------------------------------------------- update.sh | 109 ----------------------------------------------------------- 6 files changed, 209 insertions(+), 209 deletions(-) create mode 100755 links-remove create mode 100755 links-update delete mode 100755 unlink.sh delete mode 100755 update.sh diff --git a/.ci/test.sh b/.ci/test.sh index fffc883..37167ec 100755 --- a/.ci/test.sh +++ b/.ci/test.sh @@ -58,11 +58,11 @@ call_bin_script() { } call_update() { - call_bin_script "$script_dir/../update.sh" + call_bin_script "$script_dir/../links-update" } call_unlink() { - call_bin_script "$script_dir/../unlink.sh" + call_bin_script "$script_dir/../links-remove" } verify_output() { diff --git a/README.md b/README.md index 4cd138b..0c0aab0 100644 --- a/README.md +++ b/README.md @@ -27,10 +27,10 @@ This description is obviously confusing; see the complete usage example below. Usage ----- -Symlinks are managed by `update.sh`. +Symlinks are managed by `links-update`. ``` -usage: update.sh [-h|--help] [-d|--database PATH] [-s|--shared-dir DIR] [-n|--dry-run] +usage: links-update [-h|--help] [-d|--database PATH] [-s|--shared-dir DIR] [-n|--dry-run] ``` Pass the `--help` flag to this script to examine its detailed usage @@ -62,7 +62,7 @@ In this example, the symlinks to files in "../src" must appear in > echo "$DEST" /test/dest -> ./update.sh --shared-dir ../src/ +> ./links-update --shared-dir ../src/ ... > tree /test/dest/ diff --git a/links-remove b/links-remove new file mode 100755 index 0000000..a44fa3f --- /dev/null +++ b/links-remove @@ -0,0 +1,95 @@ +#!/usr/bin/env bash + +# Copyright (c) 2019 Egor Tensin +# This file is part of the "Configuration file sharing" project. +# For details, see https://github.com/egor-tensin/config-links. +# Distributed under the MIT License. + +# usage: ./unlink.sh [-h|--help] [-d|--database PATH] [-s|--shared-dir DIR] [-n|--dry-run] + +set -o errexit +set -o nounset +set -o pipefail + +script_name="$( basename -- "${BASH_SOURCE[0]}" )" +readonly script_name +script_path="$( realpath --canonicalize-existing -- "${BASH_SOURCE[0]}" )" +readonly script_path +script_dir="$( dirname -- "$script_path" )" +readonly script_dir +src_dir="$( cd -- "$script_dir/src" && pwd )" +readonly src_dir + +. "$src_dir/common.sh" +. "$src_dir/os.sh" +. "$src_dir/path.sh" +. "$src_dir/vars.sh" +. "$src_dir/db.sh" + +script_usage() { + local msg + for msg; do + echo "$script_name: $msg" + done + + echo "usage: $script_name [-h|--help] [-d|--database PATH] [-s|--shared-dir DIR] [-n|--dry-run] + -h,--help show this message and exit + -d,--database set database file path + -s,--shared-dir set top-level shared directory path + (current working directory by default) + -n,--dry-run don't actually do anything intrusive" +} + +parse_script_options() { + while [ "$#" -gt 0 ]; do + local key="$1" + shift + + case "$key" in + -h|--help) + script_usage + exit 0 + ;; + -n|--dry-run) + set_dry_run + continue + ;; + -d|--database|-s|--shared-dir) + ;; + *) + script_usage "unrecognized parameter: $key" >&2 + exit 1 + ;; + esac + + if [ "$#" -eq 0 ]; then + script_usage "missing argument for parameter: $key" >&2 + exit 1 + fi + + local value="$1" + shift + + case "$key" in + -d|--database) + update_database_path "$value" + ;; + -s|--shared-dir) + update_shared_dir "$value" + ;; + *) + script_usage "unrecognized parameter: $key" >&2 + exit 1 + ;; + esac + done +} + +main() { + parse_script_options "$@" + read_database + unlink_all_entries + write_database +} + +main "$@" diff --git a/links-update b/links-update new file mode 100755 index 0000000..faea90d --- /dev/null +++ b/links-update @@ -0,0 +1,109 @@ +#!/usr/bin/env bash + +# Copyright (c) 2016 Egor Tensin +# This file is part of the "Configuration file sharing" project. +# For details, see https://github.com/egor-tensin/config-links. +# Distributed under the MIT License. + +# This script relies on the availability of native symlinks. +# Those are indeed supported by NTFS, but require Administrator privileges for +# creation. +# It likely won't bother you as long as you don't use the functions defined in +# this file. +# In any case, you will see `ln` complaining about some access being denied in +# case something goes wrong. +# +# Remember that in order to force `ln` to use native NTFS symlinks, your +# `CYGWIN` Windows environment variable value **must** include either +# `winsymlinks:native` or `winsymlinks:nativestrict`! + +# usage: ./update.sh [-h|--help] [-d|--database PATH] [-s|--shared-dir DIR] [-n|--dry-run] + +set -o errexit +set -o nounset +set -o pipefail + +script_name="$( basename -- "${BASH_SOURCE[0]}" )" +readonly script_name +script_path="$( realpath --canonicalize-existing -- "${BASH_SOURCE[0]}" )" +readonly script_path +script_dir="$( dirname -- "$script_path" )" +readonly script_dir +src_dir="$( cd -- "$script_dir/src" && pwd )" +readonly src_dir + +. "$src_dir/common.sh" +. "$src_dir/os.sh" +. "$src_dir/path.sh" +. "$src_dir/vars.sh" +. "$src_dir/db.sh" + +script_usage() { + local msg + for msg; do + echo "$script_name: $msg" + done + + echo "usage: $script_name [-h|--help] [-d|--database PATH] [-s|--shared-dir DIR] [-n|--dry-run] + -h,--help show this message and exit + -d,--database set database file path + -s,--shared-dir set top-level shared directory path + (current working directory by default) + -n,--dry-run don't actually do anything intrusive" +} + +parse_script_options() { + while [ "$#" -gt 0 ]; do + local key="$1" + shift + + case "$key" in + -h|--help) + script_usage + exit 0 + ;; + -n|--dry-run) + set_dry_run + continue + ;; + -d|--database|-s|--shared-dir) + ;; + *) + script_usage "unrecognized parameter: $key" >&2 + exit 1 + ;; + esac + + if [ "$#" -eq 0 ]; then + script_usage "missing argument for parameter: $key" >&2 + exit 1 + fi + + local value="$1" + shift + + case "$key" in + -d|--database) + update_database_path "$value" + ;; + -s|--shared-dir) + update_shared_dir "$value" + ;; + *) + script_usage "unrecognized parameter: $key" >&2 + exit 1 + ;; + esac + done +} + +main() { + parse_script_options "$@" + check_symlinks_enabled + read_database + unlink_obsolete_entries + link_all_entries + write_database +} + +main "$@" diff --git a/unlink.sh b/unlink.sh deleted file mode 100755 index a44fa3f..0000000 --- a/unlink.sh +++ /dev/null @@ -1,95 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2019 Egor Tensin -# This file is part of the "Configuration file sharing" project. -# For details, see https://github.com/egor-tensin/config-links. -# Distributed under the MIT License. - -# usage: ./unlink.sh [-h|--help] [-d|--database PATH] [-s|--shared-dir DIR] [-n|--dry-run] - -set -o errexit -set -o nounset -set -o pipefail - -script_name="$( basename -- "${BASH_SOURCE[0]}" )" -readonly script_name -script_path="$( realpath --canonicalize-existing -- "${BASH_SOURCE[0]}" )" -readonly script_path -script_dir="$( dirname -- "$script_path" )" -readonly script_dir -src_dir="$( cd -- "$script_dir/src" && pwd )" -readonly src_dir - -. "$src_dir/common.sh" -. "$src_dir/os.sh" -. "$src_dir/path.sh" -. "$src_dir/vars.sh" -. "$src_dir/db.sh" - -script_usage() { - local msg - for msg; do - echo "$script_name: $msg" - done - - echo "usage: $script_name [-h|--help] [-d|--database PATH] [-s|--shared-dir DIR] [-n|--dry-run] - -h,--help show this message and exit - -d,--database set database file path - -s,--shared-dir set top-level shared directory path - (current working directory by default) - -n,--dry-run don't actually do anything intrusive" -} - -parse_script_options() { - while [ "$#" -gt 0 ]; do - local key="$1" - shift - - case "$key" in - -h|--help) - script_usage - exit 0 - ;; - -n|--dry-run) - set_dry_run - continue - ;; - -d|--database|-s|--shared-dir) - ;; - *) - script_usage "unrecognized parameter: $key" >&2 - exit 1 - ;; - esac - - if [ "$#" -eq 0 ]; then - script_usage "missing argument for parameter: $key" >&2 - exit 1 - fi - - local value="$1" - shift - - case "$key" in - -d|--database) - update_database_path "$value" - ;; - -s|--shared-dir) - update_shared_dir "$value" - ;; - *) - script_usage "unrecognized parameter: $key" >&2 - exit 1 - ;; - esac - done -} - -main() { - parse_script_options "$@" - read_database - unlink_all_entries - write_database -} - -main "$@" diff --git a/update.sh b/update.sh deleted file mode 100755 index faea90d..0000000 --- a/update.sh +++ /dev/null @@ -1,109 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2016 Egor Tensin -# This file is part of the "Configuration file sharing" project. -# For details, see https://github.com/egor-tensin/config-links. -# Distributed under the MIT License. - -# This script relies on the availability of native symlinks. -# Those are indeed supported by NTFS, but require Administrator privileges for -# creation. -# It likely won't bother you as long as you don't use the functions defined in -# this file. -# In any case, you will see `ln` complaining about some access being denied in -# case something goes wrong. -# -# Remember that in order to force `ln` to use native NTFS symlinks, your -# `CYGWIN` Windows environment variable value **must** include either -# `winsymlinks:native` or `winsymlinks:nativestrict`! - -# usage: ./update.sh [-h|--help] [-d|--database PATH] [-s|--shared-dir DIR] [-n|--dry-run] - -set -o errexit -set -o nounset -set -o pipefail - -script_name="$( basename -- "${BASH_SOURCE[0]}" )" -readonly script_name -script_path="$( realpath --canonicalize-existing -- "${BASH_SOURCE[0]}" )" -readonly script_path -script_dir="$( dirname -- "$script_path" )" -readonly script_dir -src_dir="$( cd -- "$script_dir/src" && pwd )" -readonly src_dir - -. "$src_dir/common.sh" -. "$src_dir/os.sh" -. "$src_dir/path.sh" -. "$src_dir/vars.sh" -. "$src_dir/db.sh" - -script_usage() { - local msg - for msg; do - echo "$script_name: $msg" - done - - echo "usage: $script_name [-h|--help] [-d|--database PATH] [-s|--shared-dir DIR] [-n|--dry-run] - -h,--help show this message and exit - -d,--database set database file path - -s,--shared-dir set top-level shared directory path - (current working directory by default) - -n,--dry-run don't actually do anything intrusive" -} - -parse_script_options() { - while [ "$#" -gt 0 ]; do - local key="$1" - shift - - case "$key" in - -h|--help) - script_usage - exit 0 - ;; - -n|--dry-run) - set_dry_run - continue - ;; - -d|--database|-s|--shared-dir) - ;; - *) - script_usage "unrecognized parameter: $key" >&2 - exit 1 - ;; - esac - - if [ "$#" -eq 0 ]; then - script_usage "missing argument for parameter: $key" >&2 - exit 1 - fi - - local value="$1" - shift - - case "$key" in - -d|--database) - update_database_path "$value" - ;; - -s|--shared-dir) - update_shared_dir "$value" - ;; - *) - script_usage "unrecognized parameter: $key" >&2 - exit 1 - ;; - esac - done -} - -main() { - parse_script_options "$@" - check_symlinks_enabled - read_database - unlink_obsolete_entries - link_all_entries - write_database -} - -main "$@" -- cgit v1.2.3 From cef4642ae006edd4fc177dcc03b9ace62115c745 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Thu, 29 Apr 2021 04:02:41 +0300 Subject: README: add more badges --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 0c0aab0..9e87b0f 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ Configuration file sharing ========================== [![Test](https://github.com/egor-tensin/config-links/actions/workflows/test.yml/badge.svg)](https://github.com/egor-tensin/config-links/actions/workflows/test.yml) +[![Packages (Debian)](https://github.com/egor-tensin/config-links/actions/workflows/debian.yml/badge.svg)](https://github.com/egor-tensin/config-links/actions/workflows/debian.yml) +[![Publish (Launchpad)](https://github.com/egor-tensin/config-links/actions/workflows/ppa.yml/badge.svg)](https://github.com/egor-tensin/config-links/actions/workflows/ppa.yml) * Store your files in a repository. * Checkout it on any machine. -- cgit v1.2.3 From 351e33032eaa34e223abb64cec5b5dd51703d8d9 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Thu, 29 Apr 2021 04:06:24 +0300 Subject: README: update --- README.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 9e87b0f..a52fb28 100644 --- a/README.md +++ b/README.md @@ -24,23 +24,24 @@ corresponding symlink is then deleted too). The default database file name is "links.bin", maintained in the top-level directory with shared files. -This description is obviously confusing; see the complete usage example below. +For a complete usage example, see below. Usage ----- -Symlinks are managed by `links-update`. +Symlinks are created & maintained by `links-update`. ``` usage: links-update [-h|--help] [-d|--database PATH] [-s|--shared-dir DIR] [-n|--dry-run] ``` -Pass the `--help` flag to this script to examine its detailed usage -information. +To remove all symlinks, use `links-remove`. -A complete usage example is given below. -In this example, the symlinks to files in "../src" must appear in -"/test/dest". +``` +usage: links-remove [-h|--help] [-d|--database PATH] [-s|--shared-dir DIR] [-n|--dry-run] +``` + +In this example, symlinks to files in "../src" must appear in "/test/dest". ``` > tree /test/dest/ @@ -80,7 +81,7 @@ In this example, the symlinks to files in "../src" must appear in 5 directories, 2 files ``` -For more realistic usage examples, see +For my personal real-life usage examples, see * my [Linux/Cygwin environment], * configuration files for various [Windows apps]. -- cgit v1.2.3 From 985c99e9c1fd65a3447f4c0d91e7eb00f34eb639 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Thu, 29 Apr 2021 11:22:31 +0300 Subject: README: add "Installation" --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index a52fb28..5807115 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,15 @@ directory with shared files. For a complete usage example, see below. +Installation +------------ + +* For Arch Linux, use the [AUR package]. +* For Ubuntu, use the [PPA]. + +[AUR package]: https://aur.archlinux.org/packages/config-links/ +[PPA]: https://launchpad.net/~egor-tensin/+archive/ubuntu/config-links + Usage ----- -- cgit v1.2.3 From d52850255b96ba9bcae4386956bdfab06148fc03 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Thu, 29 Apr 2021 11:23:42 +0300 Subject: rename the project --- README.md | 4 ++-- links-remove | 2 +- links-update | 2 +- src/common.sh | 2 +- src/db.sh | 2 +- src/os.sh | 2 +- src/path.sh | 2 +- src/vars.sh | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 5807115..a2fc4fd 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -Configuration file sharing -========================== +Config file sharing +=================== [![Test](https://github.com/egor-tensin/config-links/actions/workflows/test.yml/badge.svg)](https://github.com/egor-tensin/config-links/actions/workflows/test.yml) [![Packages (Debian)](https://github.com/egor-tensin/config-links/actions/workflows/debian.yml/badge.svg)](https://github.com/egor-tensin/config-links/actions/workflows/debian.yml) diff --git a/links-remove b/links-remove index a44fa3f..271fa02 100755 --- a/links-remove +++ b/links-remove @@ -1,7 +1,7 @@ #!/usr/bin/env bash # Copyright (c) 2019 Egor Tensin -# This file is part of the "Configuration file sharing" project. +# This file is part of the "Config file sharing" project. # For details, see https://github.com/egor-tensin/config-links. # Distributed under the MIT License. diff --git a/links-update b/links-update index faea90d..6c3b633 100755 --- a/links-update +++ b/links-update @@ -1,7 +1,7 @@ #!/usr/bin/env bash # Copyright (c) 2016 Egor Tensin -# This file is part of the "Configuration file sharing" project. +# This file is part of the "Config file sharing" project. # For details, see https://github.com/egor-tensin/config-links. # Distributed under the MIT License. diff --git a/src/common.sh b/src/common.sh index 18df4ce..8048ae1 100644 --- a/src/common.sh +++ b/src/common.sh @@ -1,5 +1,5 @@ # Copyright (c) 2016 Egor Tensin -# This file is part of the "Configuration file sharing" project. +# This file is part of the "Config file sharing" project. # For details, see https://github.com/egor-tensin/config-links. # Distributed under the MIT License. diff --git a/src/db.sh b/src/db.sh index 760441d..6145c6d 100644 --- a/src/db.sh +++ b/src/db.sh @@ -1,5 +1,5 @@ # Copyright (c) 2016 Egor Tensin -# This file is part of the "Configuration file sharing" project. +# This file is part of the "Config file sharing" project. # For details, see https://github.com/egor-tensin/config-links. # Distributed under the MIT License. diff --git a/src/os.sh b/src/os.sh index f9ab7ff..2f1b4bb 100644 --- a/src/os.sh +++ b/src/os.sh @@ -1,5 +1,5 @@ # Copyright (c) 2016 Egor Tensin -# This file is part of the "Configuration file sharing" project. +# This file is part of the "Config file sharing" project. # For details, see https://github.com/egor-tensin/config-links. # Distributed under the MIT License. diff --git a/src/path.sh b/src/path.sh index b1b1e8f..bf52a6f 100644 --- a/src/path.sh +++ b/src/path.sh @@ -1,5 +1,5 @@ # Copyright (c) 2016 Egor Tensin -# This file is part of the "Configuration file sharing" project. +# This file is part of the "Config file sharing" project. # For details, see https://github.com/egor-tensin/config-links. # Distributed under the MIT License. diff --git a/src/vars.sh b/src/vars.sh index f989b0a..af73c1d 100644 --- a/src/vars.sh +++ b/src/vars.sh @@ -1,5 +1,5 @@ # Copyright (c) 2016 Egor Tensin -# This file is part of the "Configuration file sharing" project. +# This file is part of the "Config file sharing" project. # For details, see https://github.com/egor-tensin/config-links. # Distributed under the MIT License. -- cgit v1.2.3