Skip to content

Commit c1a5fed

Browse files
install.s
1 parent c5fe30a commit c1a5fed

2 files changed

Lines changed: 321 additions & 61 deletions

File tree

install.sh

Lines changed: 27 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,20 @@ detect_platform() {
3232
}
3333

3434
# --- Globals ---
35-
SHELLS_USER="shells"
36-
SHELLS_BINARY_NAME="shells"
37-
SHELLS_SRC_DIR="$(cd "$(dirname "$0")" && pwd)"
38-
SHELLS_BUILD_PATH="$SHELLS_SRC_DIR/$SHELLS_BINARY_NAME"
39-
INSTALL_PATH="/usr/local/bin/$SHELLS_BINARY_NAME"
35+
Shells_USER="shells"
36+
Shells_BINARY_NAME="shells"
37+
Shells_SRC_DIR="$(cd "$(dirname "$0")" && pwd)"
38+
Shells_BUILD_PATH="$Shells_SRC_DIR/$Shells_BINARY_NAME"
39+
INSTALL_PATH="/usr/local/bin/$Shells_BINARY_NAME"
4040

4141
# Go installation settings
42-
GO_VERSION="1.23.4"
42+
GO_VERSION="1.24.0"
4343
GO_INSTALL_DIR="/usr/local"
4444

