notepad/NotePad/install.sh

87 lines
2.3 KiB
Bash
Raw Permalink Normal View History

2026-02-14 14:15:52 +00:00
#!/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"
2026-02-14 22:08:38 +00:00
ICON_DIR="/usr/share/icons/hicolor/scalable/apps"
ICON_FILE="$ICON_DIR/notepad.svg"
2026-02-14 14:15:52 +00:00
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"
2026-02-14 22:08:38 +00:00
# Install icon
echo "→ Installing application icon..."
mkdir -p "$ICON_DIR"
cp "$SCRIPT_DIR/img/notepad-icon.svg" "$ICON_FILE"
2026-02-14 14:15:52 +00:00
# Create desktop entry
echo "→ Creating desktop entry..."
cat > "$DESKTOP_FILE" << EOF
[Desktop Entry]
Name=NotePad
Comment=Simple text editor
Exec=notepad %F
2026-02-14 22:08:38 +00:00
Icon=notepad
2026-02-14 14:15:52 +00:00
Type=Application
Categories=Utility;TextEditor;
Terminal=false
MimeType=text/plain;
EOF
2026-02-14 22:08:38 +00:00
# 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
2026-02-14 14:15:52 +00:00
# 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 ""