Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new method for installation by script #1595

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 44 additions & 31 deletions docs/Run_Linux.md
Original file line number Diff line number Diff line change
@@ -1,81 +1,94 @@
## Linux 安装
## Linux Installation

### Debian 系发行版
For installation, you can use this script:
```sh
sh install-nekoray.sh
```

### Debian-Based Distributions

使用 Debian 系发行版时,推荐使用 .deb 包安装:
For Debian-based distributions, it is recommended to use the `.deb` package for installation:

```shell
sudo apt install ./nekoray-*-debian-x64.deb
```

安装完成后,桌面快捷方式启动自带参数 `-appdata`,如果想要直接启动并使用之前的配置,注意附带本参数。
After installation, the desktop shortcut will launch with the `-appdata` parameter. If you want to launch directly and use previous configurations, make sure to include this parameter.

### Arch 系发行版
### Arch-Based Distributions

使用 Arch 系发行版时,推荐从 ```aur``` 或 ```archlinuxcn``` 安装:
For Arch-based distributions, it is recommended to install from `AUR` or `archlinuxcn`:

#### AUR
##### 最新稳定版
##### Latest Stable Version

```shell
[yay/paru] -S nekoray
```

##### 最新 Git 版 (开发版)
##### Latest Git Version (Development Version)

```shell
[yay/paru] -S nekoray-git
```

#### archlinuxcn

##### 最新稳定版
##### Latest Stable Version

```shell
sudo pacman -S nekoray
```

##### 最新 Git 版 (开发版)
##### Latest Git Version (Development Version)

```shell
sudo pacman -S nekoray-git
```

### 其他发行版
### Other Distributions

Download the `.zip` file, extract it to a suitable directory, and use it right away.

Alternatively, download the `.AppImage` file and grant execution permissions using:

下载 .zip 文件,解压到合适的路径,开箱即用。
```shell
chmod +x nekoray-*-AppImage-x64.AppImage
```

或下载 .AppImage,并使用 `chmod +x nekoray-*-AppImage-x64.AppImage` 给予可执行权限。
Refer to the following sections for detailed usage instructions.

具体使用方法见下文。
## Linux Usage

## Linux 运行
**Using a Linux system implies that you have basic troubleshooting skills.
This project does not provide specific support for distributions/architectures. If the precompiled files do not meet your needs, please compile/adjust them yourself.**

**使用 Linux 系统相信您已具备基本的排错能力,
本项目不提供特定发行版/架构的支持,预编译文件不能满足您的需求时,请自行编译/适配。**
Note: Some Linux distributions are known to be incompatible, and there is no current support for non-x86_64 architectures. You may attempt to compile the software yourself.

已知部分 Linux 发行版无法使用、非 x86_64 暂无适配,可以尝试自行编译。
For the current release, portable packages can be used in two ways after extraction:

目前 Release 便携包解压后,有两种使用方法:
1. **System Mode**: To use the system's Qt5 runtime library, execute `./nekoray`.
2. **Bundle Mode**: To use the precompiled Qt runtime library, execute `./launcher`.

1. System: 若要使用系统的 Qt5 运行库,请执行 `./nekoray`
2. Bundle: 若要使用预编译的 Qt 运行库,请执行 `./launcher`
### Bundle Mode

### Bundle
**Requirements**: A mainstream distribution with an xcb desktop environment installed.

要求:已安装主流的发行版和 xcb 桌面环境。
**Run**: Execute `./launcher`, or double-click to open on some systems.

运行: `./launcher` 或 部分系统可双击打开
Launcher parameters:

launcher 参数
- `./launcher -- -appdata` (Parameters after `--` are passed to the main program.)
- `-debug` Debug mode

* `./launcher -- -appdata` ( `--` 后的参数传递给主程序 )
* `-debug` Debug mode
For Ubuntu 22.04:
```shell
sudo apt install libxcb-xinerama0
```

Ubuntu 22.04: `sudo apt install libxcb-xinerama0`
### System Mode

### System
**Requirements**: A mainstream distribution with an xcb desktop environment installed and a Qt5.12 ~ Qt5.15 environment set up.

要求:已安装主流的发行版和 xcb 桌面环境,已安装 Qt5.12 ~ Qt5.15 环境。
**Run**: Execute `./nekoray`, or double-click to open on some systems. If it fails to run, it is recommended to use the Bundle version.

运行: `./nekoray` 或 部分系统可双击打开。如果无法运行,建议使用 Bundle 版。
162 changes: 162 additions & 0 deletions docs/install-nekoray.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
#!/bin/bash
set -e

NEKORAY_URL="https://api.github.com/repos/MatsuriDayo/nekoray/releases"
NEKORAY_FILE_NAME="NekoRay"
NEKORAY_DESKTOPFILE="$HOME/.local/share/applications/nekoray.desktop"
WGET_TIMEOUT="15"

# Colors for terminal output
GREEN='\033[0;32m'
NC='\033[0m' # No Color

