-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·62 lines (48 loc) · 1.68 KB
/
install.sh
File metadata and controls
executable file
·62 lines (48 loc) · 1.68 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
#!/usr/bin/env bash
set -e
RED_BOLD="\033[1;31m"
BLUE="\033[0;34m"
GREEN_BOLD="\033[1;32m"
RESET="\033[0m"
error() {
echo -e "${RED_BOLD}$1${RESET}" >&2
exit 1
}
info() {
echo -e "${BLUE}$1${RESET}"
}
if [[ $EUID -eq 0 ]]; then
error "Don't run this script as root."
fi
local_share_path="$HOME/.local/share/marzeq/dotfiles"
state_dir="$HOME/.local/share/marzeq"
cli_target="$HOME/.local/bin/marzeq-dotfiles"
if ! command -v git &>/dev/null; then
error "git is required to bootstrap dotfiles."
fi
mkdir -p "$(dirname "$local_share_path")" "$state_dir" "$(dirname "$cli_target")"
cwd="$(pwd)"
if [[ -d "$cwd/.git" && ! -d "$local_share_path" ]]; then
origin_url="$(git -C "$cwd" config --get remote.origin.url 2>/dev/null || true)"
if [[ "$origin_url" == *"marzeq/dotfiles"* ]]; then
info "Detected local clone in current directory; linking into $local_share_path"
ln -sfn "$cwd" "$local_share_path"
fi
fi
if [[ -d "$local_share_path/.git" ]]; then
info "Updating existing dotfiles repository..."
git -C "$local_share_path" pull --ff-only || error "Failed to update repository."
else
info "Cloning dotfiles repository to $local_share_path..."
git clone "https://github.com/marzeq/dotfiles.git" "$local_share_path" || error "Git clone failed."
fi
if [[ -f "$local_share_path/marzeq-dotfiles" ]]; then
info "Linking CLI to $cli_target"
chmod +x "$local_share_path/marzeq-dotfiles" || true
ln -sf "$local_share_path/marzeq-dotfiles" "$cli_target"
else
info "Warning: CLI script not found in repository; skipping link."
fi
info "Bootstrap complete. Repo path: $local_share_path"
echo
echo "Run '$cli_target --help' to see available commands for managing the installation."