-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·141 lines (122 loc) · 3.54 KB
/
install.sh
File metadata and controls
executable file
·141 lines (122 loc) · 3.54 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
#!/usr/bin/env bash
set -euo pipefail
REPO="webcrft/wede"
BINARY="wede"
echo "Installing wede..."
echo ""
# Check dependencies
if ! command -v curl &> /dev/null; then
echo "Error: curl is required but not installed."
echo " Install it with your package manager:"
echo " Ubuntu/Debian: sudo apt install curl"
echo " macOS: brew install curl"
echo " Fedora: sudo dnf install curl"
exit 1
fi
# Detect OS and set install directory
OS="$(uname -s)"
case "$OS" in
Linux*)
OS="linux"
INSTALL_DIR="${HOME}/.local/bin"
;;
Darwin*)
OS="darwin"
INSTALL_DIR="${HOME}/.local/bin"
;;
MINGW*|MSYS*|CYGWIN*)
OS="windows"
INSTALL_DIR="${LOCALAPPDATA:-$HOME/AppData/Local}/wede"
;;
*)
echo "Error: Unsupported operating system: $OS"
exit 1
;;
esac
# Detect architecture
ARCH="$(uname -m)"
case "$ARCH" in
x86_64) ARCH="amd64" ;;
aarch64) ARCH="arm64" ;;
arm64) ARCH="arm64" ;;
*)
echo "Error: Unsupported architecture: $ARCH"
exit 1
;;
esac
echo " OS: $OS"
echo " Arch: $ARCH"
echo ""
# Get latest release tag
LATEST=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name"' | sed -E 's/.*"tag_name": *"([^"]+)".*/\1/')
if [ -z "$LATEST" ]; then
echo "Error: Could not determine the latest release."
exit 1
fi
echo " Version: $LATEST"
# Build download URL
DOWNLOAD_URL="https://github.com/${REPO}/releases/download/${LATEST}/${BINARY}-${OS}-${ARCH}"
echo " Downloading from: $DOWNLOAD_URL"
echo ""
# Download to temp file
TMP_DIR=$(mktemp -d)
TMP_FILE="${TMP_DIR}/${BINARY}"
trap 'rm -rf "$TMP_DIR"' EXIT
curl -fsSL -o "$TMP_FILE" "$DOWNLOAD_URL"
chmod +x "$TMP_FILE"
# Install binary
mkdir -p "$INSTALL_DIR"
mv "$TMP_FILE" "${INSTALL_DIR}/${BINARY}"
echo " Installed to ${INSTALL_DIR}/${BINARY}"
# Check if install dir is in PATH
if ! echo "$PATH" | tr ':' '\n' | grep -q "^${INSTALL_DIR}$"; then
echo ""
echo " Warning: ${INSTALL_DIR} is not in your PATH."
echo " Run this to add it:"
echo ""
case "$OS" in
darwin)
echo " echo 'export PATH=\"\$HOME/.local/bin:\$PATH\"' >> ~/.zshrc && source ~/.zshrc"
;;
linux)
echo " echo 'export PATH=\"\$HOME/.local/bin:\$PATH\"' >> ~/.bashrc && source ~/.bashrc"
;;
windows)
echo " setx PATH \"%PATH%;${INSTALL_DIR}\""
;;
esac
fi
# Create default config
CONFIG_DIR="${HOME}/.config/wede"
CONFIG_FILE="${CONFIG_DIR}/wede.config.json"
mkdir -p "$CONFIG_DIR"
DEFAULT_PASSWORD=$(LC_ALL=C tr -dc 'A-Za-z0-9' < /dev/urandom | head -c 16 || true)
if [ -f "$CONFIG_FILE" ]; then
echo ""
echo " Config already exists at ${CONFIG_FILE}"
echo " Skipping config creation."
else
cat > "$CONFIG_FILE" <<CONF
{
"password": "${DEFAULT_PASSWORD}",
"port": "9090"
}
CONF
echo ""
echo " Config created at: ${CONFIG_FILE}"
echo ""
echo " ┌─────────────────────────────────────────────┐"
echo " │ Admin password: ${DEFAULT_PASSWORD} │"
echo " │ Port: 9090 │"
echo " │ │"
echo " │ To change, edit: ${CONFIG_FILE} │"
echo " └─────────────────────────────────────────────┘"
fi
echo ""
echo " Done! Run 'wede' to start."
echo ""
echo " Quick start:"
echo " cd /path/to/your/project"
echo " wede ."
echo " open http://localhost:9090"
echo ""