-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·145 lines (128 loc) · 3.41 KB
/
install.sh
File metadata and controls
executable file
·145 lines (128 loc) · 3.41 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/usr/bin/env bash
# bash -c "`curl -fsSL https://raw.githubusercontent.com/RealStr1ke/dotfiles/master/install.sh`"
# Check if git is installed
if ! command -v git &> /dev/null; then
echo "Error: git is required but not installed. Please install git first."
exit 1
fi
# Set variables
DOTFILES_DIR="$HOME/.dotfiles"
REPO_URL="https://github.com/RealStr1ke/dotfiles.git"
# Clone the repository if it doesn't exist
if [ ! -d "$DOTFILES_DIR" ]; then
echo "Cloning dotfiles repository..."
git clone "$REPO_URL" "$DOTFILES_DIR"
else
echo "Dotfiles directory already exists. Pulling latest changes..."
cd "$DOTFILES_DIR" && git pull
fi
# Change to dotfiles directory
cd "$DOTFILES_DIR"
# Detect OS
detect_os() {
case "$OSTYPE" in
linux*) echo "linux" ;;
darwin*) echo "macos" ;;
cygwin) echo "windows" ;;
msys) echo "windows" ;;
win32) echo "windows" ;;
*)
if [[ -f /etc/os-release ]]; then
echo "linux"
else
echo "unknown"
fi
;;
esac
}
# Install dependencies based on OS
install_dependencies() {
local os
os=$(detect_os)
case "$os" in
"linux")
echo "Linux detected. Installing Bun..."
curl -fsSL https://bun.sh/install | bash
# Add bun to PATH for the current script execution
export PATH="$HOME/.bun/bin:$PATH"
;;
"macos")
echo "Error: macOS is not supported. These dotfiles are Linux-only."
exit 1
;;
"windows")
echo "Error: Windows is not supported. These dotfiles are Linux-only."
exit 1
;;
*) # "unknown"
echo "Error: Unknown OS detected. Cannot determine installation method."
echo "Please install Bun manually: curl -fsSL https://bun.sh/install | bash"
echo "Then run the installation again."
exit 1
;;
esac
}
run_installation() {
if ! command -v bun &> /dev/null; then
echo "Error: Bun not detected. Aborting."
exit 1
fi
echo "Installing dependencies..."
cd "$DOTFILES_DIR/core"
bun install
echo "Running installation program..."
# Parse arguments passed to script
local mode="headless"
local extra_args=""
local has_args=false
# Process all arguments passed to the script
for arg in "$@"; do
has_args=true
case $arg in
--interactive|-i)
mode="interactive"
;;
--headless|-h)
mode="headless"
;;
--force|-f)
extra_args="$extra_args --force"
;;
--dry-run|-d)
extra_args="$extra_args --dry-run"
;;
--verbose|-v)
extra_args="$extra_args --verbose"
;;
*)
echo "Unknown option: $arg"
echo "Available options: --interactive, --headless, --force, --dry-run, --verbose"
;;
esac
done
# If no arguments provided, enable force mode for automated/remote installs
# This ensures smooth installation in Gitpod and other automated environments
if [ "$has_args" = false ]; then
extra_args="--force"
echo "No arguments provided - enabling automatic mode (headless + force)"
fi
# Run the TypeScript CLI
echo "Executing: bun run main.ts install --$mode $extra_args"
bun run main.ts install --$mode $extra_args
}
# Ensure Bun is installed
if command -v bun &> /dev/null; then
echo "Bun already installed."
else
echo "Bun not found. Attempting automatic Bun installation..."
install_dependencies
if command -v bun &> /dev/null; then
echo "Bun installation appears successful."
else
echo "Bun still not found after install attempt."
echo "Please install manually: curl -fsSL https://bun.sh/install | bash"
exit 1
fi
fi
# Run installation
run_installation "$@"