#!/bin/bash # Installation script for NotePad # This script installs NotePad to /opt/notepad and creates a symlink in /usr/local/bin set -e APP_NAME="NotePad" INSTALL_DIR="/opt/notepad" BIN_LINK="/usr/local/bin/notepad" DESKTOP_FILE="/usr/share/applications/notepad.desktop" ICON_DIR="/usr/share/icons/hicolor/scalable/apps" ICON_FILE="$ICON_DIR/notepad.svg" echo "============================================================" echo "$APP_NAME Installer" echo "============================================================" echo "" # Check if running as root if [ "$EUID" -ne 0 ]; then echo "❌ This script must be run as root (use sudo)" exit 1 fi # Get the directory where this script is located SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" echo "Installing $APP_NAME..." echo "" # Create installation directory echo "→ Creating installation directory: $INSTALL_DIR" mkdir -p "$INSTALL_DIR" # Copy files echo "→ Copying application files..." cp -r "$SCRIPT_DIR"/* "$INSTALL_DIR/" # Make executable chmod +x "$INSTALL_DIR/NotePad" # Create symlink echo "→ Creating symlink: $BIN_LINK" ln -sf "$INSTALL_DIR/NotePad" "$BIN_LINK" # Install icon echo "→ Installing application icon..." mkdir -p "$ICON_DIR" cp "$SCRIPT_DIR/img/notepad-icon.svg" "$ICON_FILE" # Create desktop entry echo "→ Creating desktop entry..." cat > "$DESKTOP_FILE" << EOF [Desktop Entry] Name=NotePad Comment=Simple text editor Exec=notepad %F Icon=notepad Type=Application Categories=Utility;TextEditor; Terminal=false MimeType=text/plain; EOF # Update icon cache if available if command -v gtk-update-icon-cache &> /dev/null; then echo "→ Updating icon cache..." gtk-update-icon-cache -f -t /usr/share/icons/hicolor 2>/dev/null || true fi # Update desktop database if available if command -v update-desktop-database &> /dev/null; then echo "→ Updating desktop database..." update-desktop-database /usr/share/applications fi echo "" echo "============================================================" echo "✅ Installation complete!" echo "============================================================" echo "" echo "You can now run $APP_NAME by typing: notepad" echo "Or find it in your applications menu." echo "" echo "To uninstall, run: sudo $INSTALL_DIR/uninstall.sh" echo ""