mirror of
https://github.com/Gu1llaum-3/sshm.git
synced 2025-09-07 21:30:39 +02:00
fix: resolve macOS permission errors during SSHM installation
- Replace recursive find with direct file path check to avoid scanning protected directories - Backup old binary during installation to prevent interference from old version - Use full path for version verification to ensure new binary is tested - Fixes 'Operation not permitted' errors on macOS during installation process
This commit is contained in:
parent
2deec405f7
commit
2ade315ddc
@ -74,10 +74,10 @@ downloadBinary() {
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Find the extracted binary
|
# Check if the expected binary exists (no find needed)
|
||||||
EXTRACTED_BINARY=$(find . -name "sshm-${OS}-${ARCH}" -type f)
|
EXTRACTED_BINARY="./sshm-${OS}-${ARCH}"
|
||||||
if [ -z "$EXTRACTED_BINARY" ]; then
|
if [ ! -f "$EXTRACTED_BINARY" ]; then
|
||||||
printf "${RED}Could not find extracted binary${NC}\n"
|
printf "${RED}Could not find extracted binary: $EXTRACTED_BINARY${NC}\n"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -88,17 +88,37 @@ downloadBinary() {
|
|||||||
install() {
|
install() {
|
||||||
printf "${YELLOW}Installing SSHM...${NC}\n"
|
printf "${YELLOW}Installing SSHM...${NC}\n"
|
||||||
|
|
||||||
|
# Backup old version if it exists to prevent interference during installation
|
||||||
|
OLD_BACKUP=""
|
||||||
|
if [ -f "$EXECUTABLE_PATH" ]; then
|
||||||
|
OLD_BACKUP="$EXECUTABLE_PATH.backup.$$"
|
||||||
|
runAsRoot mv "$EXECUTABLE_PATH" "$OLD_BACKUP"
|
||||||
|
fi
|
||||||
|
|
||||||
chmod +x "sshm-tmp"
|
chmod +x "sshm-tmp"
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
printf "${RED}Failed to set permissions${NC}\n"
|
printf "${RED}Failed to set permissions${NC}\n"
|
||||||
|
# Restore backup if installation fails
|
||||||
|
if [ -n "$OLD_BACKUP" ] && [ -f "$OLD_BACKUP" ]; then
|
||||||
|
runAsRoot mv "$OLD_BACKUP" "$EXECUTABLE_PATH"
|
||||||
|
fi
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
runAsRoot mv "sshm-tmp" "$EXECUTABLE_PATH"
|
runAsRoot mv "sshm-tmp" "$EXECUTABLE_PATH"
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
printf "${RED}Failed to install binary${NC}\n"
|
printf "${RED}Failed to install binary${NC}\n"
|
||||||
|
# Restore backup if installation fails
|
||||||
|
if [ -n "$OLD_BACKUP" ] && [ -f "$OLD_BACKUP" ]; then
|
||||||
|
runAsRoot mv "$OLD_BACKUP" "$EXECUTABLE_PATH"
|
||||||
|
fi
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Clean up backup if installation succeeded
|
||||||
|
if [ -n "$OLD_BACKUP" ] && [ -f "$OLD_BACKUP" ]; then
|
||||||
|
runAsRoot rm -f "$OLD_BACKUP"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
@ -161,7 +181,8 @@ main() {
|
|||||||
# Show version
|
# Show version
|
||||||
printf "${YELLOW}Verifying installation...${NC}\n"
|
printf "${YELLOW}Verifying installation...${NC}\n"
|
||||||
if command -v sshm >/dev/null 2>&1; then
|
if command -v sshm >/dev/null 2>&1; then
|
||||||
sshm --version
|
# Use the full path to ensure we're using the newly installed version
|
||||||
|
"$EXECUTABLE_PATH" --version 2>/dev/null || echo "Version check failed, but installation completed"
|
||||||
else
|
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"
|
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
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user