Skip to content

Instantly share code, notes, and snippets.

@Tea23
Last active August 2, 2024 05:29
Show Gist options
  • Save Tea23/e6e6271a236ac8e60bf8c6d6bafd2436 to your computer and use it in GitHub Desktop.
Save Tea23/e6e6271a236ac8e60bf8c6d6bafd2436 to your computer and use it in GitHub Desktop.
Linux/Proton/Steam Deck Hardlinking installer for Fallout: London
#!/bin/bash
# Linux installer for Fallout London. Uses hardlinks to save space.
#
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
DOWNGRADE_SHA256SUM="ae7be31a59052f926474a767d9dbfbcc7f19af4ad2070491f7f40d821b2520eb"
check_folon() {
if [ -n "$FO4_LOCATION" ]; then
[ -e "$FO4_DATA/Fallout4.esm" ] || fail_n_bail invalid
else
fail_n_bail nodir
fi
case "$1" in
install)
if [ -e "$FO4_DATA/LondonWorldSpace.esm" ]; then
fail_n_bail installed
fi
install_folon
;;
uninstall)
if [ ! -e "$FO4_DATA/LondonWorldSpace.esm" ]; then
fail_n_bail uninstalled
fi
uninstall_folon
;;
esac
}
install_folon() {
ESM_HASH=$(sha256sum "$FO4_LOCATION/Data/Fallout4.esm" | awk '{print $1}')
if [ $ESM_HASH = "$DOWNGRADE_SHA256SUM" ]; then
echo "Installing Fallout: London to $FO4_LOCATION"
echo "compatdata path cannot be determined by script"
echo "You will need to copy the contents of the _Config and _AppData directories manually to steamapps/compatdata/377160/pfx/drive_c/users/steamuser"
echo "Run the game at least once to generate this directory."
echo "This script is known to work with the Steam version of Fallout 4 only. Use caution if applying to GOG."
echo ""
read -p "Proceed with installation? (y/n) " -r
echo ""
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "User aborted installation. Exiting."
exit 0
fi
ln f4se*.* "$FO4_LOCATION/"
cd Data/
# New directories could be made in a future update
for i in $(find . -maxdepth 5 -type d | sed 's/.\///');
do
mkdir -p "$FO4_DATA/$i"
done
# Hardlinks - this saves space because the default installation procedure is to a) 'install' FOLON from GOG to somewhere and then
# b) copy the files inside that installation to Fallout 4. This effectively doubles the data requirements for FOLON.
# A hardlink is an index to an inode occupied by an already existing file - essentially, you have two files sharing the EXACT same data!
# This keeps space utilisation down, and also ensures data integrity as the original file can be deleted or changed at will.
mkdir "$FO4_DATA/Video/original"
find "$FO4_DATA/Video/" -name '*.bk2' | while IFS= read -r file; do
mv "$file" "$FO4_DATA/Video/original"
done
ln *.* "$FO4_DATA"
ln Video/* "$FO4_DATA/Video"
ln F4SE/plugins/* "$FO4_DATA/F4SE/plugins"
ln Layouts/ObjectWindow/* "$FO4_DATA/Layouts/ObjectWindow"
ln LSData/* "$FO4_DATA/LSData"
ln PRKF/* "$FO4_DATA/PRKF"
ln Scripts/Fragments/Quests/* "$FO4_DATA/Scripts/Fragments/Quests"
ln Textures/Interface/* "$FO4_DATA/Textures/Interface"
ln XDI/* "$FO4_DATA/XDI"
cd Scripts/
for i in $(find . -maxdepth 1 -type f);
do
ln $i "$FO4_DATA/Scripts"
done
if [ -e "$FO4_DATA/LondonWorldSpace.esm" ]; then
echo "Installation complete. Enjoy!"
disclaimer
exit 0
else
echo "LondonWorldSpace.esm not found!"
echo "Something went wrong during installation. Check output and try again."
disclaimer
exit 1
fi
else
fail_n_bail downgrade
fi
}
uninstall_folon() {
echo "Uninstalling FOLON is not a good idea, but you can try it anyway."
echo "You will need to restore the original AppData and Config files in compatdata manually."
echo "Furthermore, any mods you installed will not be handled by this script and will need to be removed manually."
echo "Don't do this - just restore your backup."
echo ""
echo ""
read -p "Are you absolutely sure you want to uninstall FOLON? (y/n) " -r
echo ""
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "User aborted uninstallation. Exiting."
exit 0
fi
rm "$FO4_LOCATION"/*f4se*
cd Data/
find . -maxdepth 10 -type f -exec rm "$FO4_DATA/{}" \;
mv "$FO4_DATA"/Video/original/* "$FO4_DATA/Video/"
rmdir "$FO4_DATA/Video/original"
if [ ! -e "$FO4_DATA/LondonWorldSpace.esm" ]; then
echo "Uninstallation complete."
echo "Directories have been kept, but links to FOLON's files have been removed."
disclaimer
exit 0
else
echo "Something went wrong during uninstallation. Check output and try again: $FO4_DATA/LondonWorldSpace.esm is still present."
disclaimer
exit 1
fi
}
print_help() {
echo "Simple Fallout: London installer for Linux. Uses hardlinks to save space."
echo "Has only been tested using the Steam version of the game."
echo "If you have Fallout 4 from GOG, you should probably just use Heroic/Lutris."
echo "Usage: $0 [--install /path/to/Fallout 4] [--uninstall /path/to/FOLON] [--help]"
echo "Options:"
echo " --install <path> Install Fallout: London to the given directory containing a downgraded Fallout 4 installation."
echo " --uninstall <path> Remove Fallout: London from the given directory."
echo " --help Display this help message."
echo "All paths must be quoted or properly escaped."
echo ""
echo "This installer is a \"made for me, but maybe useful for others\" project. No warranty - implied or explicit - is given."
echo "Please make backups."
disclaimer
}
fail_n_bail() {
case "$1" in
nodir)
echo "Fallout 4 installation directory not given. Provide the path to your Fallout 4 installation."
echo "e.g. ./installer.sh --install /mnt/games/steam/steamapps/common/Fallout\ 4"
;;
invalid)
echo "Given directory $FO4_LOCATION does not appear to contain Fallout 4 installation files: $FO4_DATA/Fallout4.esm not found."
echo "Specify a valid Fallout 4 directory and try again."
;;
installed)
echo "Fallout: London appears to already be installed; $FO4_DATA/LondonWorldSpace.esm exists."
;;
uninstalled)
echo "Fallout: London doesn't appear to be installed, so nothing to uninstall: $FO4_DATA/LondonWorldSpace.esm does not exist."
;;
downgrade)
echo "Checksum mismatch, got $ESM_HASH for $FO4_DATA/Fallout4.esm"
echo "Fallout 4 is not downgraded, or Fallout4.esm has been modified. Please run the FOLON Downgrader before installing Fallout: London."
;;
*)
echo "Something went wrong. Good luck."
;;
esac
disclaimer
exit 1
}
disclaimer() {
echo ""
echo "Do NOT contact the FOLON developers or GOG for help with this script. Leave a comment on the gist instead."
echo "https://gist.github.com/Tea23/e6e6271a236ac8e60bf8c6d6bafd2436"
}
print_default() {
echo "USAGE: $0 --install /path/to/Fallout\ 4"
echo "See --help for more information."
disclaimer
exit 0
}
if [[ "$#" -eq 0 ]]; then
print_default
fi
if [ ! -e "Data/LondonWorldSpace.esm" ] || [ ! -e "goggame-1491728574.info" ]; then
print_help
echo "Installer needs to be run from the directory containing the GOG distribution of Fallout: London."
echo "Download the Fallout: London installer from GOG and run it in Wine to install it to a location or use innoextract to extract it"
echo "and then move this installer file to the installation directory (containing installer.exe, Data/, _AppData/ etc.)"
disclaimer
exit 1
fi
while [[ "$#" -gt 0 ]]; do
case "$1" in
--install)
FO4_LOCATION=$(readlink -f "$2")
FO4_DATA="${FO4_LOCATION}/Data"
check_folon install
shift
;;
--uninstall)
FO4_LOCATION=$(readlink -f "$2")
FO4_DATA="${FO4_LOCATION}/Data"
check_folon uninstall
shift
;;
--help)
print_help
;;
*)
echo "Unknown flag: $1"
echo ""
print_default
exit 1
;;
esac
shift
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment