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

1 Add Linux Installer script #219

Open
wants to merge 7 commits into
base: develop
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
674 changes: 674 additions & 0 deletions docs/Installation-Script/LICENSE

Large diffs are not rendered by default.

54 changes: 54 additions & 0 deletions docs/Installation-Script/README_EN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[![forthebadge cc-by](https://licensebuttons.net/l/by-nc-sa/4.0/88x31.png)](https://creativecommons.org/licenses/by/4.0) [![](https://img.shields.io/badge/Discord-7289DA?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/tyJX8dx)
![Debian](https://img.shields.io/badge/Debian-D70A53?style=for-the-badge&logo=debian&logoColor=white)![Ubuntu](https://img.shields.io/badge/Ubuntu-E95420?style=for-the-badge&logo=ubuntu&logoColor=white)

## EasyInstall Unitystation-Hub For Gnu_linux

### Languages used

Shell .SH

-------------

### Project description

Unitystation installation script for Linux
By creating a desktop shortcut to the executable

-------------
### Credit, participant, organisation

Managed by the Unionrolistes development team
List of contributors Credit.md
![Licence.md](https://github.com/Unitystation-fork/Unitystation-Hub/blob/main/LICENSE)

-------------

### Project goal / target audience

Gnu_linux user

-------------
### Installation
To use it, please copy Unitystation.sh locally and run it as superuser/root.

Open terminal
```shell
wget https://raw.githubusercontent.com/Unitystation-fork/Unitystation-Others/main/Installation-Script/UnityStationInstaller.sh -O ~/UnityStationInstaller.sh; sudo chmod 750 ~/UnityStationInstaller.sh; sudo ~/UnityStationInstaller.sh
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are still pointing to the other repo here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please make a branch for me to write in?
I could then have the right links (adding hand)

that's why i wanted to make a submodule, easier to upload without modifying the documentation (and i'm glad i learned that)

```
*For no debian user, please remplacer "sudo" by your own command*


-------------
### Upgrading

Once installed, the hub will update to the latest build.
If the Hub version changes, you will need to run this shell script again.

---
### Uninstall
please copy past this on your terminal Open terminal
```shell
wget -O ~/UnitystationUnInstaller.sh https://raw.githubusercontent.com/Unitystation-fork/Unitystation-Others/main/Installation-Script/UnitystationUnInstaller.sh ; sudo chmod 750 ~/UnityStationUnInstaller.sh; sudo ~/UnityStationUnInstaller.sh
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are also giving 750 perms to the wrong script

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no it's the Un-installation script
but I need to edit it to add the folder ~/.config/unity3d/Unitystation

to make the uninstall command as complete as possible.

```

-------------
53 changes: 53 additions & 0 deletions docs/Installation-Script/README_FR.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
[![forthebadge cc-by](https://licensebuttons.net/l/by-nc-sa/4.0/88x31.png)](https://creativecommons.org/licenses/by/4.0) [![](https://img.shields.io/badge/Discord-7289DA?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/tyJX8dx)
![Debian](https://img.shields.io/badge/Debian-D70A53?style=for-the-badge&logo=debian&logoColor=white)![Ubuntu](https://img.shields.io/badge/Ubuntu-E95420?style=for-the-badge&logo=ubuntu&logoColor=white)

## EasyInstall Unitystation-Hub For Gnu_linux

### Languages utilisés

Shell .SH

-------------

### Description du projet

Script d'installation pour Linux d'Unitystation
En créant un raccourci bureau de l'executable

-------------
### Credit , participant, organisation

Géré par l'équipe de développement de Unionrolistes
Liste des contributeurs Credit.md
![Licence.md](https://github.com/Unitystation-fork/Unitystation-Hub/blob/main/LICENSE)

-------------

### But du projet / public cible

Utilisateur Gnu_linux

-------------
### Installation
Pour l'utiliser, veuillez copier Unitystation.sh localement et l'exécuter en tant que super utilisateur/racine.

Open terminal
```shell
wget https://raw.githubusercontent.com/Unitystation-fork/Unitystation-Others/main/Installation-Script/UnityStationInstaller.sh -O ~/UnityStationInstaller.sh ; sudo chmod 750 ~/UnityStationInstaller.sh ; sudo ~/UnityStationInstaller.sh
```

-------------
### Mise à jour

Une fois installé, le hub mettra à jour vers le dernier build.
Si la version du Hub change, il faudra de nouveau executer ce script shell.

---
### Uninstall
merci de copier coller le texte suivant dans votre terminal
```shell
wget -O ~/UnitystationUnInstaller.sh https://raw.githubusercontent.com/Unitystation-fork/Unitystation-Others/main/Installation-Script/UnitystationUnInstaller.sh ; sudo chmod 750 ~/UnityStationUnInstaller.sh; sudo ~/UnityStationUnInstaller.sh
```


-------------
90 changes: 90 additions & 0 deletions docs/Installation-Script/UnityStationInstaller.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#!/bin/bash

# Fonction de gestion des erreurs
function handle_error {
echo "Une erreur s'est produite. Sortie du script."
exit 1
}

# Fonction pour obtenir la dernière version depuis l'API GitHub
function get_latest_version {
local repo_url="https://api.github.com/repos/unitystation/stationhub/releases/latest"
local version=$(wget -qO - "$repo_url" | grep -oP '"tag_name": "\K(.*)(?=")')
echo "$version"
}

latest_version=$(get_latest_version)

while true; do
echo "Choose your distribution :"
echo "1 - Ubuntu/Debian"
echo "2 - Arch-Linux"
echo "3 - Fedora"
echo "4 - OpenSUSE"
echo "5 - CentOS"
echo "6 - Gentoo"
read -p "Enter the number of your choice : " choice

case $choice in
1)
# Commandes pour Ubuntu
apt update
apt full-upgrade
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do not upgrade the user's system.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as I said earlier, there is no -y
so the user is free to do Y/N if the suggested updates don't suit, it doesn't block the script.

it's more for "the sake of ", to remind the user to do his updates
don't forget that most users are lazy

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's more for "the sake of ", to remind the user to do his updates

this is an awful justification. This script doesn't need the user to upgrade their system, do not upgrade someone's computer because you think it is best for them. Respect the user.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping your system up to date is precisely the first recommendation you should make to a user, especially if they're too lazy to do it.

and i've created this script for people who want everything to work "all-in-one", the flemmes are a parameter to take into account.

you don't seem convinced?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole point of a script like this is to do one thing and one thing only, install stationhub.

We don't install firefox automatically because some people are too lazy or force them to install Arch Linux because they're too stupid, because it is not our concern what the user does with their PC and we shouldn't be changing anything about it just because we think its for the best.

apt install -y wget p7zip || handle_error
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try to get rid of these dependencies.

All linux distros should already have installed unzip so you can use that. Same with curl instead of wget

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

simple tools for simple use
curl is not installed by default on some distribution,
plus wget is perfectly suited to this use, download a script,

Copy link
Member

@corp-0 corp-0 Oct 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# use curl or wget, depending on which one we find
curl_or_wget=$(if hash curl 2>/dev/null; then echo "curl -s"; elif hash wget 2>/dev/null; then echo "wget -qO-"; fi);

if [ -z "$curl_or_wget" ]; then
        echo "Neither curl nor wget found. Installing wget." >&2
        //install wget here
fi

x=$($curl_or_wget "$url")

see if either is installed in the system before installing the one you prefer.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I see, a bit of a twisted approach but why not.

and why do you insist on using curl?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had the impression that curl is the most common found in most linux systems. I read now that both are equally common, so I think the best option is to check if the system has either before installing wget

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't basing this reflection on that.

curl being a very powerful and versatile command, it often frightens people, and rightly so.

wget is all about downloading a file.
the most powerful thing you can do with it is resume an interrupted download.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know where you got that "it frightens people" thing, but I managed to get curl working pretty quick in my own installer script and the best part is that we didn't need any external dependencies.

wget is not available on all platforms or distros, and like I've mentioned; this shell script literally doesn't need an entirely new library for it to work, especially one that can affect user security.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wget, affected the security of user :D best joke ever ...

;;

2)
# Commandes pour Arch Linux
pacman -Syu --noconfirm
pacman -S --noconfirm wget p7zip || handle_error
;;

3)
# Commandes pour Fedora
dnf update -y
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You said above:

as I said earlier, there is no -y
so the user is free to do Y/N if the suggested updates don't suit, it doesn't block the script.

However this DOES force a user to update their system, please do not do this.

dnf install -y wget p7zip || handle_error
;;

4)
# Commandes pour openSUSE
zypper refresh
zypper install -y wget p7zip || handle_error
;;

5)
# Commandes pour CentOS
yum update -y
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

yum install -y wget p7zip || handle_error
;;

6)
# Commandes pour Gentoo
emerge --sync
emerge -av wget p7zip || handle_error
;;

*)
echo "Invalid choice. Please try again."
;;
esac

if [ $choice -ge 1 ] && [ $choice -le 6 ]; then
break # Sort de la boucle si le choix est valide
fi
done

# Téléchargement des fichiers avec wget
mkdir -p /usr/share/Unitystation/
cd /usr/share/Unitystation/
latest_url="https://github.com/unitystation/stationhub/releases/download/$latest_version/lin$latest_version.zip"
wget -O "/usr/share/Unitystation/lin-latest.zip" "$latest_url"
wget -O /usr/share/Unitystation/unityico.png https://raw.githubusercontent.com/unitystation/stationhub/develop/UnitystationLauncher/Assets/unityico.png || handle_error
wget -O /usr/share/applications/Stationhub.desktop https://raw.githubusercontent.com/Unitystation-fork/Unitystation-Others/main/Installation-Script/Unitystation.desktop || handle_error

# Extraction du fichier zip
unzip /usr/share/Unitystation/lin-latest.zip || handle_error
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like you are using unzip here, so what do you need p7zip for?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

of memory when you want to use archive extration via a script (for example sh or py) you need p7zip

but I could be mistaken

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

7zip and unzip are both valid, some distros for some reason dont' come with 7zip

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in that case, the script would also have to find if the system has either and use that, like I suggested for curl and wget

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also you can do this to check for the existence of 7zip:

echo "Looking for 7zip.."
if ! command -v 7z &> /dev/null
then
    echo "7zip could not be found. Extract files manually."
    case $OS in
    'Linux')
        xdg-open https://7-zip.org/
        ;;
    'Windows')
        msg "%username%" 7zip could not be found. Extract files manually.
        start https://7-zip.org/
        ;;
    'Mac') 
        open https://7-zip.org/
        ;;
    'AIX') ;;
    *) ;;
    esac
    exit 1
