mirror of
https://github.com/tw93/Mole.git
synced 2026-02-14 19:57:28 +00:00
🐛 update install
This commit is contained in:
87
install.sh
87
install.sh
@@ -11,10 +11,13 @@ YELLOW='\033[1;33m'
|
|||||||
RED='\033[0;31m'
|
RED='\033[0;31m'
|
||||||
NC='\033[0m'
|
NC='\033[0m'
|
||||||
|
|
||||||
# Logging functions
|
# Verbosity (0 = quiet, 1 = verbose)
|
||||||
log_info() { echo -e "${BLUE}$1${NC}"; }
|
VERBOSE=0
|
||||||
log_success() { echo -e "${GREEN}✅ $1${NC}"; }
|
|
||||||
log_warning() { echo -e "${YELLOW}⚠️ $1${NC}"; }
|
# Logging functions (quiet by default)
|
||||||
|
log_info() { [[ ${VERBOSE} -eq 1 ]] && echo -e "${BLUE}$1${NC}"; }
|
||||||
|
log_success() { [[ ${VERBOSE} -eq 1 ]] && echo -e "${GREEN}✅ $1${NC}"; }
|
||||||
|
log_warning() { [[ ${VERBOSE} -eq 1 ]] && echo -e "${YELLOW}⚠️ $1${NC}"; }
|
||||||
log_error() { echo -e "${RED}❌ $1${NC}"; }
|
log_error() { echo -e "${RED}❌ $1${NC}"; }
|
||||||
|
|
||||||
# Default installation directory
|
# Default installation directory
|
||||||
@@ -34,6 +37,7 @@ OPTIONS:
|
|||||||
--prefix PATH Install to custom directory (default: /usr/local/bin)
|
--prefix PATH Install to custom directory (default: /usr/local/bin)
|
||||||
--config PATH Config directory (default: ~/.config/mole)
|
--config PATH Config directory (default: ~/.config/mole)
|
||||||
--uninstall Uninstall mole
|
--uninstall Uninstall mole
|
||||||
|
--verbose, -v Print progress and success messages
|
||||||
--help, -h Show this help
|
--help, -h Show this help
|
||||||
|
|
||||||
EXAMPLES:
|
EXAMPLES:
|
||||||
@@ -69,10 +73,10 @@ resolve_source_dir() {
|
|||||||
# 3) Fallback: fetch repository to a temp directory (works for curl | bash)
|
# 3) Fallback: fetch repository to a temp directory (works for curl | bash)
|
||||||
local tmp
|
local tmp
|
||||||
tmp="$(mktemp -d)"
|
tmp="$(mktemp -d)"
|
||||||
# Guard against set -u when trap runs outside the local scope
|
# Expand tmp now so trap doesn't depend on local scope
|
||||||
trap '[[ -n "${tmp:-}" ]] && rm -rf "$tmp"' EXIT
|
trap "rm -rf '$tmp'" EXIT
|
||||||
|
|
||||||
echo "Fetching Mole source..."
|
log_info "Fetching Mole source..."
|
||||||
if command -v curl >/dev/null 2>&1; then
|
if command -v curl >/dev/null 2>&1; then
|
||||||
# Download main branch tarball
|
# Download main branch tarball
|
||||||
if curl -fsSL -o "$tmp/mole.tar.gz" "https://github.com/tw93/mole/archive/refs/heads/main.tar.gz"; then
|
if curl -fsSL -o "$tmp/mole.tar.gz" "https://github.com/tw93/mole/archive/refs/heads/main.tar.gz"; then
|
||||||
@@ -113,6 +117,10 @@ parse_args() {
|
|||||||
uninstall_mole
|
uninstall_mole
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
|
--verbose|-v)
|
||||||
|
VERBOSE=1
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
--help|-h)
|
--help|-h)
|
||||||
show_help
|
show_help
|
||||||
exit 0
|
exit 0
|
||||||
@@ -240,20 +248,23 @@ verify_installation() {
|
|||||||
|
|
||||||
# Add to PATH if needed
|
# Add to PATH if needed
|
||||||
setup_path() {
|
setup_path() {
|
||||||
# Check if install directory is in PATH
|
# Only output in verbose mode
|
||||||
if [[ ":$PATH:" == *":$INSTALL_DIR:"* ]]; then
|
if [[ ${VERBOSE} -eq 1 ]]; then
|
||||||
log_success "$INSTALL_DIR is already in PATH"
|
# Check if install directory is in PATH
|
||||||
return
|
if [[ ":$PATH:" == *":$INSTALL_DIR:"* ]]; then
|
||||||
fi
|
log_success "$INSTALL_DIR is already in PATH"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
# Only suggest PATH setup for custom directories
|
# Only suggest PATH setup for custom directories
|
||||||
if [[ "$INSTALL_DIR" != "/usr/local/bin" ]]; then
|
if [[ "$INSTALL_DIR" != "/usr/local/bin" ]]; then
|
||||||
log_warning "$INSTALL_DIR is not in your PATH"
|
log_warning "$INSTALL_DIR is not in your PATH"
|
||||||
echo ""
|
echo ""
|
||||||
echo "To use mole from anywhere, add this line to your shell profile:"
|
echo "To use mole from anywhere, add this line to your shell profile:"
|
||||||
echo "export PATH=\"$INSTALL_DIR:\$PATH\""
|
echo "export PATH=\"$INSTALL_DIR:\$PATH\""
|
||||||
echo ""
|
echo ""
|
||||||
echo "For example, add it to ~/.zshrc or ~/.bash_profile"
|
echo "For example, add it to ~/.zshrc or ~/.bash_profile"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -289,9 +300,11 @@ uninstall_mole() {
|
|||||||
|
|
||||||
# Main installation function
|
# Main installation function
|
||||||
main() {
|
main() {
|
||||||
echo "🕳️ Mole Installation Script"
|
if [[ ${VERBOSE} -eq 1 ]]; then
|
||||||
echo "============================"
|
echo "🕳️ Mole Installation Script"
|
||||||
echo ""
|
echo "============================"
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
|
||||||
check_requirements
|
check_requirements
|
||||||
create_directories
|
create_directories
|
||||||
@@ -299,20 +312,22 @@ main() {
|
|||||||
verify_installation
|
verify_installation
|
||||||
setup_path
|
setup_path
|
||||||
|
|
||||||
echo ""
|
if [[ ${VERBOSE} -eq 1 ]]; then
|
||||||
log_success "Mole installed successfully!"
|
echo ""
|
||||||
echo ""
|
log_success "Mole installed successfully!"
|
||||||
echo "Usage:"
|
echo ""
|
||||||
if [[ ":$PATH:" == *":$INSTALL_DIR:"* ]]; then
|
echo "Usage:"
|
||||||
echo " mole # Interactive menu"
|
if [[ ":$PATH:" == *":$INSTALL_DIR:"* ]]; then
|
||||||
echo " mole clean # System cleanup"
|
echo " mole # Interactive menu"
|
||||||
echo " mole uninstall # Remove applications"
|
echo " mole clean # System cleanup"
|
||||||
else
|
echo " mole uninstall # Remove applications"
|
||||||
echo " $INSTALL_DIR/mole # Interactive menu"
|
else
|
||||||
echo " $INSTALL_DIR/mole clean # System cleanup"
|
echo " $INSTALL_DIR/mole # Interactive menu"
|
||||||
echo " $INSTALL_DIR/mole uninstall # Remove applications"
|
echo " $INSTALL_DIR/mole clean # System cleanup"
|
||||||
|
echo " $INSTALL_DIR/mole uninstall # Remove applications"
|
||||||
|
fi
|
||||||
|
echo ""
|
||||||
fi
|
fi
|
||||||
echo ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Run installation
|
# Run installation
|
||||||
|
|||||||
Reference in New Issue
Block a user