diff --git a/docs/de/setup/linux.md b/docs/de/setup/linux.md index c1616aa4..af078b1a 100644 --- a/docs/de/setup/linux.md +++ b/docs/de/setup/linux.md @@ -55,30 +55,32 @@ curl -sSL https://raw.githubusercontent.com/gnmyt/myspeed/development/scripts/un ## Manuelle Installation ```sh -sudo apt-get install wget curl unzip -y #(1) +sudo apt-get install wget curl -y #(1) -# Dies ist nur erforderlich, wenn NodeJS noch nicht installiert ist -curl -sSL https://deb.nodesource.com/setup_18.x | bash -sudo apt-get install nodejs -y #(2) +mkdir /opt/myspeed && cd /opt/myspeed #(2) -mkdir /opt/myspeed && cd /opt/myspeed #(3) +# Architektur erkennen und passende Binary herunterladen +ARCH=$(uname -m) +if [ "$ARCH" = "x86_64" ]; then + ARCH="x64" +elif [ "$ARCH" = "aarch64" ]; then + ARCH="arm64" +fi -wget $(curl -s https://api.github.com/repos/gnmyt/myspeed/releases/latest | grep browser_download_url | cut -d '"' -f 4) #(4) +wget $(curl -s https://api.github.com/repos/gnmyt/myspeed/releases/latest \ + | grep "browser_download_url.*linux-${ARCH}" | cut -d '"' -f 4) \ + -O myspeed #(3) -unzip MySpeed-*.zip && rm MySpeed-*.zip #(5) +chmod +x myspeed #(4) -npm install #(6) - -NODE_ENV=production node server #(7) +./myspeed #(5) ``` 1. Hier werden alle notwendigen Pakete für die Installation des Projekts installiert. -2. Dieser Schritt installiert die neueste Version von NodeJS. -3. Erstelle nun den Ordner, in dem du MySpeed installieren möchtest. In diesem Fall ist es der Ordner `/opt/myspeed`. -4. Installiere nun die neueste Version von MySpeed. -5. Entpacke die gerade heruntergeladene Datei (danach kannst du sie löschen). -6. Installiere nun alle Abhängigkeiten. -7. Starte nun MySpeed. MySpeed ist jetzt auf Port 5216 verfügbar. +2. Erstelle nun den Ordner, in dem du MySpeed installieren möchtest. In diesem Fall ist es der Ordner `/opt/myspeed`. +3. Lade die vorkompilierte Binary für deine Architektur (x64 oder arm64) herunter. +4. Mache die Binary ausführbar. +5. Starte nun MySpeed. MySpeed ist jetzt auf Port 5216 verfügbar. Wenn du planst, MySpeed im Hintergrund laufen zu lassen, siehe die Anleitung unten. ## Installation von MySpeed aus dem Quellcode @@ -87,25 +89,26 @@ Dieser Prozess installiert die neuste Entwicklungsversion von MySpeed. Fehler k ::: ```sh -sudo apt-get install git curl -y #(1) +sudo apt-get install git curl npm -y #(1) -# Dies ist nur erforderlich, wenn NodeJS noch nicht installiert ist -curl -sSL https://deb.nodesource.com/setup_18.x | bash -sudo apt-get install nodejs -y #(2) +# Deno installieren +curl -fsSL https://deno.land/install.sh | sh +export DENO_INSTALL="$HOME/.deno" +export PATH="$DENO_INSTALL/bin:$PATH" #(2) mkdir /opt/myspeed && cd /opt/myspeed #(3) git clone https://github.com/gnmyt/myspeed.git . #(4) -npm install #(5) +deno install #(5) cd client && npm install && npm run build && cd .. && mv client/build . #(6) -NODE_ENV=production node server #(7) +deno run --allow-all server/index.js #(7) ``` 1. Hier installierst du alle notwendigen Pakete, um das Projekt zu installieren. -2. Dieser Schritt installiert die neuste Version von NodeJS. +2. Dieser Schritt installiert die Deno Runtime. 3. Erstelle nun den Ordner, in welchen du MySpeed installieren möchtest. In diesem Fall ist das der Ordner `/opt/myspeed`. 4. Klone nun das MySpeed Repository, um Zugriff auf den Code zu erhalten. 5. Installiere nun alle Abhängigkeiten des Servers. @@ -134,11 +137,10 @@ Die Installation als Systemdienst ist nicht schwer. In diesem Fall verwenden wir [Service] Type=simple - ExecStart=/usr/bin/node server + ExecStart=/opt/myspeed/myspeed Restart=always # \/ Es wird dringend empfohlen, hier deinen eigenen Benutzer zu erstellen User=root - Environment=NODE_ENV=production # \/ Gib hier deinen Installationsort an WorkingDirectory=/opt/myspeed diff --git a/docs/de/setup/windows.md b/docs/de/setup/windows.md index d9522d09..b2a14ecf 100644 --- a/docs/de/setup/windows.md +++ b/docs/de/setup/windows.md @@ -3,60 +3,53 @@ Hier beschreiben wir die Einrichtung für Windows. ## Installation von MySpeed -1. NodeJS herunterladen - Um MySpeed zu verwenden, benötigst du zuerst **NodeJS**. Du kannst den Installer ganz einfach [hier](https://nodejs.org/en/download/) herunterladen. Empfohlen wird die LTS-Version 18 von NodeJS. +1. MySpeed herunterladen + Lade die neueste Version von MySpeed von der [Releases-Seite](https://github.com/gnmyt/myspeed/releases/latest) herunter. Lade die Datei `myspeed-windows-x64.exe` herunter. -2. MySpeed herunterladen - Lade jetzt die neueste Version von MySpeed herunter. Die aktuellste Version findest du [hier](https://github.com/gnmyt/myspeed/releases/latest). Lade die Datei "MySpeed-x.x.x-zip" von hier herunter. +2. Datei platzieren + Verschiebe die heruntergeladene Datei in einen Ordner deiner Wahl (z.B. `C:\MySpeed`). Benenne sie der Einfachheit halber in `myspeed.exe` um. -3. Datei entpacken - Entpacke nun die heruntergeladene Datei an einen Ort deiner Wahl. Am besten an einen Ort, den du später wiederfindest 🌚. - -4. Installation testen - Navigiere zuerst in den Ordner, wo du die Datei entpackt hast. Klicke in einen leeren Bereich dieses Ordners mit `Shift` + `Rechtsklick` und wähle "Öffnen in Powershell". - Füge nun diesen Befehl in das Konsolenfenster ein und drücke `Enter`: - ```sh - npm install - ``` - - ::: warning Schlägt die NPM-Installation fehl? - Möglicherweise gibt es keine vorkompilierten Module für dein System. In diesem Fall musst du die Module selbst kompilieren. - Folge diesen Schritten: - - 1. Python herunterladen - Um das Projekt zu "bauen", benötigst du auch Python. Du kannst es [hier](https://www.python.org/downloads/) herunterladen. - - 2. Visual Studio BuildTools herunterladen - Das Tool "node-gyp" erfordert auch Visual Studio BuildTools, um das Projekt erfolgreich zu "bauen". So funktioniert es: - 1. Klicke [auf diesen Link](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=BuildTools) und warte einen Moment, bis der Download startet. - 2. Öffne die Datei und klicke auf "Weiter". - 3. Wähle jetzt die optionale Workload "Desktopentwicklung mit C++" aus und bestätige deine Auswahl durch Klicken auf "Installieren". - 3. Führe `npm install` erneut aus. - ::: - Wenn alles erfolgreich durchläuft, hast du alles richtig gemacht! Herzlichen Glückwunsch. :) - Du kannst MySpeed jetzt mit diesem Befehl in Powershell starten. - -5. MySpeed starten +3. Installation testen + Öffne PowerShell oder die Eingabeaufforderung im Ordner, in dem du die Datei platziert hast (Shift + Rechtsklick > "PowerShell-Fenster hier öffnen"). + Führe die ausführbare Datei aus: ```powershell - $env:NODE_ENV="production"; node server + .\myspeed.exe ``` + Wenn alles erfolgreich durchläuft, hast du alles richtig gemacht! Herzlichen Glückwunsch. :) + MySpeed ist jetzt auf Port 5216 verfügbar. Öffne http://localhost:5216 in deinem Browser. + ## Automatischer Start mit dem Autostart-Ordner in Windows 1. Autostart-Ordner in Windows öffnen Drücke gleichzeitig die Tasten (`Windows` + `R`) auf deiner Tastatur, bis ein Ausführen-Dialog erscheint. Gib dann `%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup` ein und drücke `Enter`. -2. Autostart-Datei erstellen - Stelle sicher, dass du [Dateinamenerweiterungen aktiviert](https://support.microsoft.com/en-us/windows/common-file-name-extensions-in-windows-da4a4430-8e76-89c5-59f7-1cdbbc75cb01) hast. Wenn das erledigt ist, erstelle ein neues Dokument mit `Rechtsklick` > `Neu` > `Textdokument`. - Drücke dann `Strg` + `A` und benenne es als "MySpeed.bat". Drücke dann zweimal `Enter`. +2. Verknüpfung erstellen + Klicke mit der rechten Maustaste in den Ordner und wähle `Neu` > `Verknüpfung`. Navigiere zu deiner `myspeed.exe`-Datei und erstelle die Verknüpfung. -3. Inhalt erstellen - Klicke mit `Rechtsklick` und wähle `Bearbeiten`. Füge dann den folgenden Code ein und passe den Installationsort an: - ```batch - @echo off - cd "C:\Users\Desktop\MySpeed" - set NODE_ENV=production - node server +3. Wenn alles funktioniert hat, sollte MySpeed jetzt automatisch starten, wenn das System hochfährt. + +## Alternative: Installation aus dem Quellcode +::: warning Achtung +Dieser Prozess installiert die neueste Entwicklungsversion von MySpeed. Fehler können auftreten. +::: + +1. Deno herunterladen + Um MySpeed aus dem Quellcode zu bauen, benötigst du **Deno**. Öffne PowerShell und führe aus: + ```powershell + irm https://deno.land/install.ps1 | iex ``` -4. Wenn alles funktioniert hat, sollte MySpeed jetzt automatisch starten, wenn das System hochfährt. +2. MySpeed-Quellcode herunterladen + Klone das Repository oder lade den Quellcode von [GitHub](https://github.com/gnmyt/myspeed) herunter. + +3. Abhängigkeiten installieren und bauen + ```powershell + deno install + cd client && npm install && npm run build && cd .. && move client\build build + ``` + +4. MySpeed starten + ```powershell + deno run --allow-all server/index.js + ``` diff --git a/docs/de/troubleshooting.md b/docs/de/troubleshooting.md index 8fab69ee..66a78831 100644 --- a/docs/de/troubleshooting.md +++ b/docs/de/troubleshooting.md @@ -10,22 +10,15 @@ gelöst sein. :) Um die Berechtigungen zu setzen, gib den Befehl `chmod 700 /opt/myspeed` ein. (Ersetze /opt/myspeed mit deinem Installationsort) -2. Build Essentials Installieren - Es ist aktuell möglich, dass der Fehler auftritt, weil das Paket `build-essential` nicht installiert ist. Installiere - es ganz einfach mit dem Befehl `sudo apt-get install build-essential` nach. - -3. Führe eine Neuinstallation der Module aus - Gib zuerst den Befehl `rm -R node_modules` im Installationsordner ein, um die Module zu löschen und installiere sie - dann mit `npm install` nach. +2. Führe eine Neuinstallation der Abhängigkeiten aus + Führe `deno cache --reload server/index.js` im Installationsordner aus, um alle Abhängigkeiten neu zu laden. ::: ::: danger Diese MySpeed-Instanz befindet sich aktuell im Entwicklungsmodus -Das ist nicht wirklich ein Fehler, lediglich eine Sicherung um das Tool nur in Produktionsumgebungen verwenden zu -können. Setze dazu die Umgebungsvariable `NODE_ENV` auf den Wert `production`. - -Unter Linux erreichst du das mit `export NODE_ENV=production` und unter Windows in der Powershell -mit `$env:NODE_ENV="production"`. - -Lies dir auch mal den [Guide zur 24/7 Installation](setup/linux) durch, wenn du planst, MySpeed im Hintergrund laufen -zu lassen und beim Systemstart automatisch hochzufahren. +Das bedeutet, dass der Client-Build-Ordner nicht gefunden wurde. Wenn du aus dem Quellcode installiert hast, stelle sicher, dass du zuerst den Client baust: +```sh +cd client && npm install && npm run build && cd .. && mv client/build . +``` +Alternativ kannst du ein fertiges Release herunterladen oder Docker verwenden. +Lies dir auch mal den [Guide zur 24/7 Installation](setup/linux) durch, wenn du planst, MySpeed im Hintergrund laufen zu lassen und beim Systemstart automatisch hochzufahren. ::: \ No newline at end of file diff --git a/docs/en/setup/linux.md b/docs/en/setup/linux.md index ac89383b..713def1e 100644 --- a/docs/en/setup/linux.md +++ b/docs/en/setup/linux.md @@ -4,7 +4,7 @@ Here the setup for Linux is described. MySpeed can be installed in several ways. ## Installation with Docker ::: tip Help - You don't know how to install Docker? Then check out [this guide](https://docs.docker.com/engine/install/#server) +You don't know how to install Docker? Then check out [this guide](https://docs.docker.com/engine/install/#server) ::: @@ -56,30 +56,32 @@ curl -sSL https://raw.githubusercontent.com/gnmyt/myspeed/development/scripts/un ## Manual installation ```sh -sudo apt-get install wget curl unzip -y #(1) +sudo apt-get install wget curl -y #(1) -# You only need to do this if you don't have NodeJS installed yet -curl -sSL https://deb.nodesource.com/setup_18.x | bash -sudo apt-get install nodejs -y #(2) +mkdir /opt/myspeed && cd /opt/myspeed #(2) -mkdir /opt/myspeed && cd /opt/myspeed #(3) +# Detect architecture and download the appropriate binary +ARCH=$(uname -m) +if [ "$ARCH" = "x86_64" ]; then + ARCH="x64" +elif [ "$ARCH" = "aarch64" ]; then + ARCH="arm64" +fi -wget $(curl -s https://api.github.com/repos/gnmyt/myspeed/releases/latest | grep browser_download_url | cut -d '"' -f 4) #(4) +wget $(curl -s https://api.github.com/repos/gnmyt/myspeed/releases/latest \ + | grep "browser_download_url.*linux-${ARCH}" | cut -d '"' -f 4) \ + -O myspeed #(3) -unzip MySpeed-*.zip && rm MySpeed-*.zip #(5) +chmod +x myspeed #(4) -npm install #(6) - -NODE_ENV=production node server #(7) +./myspeed #(5) ``` 1. Here you install all necessary packages to install the project. -2. This step installs the latest version of NodeJS. -3. Now create the folder where you want to install MySpeed. In this case it is the folder `/opt/myspeed`. -4. Now install the newest version of MySpeed. -5. Now unzip the file you just downloaded (then you can delete it) -6. Now install all dependencies. -7. Now MySpeed is started. MySpeed is now available on port 5216. +2. Now create the folder where you want to install MySpeed. In this case it is the folder `/opt/myspeed`. +3. Download the pre-compiled binary for your architecture (x64 or arm64). +4. Make the binary executable. +5. Now MySpeed is started. MySpeed is now available on port 5216. If you plan to run MySpeed in the background, see the guide below. ## Install MySpeed from the source code @@ -89,30 +91,31 @@ This process installs the latest development version of MySpeed. Errors may occu ::: ```sh -sudo apt-get install git curl -y #(1) +sudo apt-get install git curl npm -y #(1) -# You only need to run this if you don't have NodeJS installed yet -curl -sSL https://deb.nodesource.com/setup_18.x | bash -sudo apt-get install nodejs -y #(2) +# Install Deno +curl -fsSL https://deno.land/install.sh | sh +export DENO_INSTALL="$HOME/.deno" +export PATH="$DENO_INSTALL/bin:$PATH" #(2) mkdir /opt/myspeed && cd /opt/myspeed #(3) git clone https://github.com/gnmyt/myspeed.git . #(4) -npm install #(5) +deno install #(5) cd client && npm install && npm run build && cd .. && mv client/build . #(6) -NODE_ENV=production node server #(7) +deno run --allow-all server/index.js #(7) ``` -1. here you install all necessary packages to install the project. -2. this step installs the latest version of NodeJS. -3. now create the folder where you want to install MySpeed. In this case this is the folder `/opt/myspeed`. -4. clone the MySpeed repository to get access to the code. -5. now install all dependencies of the server. -6. now compile the interface of MySpeed and move it to the folder where MySpeed can read it. -7. now start MySpeed. MySpeed is now accessible on port 5216. +1. Here you install all necessary packages to install the project. +2. This step installs the Deno runtime. +3. Now create the folder where you want to install MySpeed. In this case this is the folder `/opt/myspeed`. +4. Clone the MySpeed repository to get access to the code. +5. Now install all dependencies of the server. +6. Now compile the interface of MySpeed and move it to the folder where MySpeed can read it. +7. Now start MySpeed. MySpeed is now accessible on port 5216. If you plan to run MySpeed in the background, see the guide below. @@ -136,11 +139,10 @@ Installing as a system service is not even that hard. In this case we use `syste [Service] Type=simple - ExecStart=/usr/bin/node server + ExecStart=/opt/myspeed/myspeed Restart=always # \/ It is strongly recommended to create your own user here User=root - Environment=NODE_ENV=production # \/ Specify your installation location here WorkingDirectory=/opt/myspeed @@ -154,7 +156,7 @@ Installing as a system service is not even that hard. In this case we use `syste ```sh [nano] Press `CTRL` + `X`, then press `Y` and press `Enter` to save the file and exit the editor. ``` - + ```sh [vim] Press `ESC`, then type `:wq` and press `Enter` to save the file and exit the editor. ``` diff --git a/docs/en/setup/windows.md b/docs/en/setup/windows.md index 2869f213..44495bad 100644 --- a/docs/en/setup/windows.md +++ b/docs/en/setup/windows.md @@ -3,60 +3,53 @@ Here we describe the setup for Windows. ## Installing MySpeed -1. Download NodeJS - To use MySpeed, you first need **NodeJS**. You can easily download the installer [here](https://nodejs.org/en/download/). Recommended is the LTS version 18 of NodeJS. +1. Download MySpeed + Download the latest version of MySpeed from the [releases page](https://github.com/gnmyt/myspeed/releases/latest). Download the file `myspeed-windows-x64.exe`. -2. Download MySpeed - Now download the latest version of MySpeed. You can find the latest release [here](https://github.com/gnmyt/myspeed/releases/latest). Download the file "MySpeed-x.x.x-zip" from here. +2. Place the file + Move the downloaded file to a folder of your choice (e.g., `C:\MySpeed`). Rename it to `myspeed.exe` for convenience. -3. Unpack the file - Now unzip the downloaded file to a place of your choice. Preferably to a place that you know afterwards 🌚. - -4. Test your installation - First navigate to the folder where you unzipped the file. Click with `Shift` + `Right click` into an empty area in this folder and select "Open in Powershell". - Now paste this command into the console window and press `Enter`: - ```sh - npm install - ``` - - ::: warning Does the NPM installation fail? - There is a possibility that there are no precompiled modules for your system. In this case you have to compile the modules yourself. - Follow these steps: - - 1. Download Python - To "build" the project, you also need to download Python. You can do this [here](https://www.python.org/downloads/). - - 2. Download the Visual Studio BuildTools - The "node-gyp" tool also requires Visual Studio's BuildTools to successfully "build" the project. Here's how it works: - 1. click [on this link](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=BuildTools) and wait a short time until the download starts - 2. open the file and click "continue - 3. now select the optional workload "Desktop development with C++" and confirm your selection by clicking on "Install - 3. run `npm install` again - ::: - If everything runs successfully, you did everything right! Congratulations. :) - You can now start MySpeed with this command in your Powershell. - -5. Start MySpeed +3. Test your installation + Open PowerShell or Command Prompt in the folder where you placed the file (Shift + Right-click > "Open PowerShell window here"). + Run the executable: ```powershell - $env:NODE_ENV="production"; node server + .\myspeed.exe ``` + If everything runs successfully, you did everything right! Congratulations. :) + MySpeed is now available on port 5216. Open http://localhost:5216 in your browser. + ## Automatic startup using the autostart folder in Windows 1. Open the autostart folder in windows Press both keys (`Windows` + `R`) simultaneously on your keyboard until a Run dialog appears. Then type `%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup` and press `Enter`. -2. Create the autostart file - First make sure you have [filename extensions active](https://support.microsoft.com/en-us/windows/common-file-name-extensions-in-windows-da4a4430-8e76-89c5-59f7-1cdbbc75cb01). Once this is done. Create a new document with `Right click` > `New` > `Text document`. - Then press `CTRL` + `A` and write as filename "MySpeed.bat". Then press `Enter` 2 times +2. Create a shortcut + Right-click in the folder and select `New` > `Shortcut`. Browse to your `myspeed.exe` file and create the shortcut. -3. Create the content - Right click and select `Edit`. Then paste the code from below and adjust your installation location. - ```batch - @echo off - cd "C:\Users\Desktop\MySpeed" - set NODE_ENV=production - node server +3. If everything worked, MySpeed should now start automatically when the system is started. + +## Alternative: Install from source code +::: warning Attention +This process installs the latest development version of MySpeed. Errors may occur. +::: + +1. Download Deno + To build MySpeed from source, you need **Deno**. Open PowerShell and run: + ```powershell + irm https://deno.land/install.ps1 | iex ``` -4. If everything worked, MySpeed should now start automatically when the system is started. \ No newline at end of file +2. Download MySpeed source + Clone the repository or download the source code from [GitHub](https://github.com/gnmyt/myspeed). + +3. Install dependencies and build + ```powershell + deno install + cd client && npm install && npm run build && cd .. && move client\build build + ``` + +4. Start MySpeed + ```powershell + deno run --allow-all server/index.js + ``` \ No newline at end of file diff --git a/docs/en/troubleshooting.md b/docs/en/troubleshooting.md index d1c3a365..15340877 100644 --- a/docs/en/troubleshooting.md +++ b/docs/en/troubleshooting.md @@ -8,16 +8,15 @@ There can be several solutions to this error. Just work through all possibilitie 1. **Set the required permissions** To set the permissions, enter the command `chmod 700 /opt/myspeed`. (Replace /opt/myspeed with your installation location). -2. **Install the build essentials** - It is currently possible that the error occurs because the `build-essential` package is not installed. Simply reinstall it with the command `sudo apt-get install build-essential`. - -3. **Perform a new installation of the modules** - First, enter the command `rm -R node_modules` in the installation folder to delete the modules and then reinstall them with `npm install`. +2. **Perform a new installation of the dependencies** + First, run `deno cache --reload server/index.js` in the installation folder to refresh all dependencies. ::: ::: danger This MySpeed instance is currently in development mode -This is not really an error, just a backup to use the tool only in production environments. -Set the environment variable `NODE_ENV` to the value `production`. -On Linux, you can do this with `export NODE_ENV=production` and on Windows in the PowerShell with `$env:NODE_ENV="production"`. +This means the client build folder was not found. If you installed from source, make sure to build the client first: +```sh +cd client && npm install && npm run build && cd .. && mv client/build . +``` +Alternatively, download a pre-built release or use Docker. Also, read the [guide for 24/7 installation](setup/linux) if you plan to run MySpeed in the background and start it automatically at system startup. ::: \ No newline at end of file diff --git a/scripts/install.sh b/scripts/install.sh index 9773a917..e9ea3657 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -24,17 +24,29 @@ if [ $EUID -ne 0 ]; then exit fi +ARCH=$(uname -m) +case "$ARCH" in + x86_64) + BINARY_NAME="MySpeed-linux-x64" + ;; + aarch64|arm64) + BINARY_NAME="MySpeed-linux-arm64" + ;; + *) + echo -e "$RED✗ Unsupported architecture: $ARCH" + echo -e "$NORMAL MySpeed only supports x64 and arm64 architectures." + exit 1 + ;; +esac + echo -e "$GREEN ---------$BLUE Automatic Installation$GREEN ---------" echo -e "$BLUE MySpeed$YELLOW is now being installed." -if [ "$1" == "--beta" ]; then - echo -e "$YELLOW Version:$BLUE MySpeed$PURPLE Beta" -else - echo -e "$YELLOW Version:$BLUE MySpeed Release" -fi +echo -e "$YELLOW Version:$BLUE MySpeed Release" +echo -e "$YELLOW Architecture:$BLUE $ARCH ($BINARY_NAME)" echo -e "$YELLOW Location:$BLUE $INSTALLATION_PATH" echo -e "$GREEN Installation will start in 5 seconds..." echo -e "$GREEN ----------------------------------------------" -sleep 10 +sleep 5 clear if [ -d "$INSTALLATION_PATH" ]; then @@ -50,13 +62,12 @@ if [ -d "$INSTALLATION_PATH" ]; then sleep 5 fi -if command -v systemctl &> /dev/null && systemctl --all --type service | grep -n "myspeed.service"; then +if command -v systemctl &> /dev/null && systemctl --all --type service | grep -q "myspeed.service"; then clear echo -e "$YELLOWℹ MySpeed Service is being stopped..." systemctl stop myspeed fi - clear echo -e "" echo -e "$BLUE-$NORMAL-$BLUE-$NORMAL-$BLUE-$NORMAL-$BLUE-$NORMAL-$BLUE-$NORMAL-$BLUE-$NORMAL-$BLUE-$NORMAL-$BLUE-$NORMAL-$BLUE-$NORMAL-" @@ -70,7 +81,7 @@ apt-get update -y clear echo -e "$GREENℹ Info:$NORMAL Installation is now being prepared. This may take a moment..." -sleep 5 +sleep 3 function check() { clear @@ -89,83 +100,40 @@ function check() { } check "wget" -check "unzip" check "curl" clear + echo -e "$BLUE🔎 STATUS MESSAGE" -echo -e "$NORMAL Checking if node is present..." -if ! command -v node &> /dev/null -then - echo -e "$YELLOWℹ \"node\" is not installed.$NORMAL Installation will proceed..." - sleep 2 - clear - echo -e "$PURPLEℹ Downloading...$NORMAL" - curl -sSL https://deb.nodesource.com/setup_20.x | bash - clear - echo -e "$PURPLEℹ Installing...$NORMAL" - apt-get install nodejs -y +echo -e "$NORMAL Fetching latest release information..." +RELEASE_URL=$(curl -s https://api.github.com/repos/gnmyt/myspeed/releases/latest | grep "browser_download_url.*$BINARY_NAME" | cut -d '"' -f 4) + +if [ -z "$RELEASE_URL" ]; then + echo -e "$RED✗ Could not find release for $BINARY_NAME" + exit 1 fi +echo -e "$GREEN✓ Found release:$NORMAL $RELEASE_URL" +sleep 2 + clear - -if [ "$1" == "--beta" ]; then - RELEASE_URL=https://github.com/gnmyt/myspeed/archive/refs/heads/development.zip -else - RELEASE_URL=$(curl -s https://api.github.com/repos/gnmyt/myspeed/releases/latest | grep browser_download_url | cut -d '"' -f 4) -fi - - echo -e "$GREEN✓ Preparation completed:$NORMAL Installation of MySpeed will now commence..." sleep 3 clear -if [ ! -d "$INSTALLATION_PATH" ] -then - clear +if [ ! -d "$INSTALLATION_PATH" ]; then echo -e "$BLUEℹ Info: $NORMAL MySpeed will be installed under directory $INSTALLATION_PATH. Creating the folder now." sleep 2 - mkdir "$INSTALLATION_PATH" + mkdir -p "$INSTALLATION_PATH" fi cd "$INSTALLATION_PATH" clear -echo -e "$BLUEℹ Info: $NORMAL The current MySpeed instance is being downloaded. Please wait..." +echo -e "$BLUEℹ Info: $NORMAL Downloading MySpeed binary. Please wait..." sleep 2 -wget "$RELEASE_URL" - -echo -e "$BLUEℹ Info: $NORMAL Download completed. Unpacking..." -sleep 2 -if [ "$1" == "--beta" ]; then - unzip -qo development.zip - rm -R server client docs cli - mv myspeed-*/* . - rm development.zip - rm -R myspeed-development -else - unzip -qo MySpeed*.zip - rm MySpeed-*.zip -fi - - -clear -echo -e "$BLUEℹ Info: $NORMAL Necessary dependencies are being installed..." -sleep 2 -rm -rf "$INSTALLATION_PATH/node_modules" -npm install --force - -if [ "$1" == "--beta" ]; then - clear - echo -e "$BLUEℹ Info: $NORMAL Web interface is being compiled..." - sleep 2 - cd client && npm install -- - -force - cd .. && npm run build - cp -r client/build . - rm -rf client/build -fi +wget -O myspeed "$RELEASE_URL" +chmod +x myspeed clear echo -e "$BLUE🔎 STATUS MESSAGE" @@ -173,42 +141,42 @@ echo -e "$NORMAL Registering MySpeed as a background service..." echo -e "" echo -e "" sleep 2 -if command -v systemctl &> /dev/null && ! systemctl --all --type service | grep -n "myspeed.service"; then - cat << EOF >> /etc/systemd/system/myspeed.service - [Unit] - Description=MySpeed - After=network.target - [Service] - Type=simple - ExecStart=/usr/bin/node server - Restart=always - User=root - Environment=NODE_ENV=production - WorkingDirectory=$INSTALLATION_PATH +if command -v systemctl &> /dev/null; then + cat << EOF > /etc/systemd/system/myspeed.service +[Unit] +Description=MySpeed +After=network.target - [Install] - WantedBy=multi-user.target +[Service] +Type=simple +ExecStart=$INSTALLATION_PATH/myspeed +Restart=always +User=root +WorkingDirectory=$INSTALLATION_PATH + +[Install] +WantedBy=multi-user.target EOF systemctl daemon-reload - echo -e "$NORMALℹ MySpeed will be added to autostart..." - sleep 1 - systemctl enable myspeed + + if ! systemctl is-enabled myspeed &> /dev/null; then + echo -e "$NORMALℹ MySpeed will be added to autostart..." + sleep 1 + systemctl enable myspeed + fi + echo -e "$NORMALℹ MySpeed service is starting..." sleep 1 - systemctl start myspeed + systemctl restart myspeed fi clear if ! command -v systemctl &> /dev/null; then echo -e "$YELLOW⚠ Warning: $NORMAL Your Linux system currently does not support starting MySpeed in the background. \"systemd\" is required for this purpose." - echo -e "$BLUEℹ Info: $NORMAL If you have installed \"systemd\", you can restart the installation. It will be set up automatically." + echo -e "$BLUEℹ Info: $NORMAL You can start MySpeed manually by running: $INSTALLATION_PATH/myspeed" sleep 5 -else - echo -e "$GREENℹ MySpeed is being restarted..." - sleep 2 - systemctl restart myspeed fi clear @@ -216,6 +184,6 @@ echo -e "$GREEN-$NORMAL-$GREEN-$NORMAL-$GREEN-$NORMAL-$GREEN-$NORMAL-$GREEN-$NOR echo -e "$GREEN✓ Installation completed: $NORMAL MySpeed has been installed under $INSTALLATION_PATH." echo -e "You can access the web interface in your browser at$BLUE http://$(curl -s ifconfig.me):5216$NORMAL." if [ -d "$INSTALLATION_PATH" ]; then - echo -e "$BLUEℹ Info:$NORMAL If the update was not successful, please restart MySpeed:$BLUE systemctl restart myspeed" + echo -e "$BLUEℹ Info:$NORMAL To restart MySpeed:$BLUE systemctl restart myspeed" fi echo -e "$GREEN-$NORMAL-$GREEN-$NORMAL-$GREEN-$NORMAL-$GREEN-$NORMAL-$GREEN-$NORMAL-$GREEN-$NORMAL-$GREEN-$NORMAL-$GREEN-$NORMAL-$GREEN-$NORMAL-" diff --git a/server/templates/env.html b/server/templates/env.html index ba6cfae2..01c2d431 100644 --- a/server/templates/env.html +++ b/server/templates/env.html @@ -82,7 +82,7 @@
Your MySpeed instance is currently in development mode.
-Please change the NODE_ENV variable to PRODUCTION,
Please build the client or use a production binary,
if this is a production environment or go to the development
environment.