fi

if ! command -v 7z &> /dev/null works on all platforms and distros + it checks if 7z is available, then it does things based on the user's OS; which can also be used to check if unzip is available as well and fall back to it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your script is crap and you know it.
opening a terminal and then opening a web page, did you miss the lessons on intuitiveness and the 3-click rule or what? does na notion of "user-friendly" mean anything to you?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mad lol

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mad lol

eventually,
but you did create a script because you wanted to do what I did, as if you wanted my approval and recognition, it's a shame not to have your own ideas and have to copy others because you have no talent.

In short, gilles and bod have given me recommendations as soon as I have a bit of time, and I'm going to redo it.

However, I have to thank you, so you motivated me to improve my script to prove you wrong, =)

rm -rfv /usr/share/Unitystation/lin-latest.zip || handle_error
chmod -R 777 /usr/share/Unitystation/StationHub || handle_error

echo "Installation done."
exit 1
10 changes: 10 additions & 0 deletions docs/Installation-Script/Unitystation.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Desktop Entry]
Name=UnityStation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a desktop entry for StationHub, not for Unitystation.

GenericName=UnityStation
Exec=/usr/share/Unitystation/StationHub
Type=Application
Categories=Game
Comment=UnityStation- Connect to Unitystation servers & manage your installs.
Comment[fr_FR]=UnityStation - Connectez-vous aux serveurs Unitystation & gérez vos installations.
Icon=/usr/share/Unitystation/unityico.png
Path=/usr/share/Unitystation/
49 changes: 49 additions & 0 deletions docs/Installation-Script/UnitystationUnInstaller.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash

