-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·82 lines (67 loc) · 2.31 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·82 lines (67 loc) · 2.31 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
#!/usr/bin/env bash
# Shell Dotfiles Installation Bootstrap
# Minimal bash bootstrap that installs git + ruby, then hands off to Ruby orchestrator
set -euo pipefail
# Enable debug mode if TRACE is set
if [[ "${TRACE-0}" == "1" ]]; then
set -x
fi
# Install git if missing
if ! command -v git >/dev/null 2>&1; then
echo "===> Installing git..."
if command -v apt-get >/dev/null 2>&1; then
sudo apt-get update -qq && sudo apt-get install -y git
elif command -v pacman >/dev/null 2>&1; then
sudo pacman -Sy --noconfirm git
elif command -v brew >/dev/null 2>&1; then
brew install git
else
echo "Error: Unable to install git. Please install git manually."
exit 1
fi
fi
# bootstrap
if [[ "${BASH_SOURCE[0]:-}" == "" ]] || [[ "${BASH_SOURCE[0]}" == "bash" ]]; then
echo "===> Detected execution via curl, bootstrapping..."
BOOTSTRAP_CLONE_DIR="${SHELL_INSTALL_DIR:-${HOME}/src/github.com/kalindudc}"
BOOTSTRAP_SHELL_DIR="${BOOTSTRAP_CLONE_DIR}/shell"
echo "===> Repository will be cloned to: ${BOOTSTRAP_SHELL_DIR}"
# Check if directory already exists
if [[ -d "${BOOTSTRAP_SHELL_DIR}" ]]; then
echo "===> Directory already exists, updating..."
cd "${BOOTSTRAP_SHELL_DIR}"
if [[ -d .git ]]; then
git pull --quiet
else
echo "Error: ${BOOTSTRAP_SHELL_DIR} exists but is not a git repository"
exit 1
fi
else
echo "===> Cloning repository..."
mkdir -p "${BOOTSTRAP_CLONE_DIR}"
git clone --depth 1 https://github.com/kalindudc/shell.git "${BOOTSTRAP_SHELL_DIR}"
fi
echo "===> Re-executing from cloned repository..."
cd "${BOOTSTRAP_SHELL_DIR}"
exec bash "${BOOTSTRAP_SHELL_DIR}/install.sh" "$@"
echo "Error: Failed to execute cloned script"
exit 1
fi
# main
SHELL_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Install ruby if missing
if ! command -v ruby >/dev/null 2>&1; then
echo "===> Installing ruby..."
if command -v apt-get >/dev/null 2>&1; then
sudo apt-get update -qq && sudo apt-get install -y ruby
elif command -v pacman >/dev/null 2>&1; then
sudo pacman -Sy --noconfirm ruby
elif command -v brew >/dev/null 2>&1; then
brew install ruby
else
echo "Error: Unable to install ruby. Please install ruby manually."
exit 1
fi
fi
# Execute Ruby orchestrator
exec bundle exec ruby "${SHELL_DIR}/src/install.rb" "$@"