-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·128 lines (108 loc) · 3.23 KB
/
install.sh
File metadata and controls
executable file
·128 lines (108 loc) · 3.23 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
#!/bin/bash
set -e
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
REPO_OWNER="seanockert"
REPO_NAME="sodeploy"
GITHUB_URL="https://raw.githubusercontent.com/${REPO_OWNER}/${REPO_NAME}/main/so"
INSTALL_DIR="/usr/local/bin"
INSTALL_PATH="${INSTALL_DIR}/so"
# Detect OS
detect_os() {
if [[ "$OSTYPE" == "darwin"* ]]; then
echo "darwin"
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
echo "linux"
elif [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then
echo "windows"
else
echo "unknown"
fi
}
check_permissions() {
[[ "$(detect_os)" == "windows" ]] && return 0
([[ -w "$INSTALL_DIR" ]] || [[ "$EUID" -eq 0 ]]) && return 0
mkdir -p "$INSTALL_DIR" 2>/dev/null && [[ -w "$INSTALL_DIR" ]] && return 0
echo -e "${YELLOW}⚠️ Requires sudo. Run: sudo bash -c \"\$(curl -fsSL https://raw.githubusercontent.com/${REPO_OWNER}/${REPO_NAME}/main/install.sh)\"${NC}"
exit 1
}
check_curl() {
command -v curl >/dev/null 2>&1 || {
echo -e "${RED}❌ curl required${NC}"
exit 1
}
}
install_jq() {
command -v jq >/dev/null 2>&1 && return
local os=$(detect_os)
echo -e "${YELLOW}Installing jq...${NC}"
case "$os" in
darwin)
command -v brew >/dev/null 2>&1 || {
echo -e "${RED}❌ Homebrew required: https://brew.sh${NC}"
exit 1
}
brew install jq
;;
linux)
if command -v apt-get >/dev/null 2>&1; then
apt-get update -qq && apt-get install -y jq
elif command -v yum >/dev/null 2>&1; then
yum install -y jq
elif command -v dnf >/dev/null 2>&1; then
dnf install -y jq
else
echo -e "${RED}❌ Install jq manually: sudo apt install jq${NC}"
exit 1
fi
;;
windows)
curl -fsSL -o /usr/bin/jq.exe https://github.com/stedolan/jq/releases/latest/download/jq-win64.exe
chmod +x /usr/bin/jq.exe
;;
*)
echo -e "${RED}❌ Unsupported OS${NC}"
exit 1
;;
esac
command -v jq >/dev/null 2>&1 || {
echo -e "${RED}❌ jq installation failed${NC}"
exit 1
}
}
install_so() {
echo -e "${YELLOW}Installing so...${NC}"
mkdir -p "$INSTALL_DIR"
curl -fsSL "$GITHUB_URL" -o "$INSTALL_PATH" || {
echo -e "${RED}❌ Download failed${NC}"
exit 1
}
chmod +x "$INSTALL_PATH"
}
main() {
echo "Installing SO Deploy..."
echo
check_curl
check_permissions
install_jq
install_so
echo -e "${GREEN}✅ Installed${NC}"
echo
if ! command -v so >/dev/null 2>&1; then
echo -e "${YELLOW}⚠️ Restart terminal or: export PATH=\"${INSTALL_DIR}:\$PATH\"${NC}"
echo "Then run: so setup"
return
fi
echo "Running setup..."
set +e
so setup
local exit_code=$?
set -e
[[ $exit_code -eq 0 ]] && echo -e "${GREEN}✅ Ready to deploy!${NC}" || echo -e "${YELLOW}⚠️ Run 'so setup' later to configure${NC}"
echo
echo "Usage: so | so -d <name> | so list | so teardown"
}
# Run main function
main