aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/bin
diff options
context:
space:
mode:
authorEgor Tensin <egor@tensin.name>2026-06-06 18:12:33 +0200
committerEgor Tensin <egor@tensin.name>2026-06-06 18:17:34 +0200
commit40b7b047a3fbf6451228de7f69c8ad5f156f7d1c (patch)
tree365df06d7b7cb6122d8a30695aa45a12c4f58302 /bin
parentworkflows/ci: remove on: pull_request (diff)
downloadconfig-links-40b7b047a3fbf6451228de7f69c8ad5f156f7d1c.tar.gz
config-links-40b7b047a3fbf6451228de7f69c8ad5f156f7d1c.zip
reorganize filesv2.1.0
Diffstat (limited to 'bin')
-rwxr-xr-xbin/links-chmod115
-rwxr-xr-xbin/links-remove95
-rwxr-xr-xbin/links-update104
3 files changed, 314 insertions, 0 deletions
diff --git a/bin/links-chmod b/bin/links-chmod
new file mode 100755
index 0000000..931a5b5
--- /dev/null
+++ b/bin/links-chmod
@@ -0,0 +1,115 @@
+#!/usr/bin/env bash
+
+# Copyright (c) 2021 Egor Tensin <egor@tensin.name>
+# 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.
+
+# usage: ./links-chmod [-h|--help] [-d|--database PATH] [-s|--shared-dir DIR] [-n|--dry-run] MODE
+
+set -o errexit -o nounset -o pipefail
+shopt -s inherit_errexit 2> /dev/null || true
+shopt -s lastpipe
+
+script_name="$( basename -- "${BASH_SOURCE[0]}" )"
+readonly script_name
+script_path="$( readlink --canonicalize-existing -- "${BASH_SOURCE[0]}" )"
+readonly script_path
+script_dir="$( dirname -- "$script_path" )"
+readonly script_dir
+lib_dir="$( cd -- "$script_dir/../lib" && pwd )"
+readonly lib_dir
+
+. "$lib_dir/common.sh"
+. "$lib_dir/os.sh"
+. "$lib_dir/path.sh"
+. "$lib_dir/vars.sh"
+. "$lib_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] MODE
+ MODE shared files mode (as in chmod)
+ -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() {
+ local -a args=()
+
+ 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)
+ ;;
+ --)
+ break
+ ;;
+ -*)
+ script_usage "unrecognized parameter: $key" >&2
+ exit 1
+ ;;
+ *)
+ args+=("$key")
+ continue
+ ;;
+ 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
+
+ args+=("$@")
+
+ if [ "${#args[@]}" -ne 1 ]; then
+ script_usage "missing parameter MODE" >&2
+ exit 1
+ fi
+
+ mode="$( parse_mode "${args[0]}" )"
+}
+
+mode=''
+
+main() {
+ parse_script_options "$@"
+ read_database
+ chmod_entries "$mode"
+}
+
+main "$@"
diff --git a/bin/links-remove b/bin/links-remove
new file mode 100755
index 0000000..a149e52
--- /dev/null
+++ b/bin/links-remove
@@ -0,0 +1,95 @@
+#!/usr/bin/env bash
+
+# Copyright (c) 2019 Egor Tensin <egor@tensin.name>
+# 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.
+
+# usage: ./links-remove [-h|--help] [-d|--database PATH] [-s|--shared-dir DIR] [-n|--dry-run]
+
+set -o errexit -o nounset -o pipefail
+shopt -s inherit_errexit 2> /dev/null || true
+shopt -s lastpipe
+
+script_name="$( basename -- "${BASH_SOURCE[0]}" )"
+readonly script_name
+script_path="$( readlink --canonicalize-existing -- "${BASH_SOURCE[0]}" )"
+readonly script_path
+script_dir="$( dirname -- "$script_path" )"
+readonly script_dir
+lib_dir="$( cd -- "$script_dir/../lib" && pwd )"
+readonly lib_dir
+
+. "$lib_dir/common.sh"
+. "$lib_dir/os.sh"
+. "$lib_dir/path.sh"
+. "$lib_dir/vars.sh"
+. "$lib_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/bin/links-update b/bin/links-update
new file mode 100755
index 0000000..dac40ff
--- /dev/null
+++ b/bin/links-update
@@ -0,0 +1,104 @@
+#!/usr/bin/env bash
+
+# Copyright (c) 2016 Egor Tensin <egor@tensin.name>
+# 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.
+
+# usage: ./links-update [-h|--help] [-d|--database PATH] [-s|--shared-dir DIR] [-m|--mode MODE] [-n|--dry-run]
+
+set -o errexit -o nounset -o pipefail
+shopt -s inherit_errexit 2> /dev/null || true
+shopt -s lastpipe
+
+script_name="$( basename -- "${BASH_SOURCE[0]}" )"
+readonly script_name
+script_path="$( readlink --canonicalize-existing -- "${BASH_SOURCE[0]}" )"
+readonly script_path
+script_dir="$( dirname -- "$script_path" )"
+readonly script_dir
+lib_dir="$( cd -- "$script_dir/../lib" && pwd )"
+readonly lib_dir
+
+. "$lib_dir/common.sh"
+. "$lib_dir/os.sh"
+. "$lib_dir/path.sh"
+. "$lib_dir/vars.sh"
+. "$lib_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] [-m|--mode MODE] [-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)
+ -m,--mode shared files mode (as in chmod)
+ -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|-m|--mode)
+ ;;
+ *)
+ 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"
+ ;;
+ -m|--mode)
+ mode="$( parse_mode "$value" )"
+ ;;
+ *)
+ script_usage "unrecognized parameter: $key" >&2
+ exit 1
+ ;;
+ esac
+ done
+}
+
+mode=''
+
+main() {
+ parse_script_options "$@"
+ check_symlinks_enabled
+ read_database
+ unlink_obsolete_entries
+ link_all_entries
+ test -n "$mode" && chmod_entries "$mode"
+ write_database
+}
+
+main "$@"