# Fonction pour afficher un message de confirmation
function confirm_delete {
echo "Voulez-vous vraiment supprimer le jeu Unitystation ?"
read -p "Tapez 'y' pour confirmer ou 'n' pour annuler : " response
if [[ $response == "y" ]]; then
return 0
else
return 1
fi
}

# Fonction pour supprimer uniquement le dossier contenant le Launcher et le raccourci du bureau
function delete_launcher_and_shortcut {
rm -rfv /usr/share/Unitystation
rm -fv /usr/share/applications/Stationhub.desktop
}

# Fonction pour supprimer TOUS (jeux + raccourcis + données du jeu)
function delete_all {
rm -rfv ~/local/share/StationHub
rm -rfv /usr/share/Unitystation
rm -fv /usr/share/applications/Stationhub.desktop
}

# Afficher un message de confirmation
confirm_delete
if [ $? -eq 0 ]; then
echo "Choisissez une option :"
echo "1 - Supprimer uniquement le dossier contenant le Launcher et le raccourci du bureau"
echo "2 - Supprimer TOUS (jeux + raccourcis + données du jeu)"
read -p "Entrez le numéro de votre choix : " choice

case $choice in
1)
delete_launcher_and_shortcut
echo "Suppression du Launcher et du raccourci terminée."
;;
2)
delete_all
echo "Suppression complète terminée."
;;
*)
echo "Choix invalide. Aucune action effectuée."
;;
esac
fi
exit 1
38 changes: 38 additions & 0 deletions docs/Installation-Script/changelogs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Version 0.0.4
Date: 11/10/2023 - 14h
Dev: Fr-Dae

Fix:

- Multi OS manage
- fr/en instruction
---------------------------------------------------------------------------------------------
Version 0.0.3
Date: 11/10/2023 - 8h
Dev: Fr-Dae

Fix:

- Sources of the installer for Linux dekstop

---------------------------------------------------------------------------------------------

Version 0.0.2
Date: 25/02/2022 - 19h
Dev: Peulleieo

Added:

- Sources of the installer for Linux
Ajout:

- Sources de l'installateur pour Linux

---------------------------------------------------------------------------------------------

Version 0.0.1
Date: 25/02/2022 - 16h

Ajout:

- Création du github par Dae