# ASCII Banner
echo -e "\n${GREEN}NekoRay Installer${NC}\n"

# Function to check prerequisites
check_prerequisites() {
if ! command -v unzip &> /dev/null; then
echo -e "unzip is not installed.\nInstall unzip in your system.\nFor example: sudo apt install unzip"
exit 1
fi
if ! command -v wget &> /dev/null; then
echo -e "wget is not installed.\nInstall wget in your system.\nFor example: sudo apt install wget"
exit 1
fi
}

# Function to install NekoRay
install_nekoray() {
# Fetch available versions
echo "Fetching available versions..."
VERSIONS=$(wget --timeout=$WGET_TIMEOUT -q -O- $NEKORAY_URL | grep -Eo '"tag_name": "[^"]+' | cut -d '"' -f 4)

if [ -z "$VERSIONS" ]; then
echo "Failed to fetch available versions. Please check your internet connection or the repository URL."
exit 1
fi

# Ask user to select a version
echo "Available versions:"
select VERSION in $VERSIONS; do
if [ -n "$VERSION" ]; then
echo "You selected version: $VERSION"
break
else
echo "Invalid selection. Please choose a valid version."
fi
done

# Fetch the download URL
echo "Fetching download URL for version: $VERSION"
DOWNLOAD_URL=$(wget --timeout=$WGET_TIMEOUT -q -O- $NEKORAY_URL |
grep -E "browser_download_url" |
grep "$VERSION" |
grep "linux64" |
head -n 1 |
cut -d '"' -f 4)

if [ -z "$DOWNLOAD_URL" ]; then
echo "Failed to find download URL for version $VERSION."
exit 1
fi

# Debugging: Print download URL
echo "Download URL: $DOWNLOAD_URL"

# Download the file
echo "Downloading NekoRay..."
if ! wget --timeout=$WGET_TIMEOUT -q --show-progress --progress=bar:force -O /tmp/nekoray.zip "$DOWNLOAD_URL"; then
echo "Failed to download NekoRay from $DOWNLOAD_URL."
exit 1
fi

# Extract the file
echo "Extracting NekoRay..."
if ! unzip /tmp/nekoray.zip -d "$HOME/$NEKORAY_FILE_NAME"; then
echo "Failed to extract the downloaded file."
rm /tmp/nekoray.zip
exit 1
fi
rm /tmp/nekoray.zip

# Check for renamed executable and icon
EXECUTABLE_PATH="$HOME/$NEKORAY_FILE_NAME/nekoray/nekoray"
ICON_PATH="$HOME/$NEKORAY_FILE_NAME/nekoray/nekoray.png"

if [ ! -f "$EXECUTABLE_PATH" ]; then
EXECUTABLE_PATH="$HOME/$NEKORAY_FILE_NAME/nekoray/nekobox"
fi

if [ ! -f "$ICON_PATH" ]; then
ICON_PATH="$HOME/$NEKORAY_FILE_NAME/nekoray/nekobox.png"
fi

# Create Desktop icon for current user
[ -e "$NEKORAY_DESKTOPFILE" ] && rm "$NEKORAY_DESKTOPFILE"

echo "Creating desktop entry..."
cat <<EOT >> "$NEKORAY_DESKTOPFILE"
[Desktop Entry]
Name=NekoRay
Comment=NekoRay
Exec=$EXECUTABLE_PATH
Icon=$ICON_PATH
Terminal=false
StartupWMClass=NekoRay,nekoray,Nekoray,nekoRay
Type=Application
Categories=Network
EOT

# Set permissions
echo "Setting permissions..."
chown "$USER:$USER" "$HOME/$NEKORAY_FILE_NAME/" -R
chmod +x "$EXECUTABLE_PATH" -R

echo -e "\nDone! NekoRay version $VERSION installed. Type 'NekoRay' in your desktop search to launch it."
}

# Function to remove NekoRay
remove_nekoray() {
if [ -d "$HOME/$NEKORAY_FILE_NAME" ]; then
echo "Removing NekoRay..."
rm -rf "$HOME/$NEKORAY_FILE_NAME"
[ -e "$NEKORAY_DESKTOPFILE" ] && rm "$NEKORAY_DESKTOPFILE"
echo "NekoRay has been removed."
else
echo "NekoRay is not installed."
fi
}

# Function to upgrade NekoRay
upgrade_nekoray() {
echo "Upgrading NekoRay..."
remove_nekoray
install_nekoray
}

# Main menu
echo "Choose an option:"
echo "1) Install NekoRay"
echo "2) Remove NekoRay"
echo "3) Upgrade NekoRay"
read -rp "Enter your choice: " CHOICE

case $CHOICE in
1)
check_prerequisites
install_nekoray
;;
2)
remove_nekoray
;;
3)
check_prerequisites
upgrade_nekoray
;;
*)
echo "Invalid choice. Exiting."
exit 1
;;
esac