optimisations
This commit is contained in:
119
launcher.sh
Normal file
119
launcher.sh
Normal file
@@ -0,0 +1,119 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
VERSION=1.1
|
||||
|
||||
#On verifie qu'il y a assez de place pour installer minecraft en plus de garder un peu de place pour le reste
|
||||
#STOCKAGE
|
||||
max_storage=2147483648 #2Go, le stockage max de l'afs, je deconseille fortement d'augmenter cette valeur !
|
||||
minecraft_storage=943718400 #900Mo, j'utilise cette valeur si vous voulez jouer avec un modpack qui est lourd
|
||||
margin_storage=419430400 #400Mo, marge de securité pour que vous puissiez utiliser l'afs aprés l'installation du jeu, je deconseille de modifier cette valeur
|
||||
|
||||
#AFS
|
||||
afs="$HOME/afs"
|
||||
|
||||
#LAUNCHER
|
||||
|
||||
minecraft_path="$afs/minecraft" #dossier qui contient minecraft la conf du launcher etc
|
||||
|
||||
launcher_name="PrismLauncher"
|
||||
launcher_config_path="$minecraft_path/config" #dossier qui contient les configurations du launcher
|
||||
launcher_appimage="$minecraft_path/PrismLauncher-Linux-x86_64.AppImage" #Dossier sense contenir le .appimage du launcher
|
||||
|
||||
instances_path="$minecraft_path/Instances" #dossier qui contient les instances minecraft
|
||||
mods_path="$minecraft_path/mods" #Dossier qui contient les mods minecraft
|
||||
java_path="$minecraft_path/java" #Dossier qui contient java(prism l'installe)
|
||||
downloads_path="$HOME/Downloads"
|
||||
launcher_local_files_path="$HOME/.local/share/PrismLauncher"
|
||||
bin_path="$minecraft_path/bin" #dossier où se trouve l'executable du launcher
|
||||
|
||||
#URL
|
||||
launcher_url="https://github.com/PrismLauncher/PrismLauncher/releases/download/9.4/PrismLauncher-Linux-x86_64.AppImage" #URL du github pour telecharger le launcher
|
||||
config_url="https://raw.githubusercontent.com/PixPix20/Minecraft-Installer/refs/heads/main/prismlauncher.cfg" #URL pour télécharger la config du launcher
|
||||
|
||||
check_storage(){
|
||||
#verification si l'AFS peut installer minecraft en plus de garder un marge pour les autre fichiers
|
||||
local used_storage total_storage
|
||||
used_storage=$(de -sb "$afs"|awk '{print $1}')
|
||||
total_storage=$((used_storage + minecraft_storage + margin_storage)) #On additionne le stockage déja utilisé, la taille (~) de MC puis on ajoute une marge de secu.
|
||||
|
||||
}
|
||||
|
||||
check_patr(){
|
||||
#Verfication de l'arbo du dossier minecraft
|
||||
mkdir -p $minecraft_path $launcher_config_path $instances_path $mods_path $java_path $bin_path
|
||||
}
|
||||
|
||||
check_config(){
|
||||
#telechargement et modification de la config
|
||||
local config="$launcher_config_path/primslauncher.cfg"
|
||||
if [ ! -f "$config" ]; then
|
||||
wget -q -P "$launcher_config_path/" $config_url
|
||||
sed -i \
|
||||
-e "s|DownloadsDir=|DownloadsDir=$downloads_path|" \
|
||||
-e "s|InstanceDir=|InstanceDir=$instances_path|" \
|
||||
-e "s|CentralModsDir=|CentralModsDir=$mods_path|" \
|
||||
-e "s|JavaDir=|JavaDir=$java_path|" \
|
||||
"$config"
|
||||
fi
|
||||
}
|
||||
|
||||
check_account(){
|
||||
#enregistrement du compte une fois connecte
|
||||
while [ ! -f "$prismlocal_path/accounts.json" ]; do
|
||||
sleep 2
|
||||
done
|
||||
printf "Compte détécté, sauvegarde"
|
||||
cp $prismlocal_path/accounts.json $launcher_config_path
|
||||
}
|
||||
|
||||
check_launcher(){
|
||||
#telechargement du launcher si inexistant
|
||||
if [ ! -f "$launcher_appimage" ]; then
|
||||
echo "Téléchargement de $name..."
|
||||
mkdir -p "$(dirname "$launcher_appimage")"
|
||||
#curl -L -o "$launcher_appimage" "$launcher_url" #si wget ne marche pas, décommentez cette ligne et commentez l'autre
|
||||
wget -q -O "$launcher_appimage" "$launcher_url"
|
||||
chmod +x "$launcher_appimage"
|
||||
fi
|
||||
}
|
||||
cop_files(){
|
||||
#deplacement des fichers de config et du compte dans le .local du launcher
|
||||
mkdir -p $prism_local_files_path
|
||||
cp $launcher_config_path/* $prism_local_files_path
|
||||
}
|
||||
|
||||
start_launcher(){
|
||||
nix-shell -p appimage-run --run "appimage-run $launcher_appimage"
|
||||
}
|
||||
|
||||
setup(){ #Configure i3 pour l'ajouter le launcher dans dmenu_run
|
||||
#archi
|
||||
#$HOME/afs/.confs/config/i3/config
|
||||
#apres bindsym $mod+d exec --no-startup-id PATH=$HOME/afs/minecraft/bin:$PATH dmenu_run
|
||||
#avant bindsym $mod+d exec --no-startup-id dmenu_run
|
||||
sed -i "s|bindsym $mod+d exec --no-startup-id|bindsym $mod+d exec --no-startup-id PATH=$HOME/afs/minecraft:$PATH|" "$HOME/afs/.confs/config/i3/config"
|
||||
#revoir la modif de ligne, trouver un truc plus opti (sed)
|
||||
|
||||
echo "export PATH=$HOME/afs/minecraft/bin:$PATH" >> $HOME/.bashrc
|
||||
source .bashrc
|
||||
mv $(pwd)/launcher.sh $bin_path
|
||||
}
|
||||
|
||||
|
||||
start() {
|
||||
check_path
|
||||
check_config
|
||||
check_launcher
|
||||
start_launcher & check_account
|
||||
|
||||
}
|
||||
if [ $# -eq 0 ]; then
|
||||
start
|
||||
|
||||
elif [ $1 = -i ]; then
|
||||
if [ check_storage = false ]; then
|
||||
exit 0
|
||||
else start
|
||||
fi
|
||||
fi
|
||||
@@ -1,111 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
VERSION=1.0
|
||||
|
||||
#On verifie qu'il y a assez de place pour installer minecraft en plus de garder un peu de place pour le reste
|
||||
max_storage=2147483648 #2Go, le stockage max de l'afs, je deconseille fortement d'augmenter cette valeur !
|
||||
used_storage=$(du -sb "$HOME/afs" | awk '{print $1}') #La taille actuelle de votre afs
|
||||
minecraft_storage=943718400 #900Mo, j'utilise cette valeur si vous voulez jouer avec un modpack qui est lourd
|
||||
margin_storage=419430400 #400Mo, marge de securité pour que vous puissiez utiliser l'afs aprés l'installation du jeu, je deconseille de modifier cette valeur
|
||||
afs="$HOME/afs"
|
||||
launcher_name="PrismLauncher"
|
||||
minecraft_path="$afs/minecraft" #dossier qui contient minecraft la conf du launcher etc
|
||||
launcher_config_path="$minecraft_path/config" #dossier qui contient les configurations du launcher
|
||||
instances_path="$minecraft_path/Instances" #dossier qui contient les instances minecraft
|
||||
mods_path="$minecraft_path/mods" #Dossier qui contient les mods minecraft
|
||||
java_path="$minecraft_path/java" #Dossier qui contient java(installe auto)
|
||||
downloads_path="$HOME/Downloads"
|
||||
prismlocal_path="$HOME/.local/share/PrismLauncher"
|
||||
appimage="$minecraft_path/PrismLauncher-Linux-x86_64.AppImage" #Dossier sense contenir le .appimage du launcher
|
||||
url="https://github.com/PrismLauncher/PrismLauncher/releases/download/9.4/PrismLauncher-Linux-x86_64.AppImage" #URL du github pour telecharger le launcher
|
||||
|
||||
total_storage=$(($used_storage+$minecraft_storage+$margin_storage))
|
||||
check_storage(){
|
||||
#verification si l'AFS peut installer minecraft en plus de garder un marge pour les autre fichiers
|
||||
if [ $total_storage -gt $max_storage ]; then
|
||||
printf "Impossible d'installer minecraft, il n'y a pas assez de place."
|
||||
printf "\n\tEssayez de supprimer quelques fichiers, regardez dans les configuration (du -h --max-depth=1 ~/.confs) pour connaitre la taille des differentes configuration"
|
||||
printf "\n\tNote: Chez moi la configuration de Discord faisait plus de 700Mo et celle de Firefox plus de 600Mo"
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
check_path(){
|
||||
#Verfication de l'arbo du dossier minecraft
|
||||
if [ ! -d "$minecraft_path" ]; then
|
||||
mkdir $minecraft_path $launcher_config_path $instances_path $mods_path $java_path
|
||||
|
||||
else
|
||||
if [ ! -d "$instances_path" ]; then
|
||||
mkdir $instances_path
|
||||
fi
|
||||
|
||||
if [ ! -d "$mods_path" ]; then
|
||||
mkdir $mods_path
|
||||
fi
|
||||
|
||||
if [ ! -d "$java_path" ]; then
|
||||
mkdir $java_path
|
||||
fi
|
||||
|
||||
if [ ! -d "$launcher_config_path" ]; then
|
||||
mkdir $launcher_config_path
|
||||
fi
|
||||
|
||||
if [ ! -d "$downloads_path" ]; then
|
||||
mkdir $downloads_path
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
check_config(){
|
||||
#telechargement et modification de la config
|
||||
if [ ! -f "$launcher_config_path/prismlauncher.cfg" ]; then
|
||||
wget -P "$launcher_config_path/" "https://raw.githubusercontent.com/PixPix20/Minecraft-Installer/refs/heads/main/prismlauncher.cfg"
|
||||
sed -i "s|DownloadsDir=|DownloadsDir=$downloads_path|" $launcher_config_path/prismlauncher.cfg
|
||||
sed -i "s|InstanceDir=|InstanceDir=$instances_path|" $launcher_config_path/prismlauncher.cfg
|
||||
sed -i "s|CentralModsDir=|CentralModsDir=$mods_path|" $launcher_config_path/prismlauncher.cfg
|
||||
sed -i "s|JavaDir=|JavaDir=$java_path|" $launcher_config_path/prismlauncher.cfg
|
||||
fi
|
||||
}
|
||||
|
||||
check_account(){
|
||||
#enregistrement du compte une fois connecte
|
||||
while [ ! -f "$prismlocal_path/accounts.json" ]; do
|
||||
sleep 2
|
||||
done
|
||||
cp $prismlocal_path/accounts.json $launcher_config_path
|
||||
}
|
||||
|
||||
check_launcher(){
|
||||
#telechargement du launcher si inexistant
|
||||
if [ ! -f "$appimage" ]; then
|
||||
echo "Téléchargement de PrismLauncher..."
|
||||
mkdir -p "$(dirname "$appimage")"
|
||||
#curl -L -o "$appimage" "$url"
|
||||
wget -O "$appimage" "$url"
|
||||
chmod +x "$appimage"
|
||||
fi
|
||||
}
|
||||
cop_files(){
|
||||
#deplacement des fichers de config et du compte dans le .local du launcher
|
||||
if [ ! -f "$prismlocal_path" ]; then
|
||||
mkdir -p $prismlocal_path
|
||||
fi
|
||||
cp $launcher_config_path/* $prismlocal_path
|
||||
}
|
||||
|
||||
start_launcher(){
|
||||
nix-shell -p appimage-run --run "appimage-run $appimage"
|
||||
}
|
||||
|
||||
#installation
|
||||
check_storage
|
||||
check_path
|
||||
check_config
|
||||
cop_files
|
||||
check_launcher
|
||||
start_launcher & check_account # doit se faire en para
|
||||
Reference in New Issue
Block a user