-
Notifications
You must be signed in to change notification settings - Fork 1
/
freeso-linux.sh
executable file
·126 lines (95 loc) · 4.03 KB
/
freeso-linux.sh
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
#!/bin/bash
if [ "$EUID" -eq 0 ]
then printf "Please run with local user, not sudo\n"
exit
fi
TEMPDIR="$HOME/.freeso_temp"
GAMEDIR="none"
while [ "$GAMEDIR" == "none" ]
do
read -p "Directory to install FreeSO [${HOME}/freeso]: " GAMEDIR
GAMEDIR=${GAMEDIR:-${HOME}/freeso}
if [ -z "${GAMEDIR%%/*}" ] && pathchk -pP "$GAMEDIR"
then
mkdir -p $GAMEDIR
if [ -d $GAMEDIR ]
then
printf "Installing to $GAMEDIR.\n"
else
printf "$GAMEDIR is not a valid directory.\n"
GAMEDIR="none"
fi
else
printf "$GAMEDIR is not a full absolute path (e.g. $HOME/freeso)\n"
GAMEDIR="none"
fi
done
printf "Temporary install file location: $TEMPDIR\n"
printf "Game file location: $GAMEDIR\n"
mkdir -p $TEMPDIR && cd $TEMPDIR
mkdir -p $GAMEDIR
PACKAGEUPDATE="none"
PACKAGEINSTALL="none"
printf "\nDetermining package manager...\n"
if which apt; then PACKAGEUPDATE="apt update -y"; PACKAGEINSTALL="apt install -y unzip cabextract curl mono-runtime mono-devel"; fi
if which pacman; then PACKAGEUPDATE="pacman -Syy"; PACKAGEINSTALL="pacman -S --noconfirm unzip cabextract curl mono"; fi
if which yum; then PACKAGEUPDATE="yum check-update -y"; PACKAGEINSTALL="yum install -y unzip cabextract curl mono-core mono-devel"; fi
if which dnf; then PACKAGEUPDATE="dnf check-update -y"; PACKAGEINSTALL="dnf install -y unzip cabextract curl mono-core mono-devel"; fi
if which zypper; then PACKAGEUPDATE="zypper refresh"; PACKAGEINSTALL="zypper install -y unzip cabextract curl mono-core mono-devel"; fi
if which xbps-query; then PACKAGEUPDATE="xbps-install -Su"; PACKAGEINSTALL="xbps-install unzip cabextract curl mono mono-devel libgdiplus"; fi
if [ "$PACKAGEUPDATE" == "none" ]
then
printf "\nPackage Manager/OS not supported."
exit 1
fi
printf "\nUpdating sources...\n"
sudo ${PACKAGEUPDATE}
printf "\nInstalling dependencies (unzip/cabextract/curl/mono)...\n"
sudo ${PACKAGEINSTALL}
clear -x
printf "FreeSO Installer for Linux\nhttps://github.com/tomgrice/freeso-linux\n"
printf "\nDownloading: TSO Game package\n"
curl -# -L -o "TSO.zip" https://beta.freeso.org/LauncherResourceCentral/TheSimsOnline
printf "\nDownloading: FreeSO latest client (GitHub)\n"
curl -# -o "client-latest.zip" -L $(grep -oP '(http)(.*)(client)(.*)(\.zip)' <<< "$(curl -s https://api.github.com/repos/riperiperi/FreeSO/releases/latest)")
printf "\nDownloading: macextras package\n"
curl -# -L -o "macextras.zip" https://beta.freeso.org/LauncherResourceCentral/MacExtras
printf "\nDownloading: Remesh package\n"
curl -# -L -o "RemeshPackage.zip" https://beta.freeso.org/LauncherResourceCentral/3DModels
printf "\nExtracting game archives\n"
unzip -q -o client-latest.zip -d "${GAMEDIR}"
unzip -q -o TSO.zip -d "${TEMPDIR}/tso"
unzip -q -o macextras.zip -d "${GAMEDIR}"
unzip -q -o RemeshPackage.zip -d "${GAMEDIR}/Content/MeshReplace"
cabextract -qq -d "${GAMEDIR}/game" "${TEMPDIR}/tso/Data1.cab"
printf "\nDownloading game icon from GitHub\n"
curl -# -o ${GAMEDIR}/fso-icon.png https://cdn.statically.io/gh/tomgrice/freeso-linux/main/fso-icon.png
printf "\nCreating launcher icons\n"
mkdir -p ${HOME}/.local/share/applications
cat > "${HOME}/.local/share/applications/FreeSO.desktop" << EOL
[Desktop Entry]
Version=1.0
Type=Application
Name=FreeSO
Comment=Launch FreeSO (https://freeso.org)
Exec=mono ${GAMEDIR}/FreeSO.exe
Icon=${GAMEDIR}/fso-icon.png
Terminal=false
StartupNotify=false
Categories=Game
EOL
cat > "${HOME}/.local/share/applications/FreeSO (3D).desktop" << EOL
[Desktop Entry]
Version=1.0
Type=Application
Name=FreeSO (3D)
Comment=Launch FreeSO (https://freeso.org)
Exec=mono ${GAMEDIR}/FreeSO.exe -3d
Icon=${GAMEDIR}/fso-icon.png
Terminal=false
StartupNotify=false
Categories=Game
EOL
printf "\nCleaning up temporary files\n"
rm -R "${TEMPDIR}"
printf "\nInstall complete!\nRun game using: 'mono ${GAMEDIR}/FreeSO.exe' - add -3d flag to launch in 3D mode.\nOr alternatively, run the game from your system menu.\nYou may need to restart your system for the game to show in your applications menu.\n"