-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·114 lines (94 loc) · 2.83 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·114 lines (94 loc) · 2.83 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/env bash
set -euo pipefail
REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
log() {
printf '%s\n' "$*"
}
link_path() {
local src="$1"
local dest="$2"
if [[ ! -e "$src" ]]; then
log "skip: source does not exist: $src"
return 0
fi
mkdir -p "$(dirname "$dest")"
if [[ -L "$dest" ]]; then
ln -sfn "$src" "$dest"
log "linked: $dest -> $src"
return 0
fi
if [[ -e "$dest" ]]; then
local backup="${dest}.bak.$(date +%Y%m%d%H%M%S)"
mv "$dest" "$backup"
log "backup: $dest -> $backup"
fi
ln -sfn "$src" "$dest"
log "linked: $dest -> $src"
}
setup_symlinks() {
log "Setting up symlinks..."
mkdir -p "$HOME/.config"
mkdir -p "$HOME/.ssh"
link_path "$REPO_DIR/zshrc" "$HOME/.zshrc"
link_path "$REPO_DIR/vimrc" "$HOME/.vimrc"
link_path "$REPO_DIR/gitconfig" "$HOME/.gitconfig"
link_path "$REPO_DIR/vim" "$HOME/.vim"
link_path "$REPO_DIR/nvim" "$HOME/.config/nvim"
link_path "$REPO_DIR/lazygit" "$HOME/.config/lazygit"
link_path "$REPO_DIR/junie" "$HOME/.junie"
[[ -d "$REPO_DIR/ghostty" ]] && link_path "$REPO_DIR/ghostty" "$HOME/.config/ghostty"
[[ -d "$REPO_DIR/Nextcloud" ]] && link_path "$REPO_DIR/Nextcloud" "$HOME/.config/Nextcloud"
[[ -f "$REPO_DIR/ssh/config" ]] && link_path "$REPO_DIR/ssh/config" "$HOME/.ssh/config"
[[ -f "$REPO_DIR/ssh/known_hosts" ]] && link_path "$REPO_DIR/ssh/known_hosts" "$HOME/.ssh/known_hosts"
chmod 700 "$HOME/.ssh" || true
# Configure git clean/smudge filters (run once per clone)
if [[ -x "$REPO_DIR/setup.git-filters.sh" ]]; then
"$REPO_DIR/setup.git-filters.sh"
fi
}
run_platform_setup() {
case "$(uname -s)" in
Darwin)
[[ -x "$REPO_DIR/setup.macos.sh" ]] || {
log "warn: setup.macos.sh not found or not executable"
return 0
}
"$REPO_DIR/setup.macos.sh"
;;
Linux)
if [[ -f /etc/fedora-release ]]; then
if command -v rpm-ostree >/dev/null 2>&1; then
[[ -x "$REPO_DIR/setup.atomic-fedora.sh" ]] || {
log "warn: setup.atomic-fedora.sh not found or not executable"
return 0
}
"$REPO_DIR/setup.atomic-fedora.sh"
else
[[ -x "$REPO_DIR/setup.fedora.sh" ]] || {
log "warn: setup.fedora.sh not found or not executable"
return 0
}
"$REPO_DIR/setup.fedora.sh"
fi
elif [[ -f /etc/manjaro-release ]]; then
[[ -x "$REPO_DIR/setup.manjaro.sh" ]] || {
log "warn: setup.manjaro.sh not found or not executable"
return 0
}
"$REPO_DIR/setup.manjaro.sh"
else
log "warn: unsupported Linux distribution"
fi
;;
*)
log "warn: unsupported OS: $(uname -s)"
;;
esac
}
main() {
log "Starting base setup..."
setup_symlinks
run_platform_setup
log "Base setup complete."
}
main "$@"