mirror of
https://github.com/Gu1llaum-3/sshm.git
synced 2026-01-27 03:04:21 +01:00
first commit
This commit is contained in:
69
install/README.md
Normal file
69
install/README.md
Normal file
@@ -0,0 +1,69 @@
|
||||
# Installation Scripts
|
||||
|
||||
This directory contains installation scripts for SSHM.
|
||||
|
||||
## Unix/Linux/macOS Installation
|
||||
|
||||
### Quick Install (Recommended)
|
||||
|
||||
```bash
|
||||
curl -sSL https://raw.githubusercontent.com/Gu1llaum-3/sshm/main/install/unix.sh | bash
|
||||
```
|
||||
|
||||
**Note:** When using the pipe method, the installer will automatically proceed with installation if SSHM is already installed.
|
||||
|
||||
### Install Options
|
||||
|
||||
**Force install without prompts:**
|
||||
```bash
|
||||
FORCE_INSTALL=true bash -c "$(curl -sSL https://raw.githubusercontent.com/Gu1llaum-3/sshm/main/install/unix.sh)"
|
||||
```
|
||||
|
||||
**Disable auto-install when using pipe:**
|
||||
```bash
|
||||
FORCE_INSTALL=false bash -c "$(curl -sSL https://raw.githubusercontent.com/Gu1llaum-3/sshm/main/install/unix.sh)"
|
||||
```
|
||||
|
||||
### Manual Install
|
||||
|
||||
1. Download the script:
|
||||
```bash
|
||||
curl -O https://raw.githubusercontent.com/Gu1llaum-3/sshm/main/install/unix.sh
|
||||
```
|
||||
|
||||
2. Make it executable:
|
||||
```bash
|
||||
chmod +x unix.sh
|
||||
```
|
||||
|
||||
3. Run the installer:
|
||||
```bash
|
||||
./unix.sh
|
||||
```
|
||||
|
||||
## What the installer does
|
||||
|
||||
1. **Detects your system** - Automatically detects your OS (Linux/macOS) and architecture (AMD64/ARM64)
|
||||
2. **Fetches latest version** - Gets the latest release from GitHub
|
||||
3. **Downloads binary** - Downloads the appropriate binary for your system
|
||||
4. **Installs to /usr/local/bin** - Installs the binary with proper permissions
|
||||
5. **Verifies installation** - Checks that the installation was successful
|
||||
|
||||
## Supported Platforms
|
||||
|
||||
- **Linux**: AMD64, ARM64
|
||||
- **macOS**: AMD64 (Intel), ARM64 (Apple Silicon)
|
||||
|
||||
## Requirements
|
||||
|
||||
- `curl` - for downloading
|
||||
- `tar` - for extracting archives
|
||||
- `sudo` access - for installing to `/usr/local/bin`
|
||||
|
||||
## Uninstall
|
||||
|
||||
To uninstall SSHM:
|
||||
|
||||
```bash
|
||||
sudo rm /usr/local/bin/sshm
|
||||
```
|
||||
173
install/unix.sh
Normal file
173
install/unix.sh
Normal file
@@ -0,0 +1,173 @@
|
||||
#!/bin/bash
|
||||
|
||||
INSTALL_DIR="/usr/local/bin"
|
||||
EXECUTABLE_NAME=sshm
|
||||
EXECUTABLE_PATH="$INSTALL_DIR/$EXECUTABLE_NAME"
|
||||
USE_SUDO="false"
|
||||
OS=""
|
||||
ARCH=""
|
||||
FORCE_INSTALL="${FORCE_INSTALL:-false}"
|
||||
|
||||
RED='\033[0;31m'
|
||||
PURPLE='\033[0;35m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m'
|
||||
|
||||
setSystem() {
|
||||
ARCH=$(uname -m)
|
||||
case $ARCH in
|
||||
i386|i686) ARCH="amd64" ;;
|
||||
x86_64) ARCH="amd64";;
|
||||
armv6*) ARCH="arm64" ;;
|
||||
armv7*) ARCH="arm64" ;;
|
||||
aarch64*) ARCH="arm64" ;;
|
||||
arm64) ARCH="arm64" ;;
|
||||
esac
|
||||
|
||||
OS=$(echo `uname`|tr '[:upper:]' '[:lower:]')
|
||||
|
||||
# Determine if we need sudo
|
||||
if [ "$OS" = "linux" ]; then
|
||||
USE_SUDO="true"
|
||||
fi
|
||||
if [ "$OS" = "darwin" ]; then
|
||||
USE_SUDO="true"
|
||||
fi
|
||||
}
|
||||
|
||||
runAsRoot() {
|
||||
local CMD="$*"
|
||||
if [ "$USE_SUDO" = "true" ]; then
|
||||
printf "${PURPLE}We need sudo access to install SSHM to $INSTALL_DIR ${NC}\n"
|
||||
CMD="sudo $CMD"
|
||||
fi
|
||||
$CMD
|
||||
}
|
||||
|
||||
getLatestVersion() {
|
||||
printf "${YELLOW}Fetching latest version...${NC}\n"
|
||||
LATEST_VERSION=$(curl -s https://api.github.com/repos/Gu1llaum-3/sshm/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
|
||||
if [ -z "$LATEST_VERSION" ]; then
|
||||
printf "${RED}Failed to fetch latest version${NC}\n"
|
||||
exit 1
|
||||
fi
|
||||
printf "${GREEN}Latest version: $LATEST_VERSION${NC}\n"
|
||||
}
|
||||
|
||||
downloadBinary() {
|
||||
GITHUB_FILE="sshm-${OS}-${ARCH}.tar.gz"
|
||||
GITHUB_URL="https://github.com/Gu1llaum-3/sshm/releases/download/$LATEST_VERSION/$GITHUB_FILE"
|
||||
|
||||
printf "${YELLOW}Downloading $GITHUB_FILE...${NC}\n"
|
||||
curl -L "$GITHUB_URL" --progress-bar --output "sshm-tmp.tar.gz"
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
printf "${RED}Failed to download binary${NC}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Extract the binary
|
||||
tar -xzf "sshm-tmp.tar.gz"
|
||||
if [ $? -ne 0 ]; then
|
||||
printf "${RED}Failed to extract binary${NC}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Find the extracted binary
|
||||
EXTRACTED_BINARY=$(find . -name "sshm-${OS}-${ARCH}" -type f)
|
||||
if [ -z "$EXTRACTED_BINARY" ]; then
|
||||
printf "${RED}Could not find extracted binary${NC}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mv "$EXTRACTED_BINARY" "sshm-tmp"
|
||||
rm -f "sshm-tmp.tar.gz"
|
||||
}
|
||||
|
||||
install() {
|
||||
printf "${YELLOW}Installing SSHM...${NC}\n"
|
||||
|
||||
chmod +x "sshm-tmp"
|
||||
if [ $? -ne 0 ]; then
|
||||
printf "${RED}Failed to set permissions${NC}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
runAsRoot mv "sshm-tmp" "$EXECUTABLE_PATH"
|
||||
if [ $? -ne 0 ]; then
|
||||
printf "${RED}Failed to install binary${NC}\n"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
rm -f "sshm-tmp" "sshm-tmp.tar.gz" "sshm-${OS}-${ARCH}"
|
||||
}
|
||||
|
||||
checkExisting() {
|
||||
if command -v sshm >/dev/null 2>&1; then
|
||||
CURRENT_VERSION=$(sshm --version 2>/dev/null | grep -o 'version.*' | cut -d' ' -f2 || echo "unknown")
|
||||
printf "${YELLOW}SSHM is already installed (version: $CURRENT_VERSION)${NC}\n"
|
||||
|
||||
# Check if FORCE_INSTALL is set
|
||||
if [ "$FORCE_INSTALL" = "true" ]; then
|
||||
printf "${GREEN}Force install enabled, proceeding with installation...${NC}\n"
|
||||
return
|
||||
fi
|
||||
|
||||
# Check if running via pipe (stdin is not a terminal)
|
||||
if [ ! -t 0 ]; then
|
||||
printf "${YELLOW}Running via pipe - automatically proceeding with installation...${NC}\n"
|
||||
printf "${YELLOW}Use 'FORCE_INSTALL=false bash -c \"\$(curl -sSL ...)\"' to disable auto-install${NC}\n"
|
||||
return
|
||||
fi
|
||||
|
||||
printf "${YELLOW}Do you want to overwrite it? [y/N]: ${NC}"
|
||||
read -r response
|
||||
case "$response" in
|
||||
[yY][eE][sS]|[yY])
|
||||
printf "${GREEN}Proceeding with installation...${NC}\n"
|
||||
;;
|
||||
*)
|
||||
printf "${GREEN}Installation cancelled.${NC}\n"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
printf "${PURPLE}Installing SSHM - SSH Connection Manager${NC}\n\n"
|
||||
|
||||
# Check if already installed
|
||||
checkExisting
|
||||
|
||||
# Set up system detection
|
||||
setSystem
|
||||
printf "${GREEN}Detected system: $OS ($ARCH)${NC}\n"
|
||||
|
||||
# Get latest version
|
||||
getLatestVersion
|
||||
|
||||
# Download and install
|
||||
downloadBinary
|
||||
install
|
||||
cleanup
|
||||
|
||||
printf "\n${GREEN}✅ SSHM was installed successfully to: ${NC}$EXECUTABLE_PATH\n"
|
||||
printf "${GREEN}You can now use 'sshm' command to manage your SSH connections!${NC}\n\n"
|
||||
|
||||
# Show version
|
||||
printf "${YELLOW}Verifying installation...${NC}\n"
|
||||
if command -v sshm >/dev/null 2>&1; then
|
||||
sshm --version
|
||||
else
|
||||
printf "${RED}Warning: 'sshm' command not found in PATH. You may need to restart your terminal or add $INSTALL_DIR to your PATH.${NC}\n"
|
||||
fi
|
||||
}
|
||||
|
||||
# Trap to cleanup on exit
|
||||
trap cleanup EXIT
|
||||
|
||||
main "$@"
|
||||
Reference in New Issue
Block a user