-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstow-all.sh
More file actions
executable file
·45 lines (37 loc) · 1.19 KB
/
stow-all.sh
File metadata and controls
executable file
·45 lines (37 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
set -euo pipefail
# Usage: ./stow-all.sh [host-dir]
# Example: ./stow-all.sh wsl-ubuntu
# If no host-dir is provided, only stow common.
HOST="${1:-}"
REPO_ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
echo "Stowing from $REPO_ROOT"
COMMON_DIR="${REPO_ROOT}/common"
HOST_DIR="${REPO_ROOT}/${HOST}"
if [[ ! -d "$COMMON_DIR" ]]; then
echo "ERROR: missing common dir: $COMMON_DIR" >&2
exit 1
fi
if [[ -n "$HOST" && ! -d "$HOST_DIR" ]]; then
echo "ERROR: host dir not found: $HOST_DIR" >&2
exit 1
fi
cd "$REPO_ROOT" # ensures ./.stowrc is picked up
echo "Stowing common packages:"
if compgen -G "${COMMON_DIR}"'/*/' >/dev/null; then
common_pkgs=$(basename -a "${COMMON_DIR}"/*/)
# shellcheck disable=SC2086
echo $common_pkgs
# shellcheck disable=SC2086
stow --restow --no-folding -d "$COMMON_DIR" $common_pkgs
fi
if [[ -n "$HOST" ]]; then
echo "Stowing host-specific packages:"
if compgen -G "${HOST_DIR}"'/*/' >/dev/null; then
host_pkgs=$(basename -a "${HOST_DIR}"/*/)
# shellcheck disable=SC2086
echo $host_pkgs
# shellcheck disable=SC2086
stow --restow --no-folding -d "$HOST_DIR" $host_pkgs
fi
fi