/ linuxy / install.sh
Swadhin Biswas Ci/improve release notes (#41) · 8/28/2026
04d550f
140 lines · 4.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/usr/bin/env bash
set -e

# Linuxy Installation Script
# This script detects your OS and installs the appropriate Linuxy package (DEB, RPM, or AppImage).

REPO="swadhinbiswas/linuxy"
API_URL="https://api.github.com/repos/$REPO/releases/latest"

echo "========================================"
echo "    Installing Linuxy Application       "
echo "========================================"
echo ""

# Ensure curl is installed
if ! command -v curl &> /dev/null; then
    echo "Error: curl is required to run this script."
    exit 1
fi

# Detect Architecture
ARCH=$(uname -m)
if [ "$ARCH" = "x86_64" ]; then
    TAURI_ARCH="amd64"
    APPIMAGE_ARCH="amd64"
    RPM_ARCH="x86_64"
else
    echo "Warning: Linuxy officially supports x86_64 architectures."
    echo "Your architecture is $ARCH. The installation might fail if no release is found."
    TAURI_ARCH="$ARCH"
    APPIMAGE_ARCH="$ARCH"
    RPM_ARCH="$ARCH"
fi

echo "Fetching latest release information..."
# Fetch latest release data
RELEASE_DATA=$(curl -fsSL "$API_URL")
if [ -z "$RELEASE_DATA" ]; then
    echo "Error: Failed to fetch release information from GitHub."
    exit 1
fi

# Extract download URLs for different formats
DEB_URL=$(echo "$RELEASE_DATA" | grep -oP '"browser_download_url": "\K(.*\.deb)(?=")' | grep "$TAURI_ARCH" | head -n 1)
RPM_URL=$(echo "$RELEASE_DATA" | grep -oP '"browser_download_url": "\K(.*\.rpm)(?=")' | grep "$RPM_ARCH" | head -n 1)
APPIMAGE_URL=$(echo "$RELEASE_DATA" | grep -oP '"browser_download_url": "\K(.*\.AppImage)(?=")' | grep -i "$APPIMAGE_ARCH" | head -n 1)

# Fallbacks if architecture-specific grep fails (sometimes the naming convention varies)
if [ -z "$DEB_URL" ]; then DEB_URL=$(echo "$RELEASE_DATA" | grep -oP '"browser_download_url": "\K(.*\.deb)(?=")' | head -n 1); fi
if [ -z "$RPM_URL" ]; then RPM_URL=$(echo "$RELEASE_DATA" | grep -oP '"browser_download_url": "\K(.*\.rpm)(?=")' | head -n 1); fi
if [ -z "$APPIMAGE_URL" ]; then APPIMAGE_URL=$(echo "$RELEASE_DATA" | grep -oP '"browser_download_url": "\K(.*\.AppImage)(?=")' | head -n 1); fi

TMP_DIR=$(mktemp -d)
cd "$TMP_DIR"

install_deb() {
    echo "Detected Debian/Ubuntu-based system."
    if [ -z "$DEB_URL" ]; then
        echo "No DEB package found for the latest release. Falling back to AppImage..."
        install_appimage
        return
    fi
    echo "Downloading: $DEB_URL"
    curl -fL# -o linuxy.deb "$DEB_URL"
    echo "Installing DEB package (requires sudo)..."
    sudo apt-get install -y ./linuxy.deb
    echo "Linuxy installed successfully!"
}

install_rpm() {
    echo "Detected RPM-based system."
    if [ -z "$RPM_URL" ]; then
        echo "No RPM package found for the latest release. Falling back to AppImage..."
        install_appimage
        return
    fi
    echo "Downloading: $RPM_URL"
    curl -fL# -o linuxy.rpm "$RPM_URL"
    echo "Installing RPM package (requires sudo)..."
    if command -v dnf &> /dev/null; then
        sudo dnf install -y ./linuxy.rpm
    elif command -v zypper &> /dev/null; then
        sudo zypper install -y ./linuxy.rpm
    elif command -v yum &> /dev/null; then
        sudo yum localinstall -y ./linuxy.rpm
    else
        sudo rpm -i ./linuxy.rpm
    fi
    echo "Linuxy installed successfully!"
}

install_appimage() {
    echo "Using universal AppImage format."
    if [ -z "$APPIMAGE_URL" ]; then
        echo "Error: No AppImage found for the latest release."
        exit 1
    fi
    echo "Downloading: $APPIMAGE_URL"
    curl -fL# -o linuxy.AppImage "$APPIMAGE_URL"
    chmod +x linuxy.AppImage
    
    BIN_DIR="$HOME/.local/bin"
    mkdir -p "$BIN_DIR"
    
    echo "Installing to $BIN_DIR/linuxy"
    mv linuxy.AppImage "$BIN_DIR/linuxy"
    
    # Add to PATH if not already there
    if [[ ":$PATH:" != *":$BIN_DIR:"* ]]; then
        echo "WARNING: $BIN_DIR is not in your PATH."
        echo "You may want to add 'export PATH=\"\$HOME/.local/bin:\$PATH\"' to your ~/.bashrc or ~/.zshrc"
    fi

    echo "Running self-registration to create desktop shortcuts..."
    # Launch briefly in background so the AppImage's setup() can register the
    # desktop entry, then terminate - avoids blocking if --help still opens the GUI
    "$BIN_DIR/linuxy" --help >/dev/null 2>&1 & pid=$!
    sleep 2
    kill "$pid" 2>/dev/null || true
    wait "$pid" 2>/dev/null || true

    echo "Linuxy AppImage installed successfully!"
    echo "You can now run 'linuxy' from your terminal or launch it from your application menu."
}

# OS Detection
if command -v apt-get &> /dev/null || command -v dpkg &> /dev/null; then
    install_deb
elif command -v dnf &> /dev/null || command -v zypper &> /dev/null || command -v rpm &> /dev/null; then
    install_rpm
else
    install_appimage
fi

# Cleanup
cd ~
rm -rf "$TMP_DIR"
echo ""
echo "Installation Complete! Welcome to Linuxy."