4545
# --- Directories ---
4646
# These are the *default* system-wide paths.
47-
# If Shell CLI supports user-specific configs, the Go application
48-
# should handle XDG Base Directory specification (e.g., ~/.config/shell)
47+
# If Shells CLI supports user-specific configs, the Go application
48+
# should handle XDG Base Directory specification (e.g., ~/.config/shells)
4949
# when run as a non-root user.
5050
if $IS_MAC; then
5151
SECRETS_DIR="$HOME/Library/Application Support/shells/secrets"
@@ -89,12 +89,12 @@ install_go() {
8989
current_version=$(go version | awk '{print $3}' | sed 's/go//')
9090
log INFO " Detected Go version: $current_version"
9191

92-
# Force installation if version is less than 1.23
93-
if [[ "$current_version" < "1.23" ]]; then
92+
# Simple version comparison - check if current version is at least the required version
93+
if printf '%s\n%s\n' "$GO_VERSION" "$current_version" | sort -V | head -n1 | grep -q "^$GO_VERSION$"; then
94+
log INFO " Go is already up-to-date (version $current_version >= $GO_VERSION)"
95+
else
9496
log INFO " Go version is older (wanted: $GO_VERSION, found: $current_version)"
9597
need_go_install=true
96-
else
97-
log INFO " Go is already up-to-date (version $current_version >= 1.23)"
9898
fi
9999
fi
100100

@@ -157,8 +157,7 @@ EOF
157157

158158
# Verify Go installation
159159
if command -v go >/dev/null 2>&1; then
160-
local installed_version=$(go version | awk '{print $3}' | sed 's/go//')
161-
log INFO " Go installation verified: version $installed_version at $(command -v go)"
160+
log INFO "Go version: $(go version)"
162161
else
163162
log ERR " Go installation verification failed"
164163
exit 1
@@ -185,9 +184,9 @@ install_github_cli() {
185184
dnf install -y dnf-plugins-core
186185

187186
# Remove any stale local repo
188-
if [ -f "/etc/yum.repos.d/opt_shell.repo" ]; then
189-
log INFO "Removing stale local repo: /etc/yum.repos.d/opt_shell.repo"
190-
rm -f /etc/yum.repos.d/opt_shell.repo
187+
if [ -f "/etc/yum.repos.d/opt_shells.repo" ]; then
188+
log INFO "Removing stale local repo: /etc/yum.repos.d/opt_shells.repo"
189+
rm -f /etc/yum.repos.d/opt_shells.repo
191190
fi
192191

193192
# Add GitHub CLI repo if not already added
@@ -254,12 +253,7 @@ check_prerequisites() {
254253
install_github_cli
255254

256255
# Verify Go is now available
257-
if command -v go >/dev/null 2>&1; then
258-
log INFO " Go detected and ready. Version: $(go version | awk '{print $3}')"
259-
else
260-
log ERR " Go verification failed after installation"
261-
exit 1
262-
fi
256+
log INFO "Go detected and ready. Version details: $(go version)"
263257

264258
if $IS_LINUX; then
265259
for cmd in useradd usermod visudo stat; do
@@ -270,10 +264,10 @@ check_prerequisites() {
270264

271265
build_shells_binary() {
272266
log INFO " Building Shells..."
273-
cd "$SHELLS_SRC_DIR"
274-
rm -rf "$SHELLS_BINARY_NAME"
267+
cd "$Shells_SRC_DIR"
268+
rm -rf "$Shells_BINARY_NAME"
275269
# Use the 'go' command which should now be in PATH due to check_prerequisites
276-
go build -o "$SHELLS_BINARY_NAME" .
270+
go build -o "$Shells_BINARY_NAME" .
277271
}
278272

279273
show_existing_checksum() {
@@ -291,7 +285,7 @@ install_binary() {
291285
if $IS_MAC; then
292286
# On macOS, sudo is typically implied for /usr/local/bin
293287
sudo rm -rf "$INSTALL_PATH" || log ERR "Failed to remove existing binary at $INSTALL_PATH. Permissions issue?"
294-
sudo cp "$SHELLS_BUILD_PATH" "$INSTALL_PATH" || log ERR "Failed to copy binary to $INSTALL_PATH. Permissions issue?"
288+
sudo cp "$Shells_BUILD_PATH" "$INSTALL_PATH" || log ERR "Failed to copy binary to $INSTALL_PATH. Permissions issue?"
295289
sudo chmod 755 "$INSTALL_PATH" || log ERR "Failed to set permissions on $INSTALL_PATH."
296290
else
297291
# Linux handling: re-run with sudo if not already root
@@ -301,7 +295,7 @@ install_binary() {
301295
exec sudo bash -c "export PATH=\"$PATH\"; \"$0\" \"$@\""
302296
fi
303297
rm -rf "$INSTALL_PATH" || log ERR "Failed to remove existing binary at $INSTALL_PATH. Permissions issue?"
304-
cp "$SHELLS_BUILD_PATH" "$INSTALL_PATH" || log ERR "Failed to copy binary to $INSTALL_PATH. Permissions issue?"
298+
cp "$Shells_BUILD_PATH" "$INSTALL_PATH" || log ERR "Failed to copy binary to $INSTALL_PATH. Permissions issue?"
305299
chown root:root "$INSTALL_PATH" || log ERR "Failed to change ownership of $INSTALL_PATH."
306300
chmod 755 "$INSTALL_PATH" || log ERR "Failed to set permissions on $INSTALL_PATH."
307301
fi
@@ -320,12 +314,12 @@ create_directories() {
320314
chmod 755 "$LOG_DIR" || log ERR "Failed to set permissions on $LOG_DIR."
321315

322316
# This is where the core logic for user-runnable commands comes in.
323-
# If Eos can run certain commands as a regular user, it needs to access
317+
# If Shells can run certain commands as a regular user, it needs to access
324318
# config/log/secret files *owned by that user*.
325319
# The recommended approach is for the Go application itself to determine
326320
# paths based on the current user and XDG Base Directory spec.
327321
# For the shell script, we can at least ensure base permissions are not overly restrictive for other users
328-
# while maintaining security for the 'eos' system user.
322+
# while maintaining security for the 'shells' system user.
329323

330324
# Example: Make config directory readable by others (if configs aren't secrets)
331325
# You might want to copy example configs here and make them user-readable
@@ -335,31 +329,7 @@ create_directories() {
335329
# This part is installing for the system service user.
336330
}
337331

338-
show_warning() {
339-
echo "⚠️ IMPORTANT WARNING ⚠️"
340-
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
341-
echo "This installs the 'shells' security testing tool."
342-
echo "This is NOT a system shell (bash/zsh/sh)!"
343-
echo ""
344-
echo "Command will be: shells (not shell)"
345-
echo "Purpose: Security scanning and penetration testing"
346-
echo "Use only on systems you have permission to test!"
347-
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
348-
echo ""
349-
read -p "Do you understand and wish to continue? (yes/no): " response
350-
case "$response" in
351-
[yY]|[yY][eE][sS])
352-
log INFO "Proceeding with installation..."
353-
;;
354-
*)
355-
log INFO "Installation cancelled by user"
356-
exit 0
357-
;;
358-
esac
359-
}
360-
361332
main() {
362-
show_warning
363333
detect_platform
364334

365335
# Update system packages first (Linux only, requires root)
@@ -383,13 +353,9 @@ main() {
383353
log INFO "This path is typically included in your user's PATH."
384354
log INFO "You should now be able to run 'shells --help' directly."
385355
echo
386-
log INFO "🔍 SHELLS - Security Testing CLI Tool"
387-
log INFO " Command: shells --help"
388-
log INFO " Config: ~/.shells.yaml"
389-
echo
390-
log INFO "⚠️ WARNING: This is a security testing tool for bug bounty hunting."
391-
log INFO " Use responsibly and only on systems you have permission to test."
392-
log INFO " Configuration files are located in '$CONFIG_DIR'."
356+
log INFO "NOTE: Commands requiring elevated privileges (e.g., system configuration, user management, service control)"
357+
log INFO " will still require 'sudo shells [command]'. For example: 'sudo shells create user'."
358+
log INFO " Log files are located in '$LOG_DIR' and configuration in '$CONFIG_DIR'."
393359
}
394360

395361
main "$@"

0 commit comments

Comments
 (0)