Deceiving a game that its mod dir is there when actually it isn't?

rado84

Well-Known Member
Joined
Feb 25, 2019
Messages
676
Reaction score
547
Credits
3,969
Guys, do you know of any way to deceive a game in linux that a certain directory is in its place when in fact it's somewhere else?
What I want to do is to trick ETS 2 that this directory "/home/rado/.local/share/Euro Truck Simulator 2" is still there when in fact it's here: "/media/500GB/STEAM/steamapps/common/ETS2Mods" and so the game will look for its mods in the 2nd location?

There's supposed to be a way by adding a launch option in Steam but it doesn't work. It seems to be reading only the first launch option (which is "-nointro") and if I add a second, the game ignores it. So I need another way, not with launch options.
 


JasKinasis

Well-Known Member
Joined
Apr 25, 2017
Messages
1,704
Reaction score
2,471
Credits
13,677
Yes. Create a symbolic link in ~/.local/share/ called "Euro Truck Simulator 2", which points to the other directory.
e.g.:
Bash:
ln -sT /media/500GB/STEAM/steamapps/common/ETS2Mods "~/.local/share/Euro Truck Simulator 2"

That way, the game will think it’s accessing the ~/.local/share/Euro Truck….. directory, but it’s redirected to the directory on the 500GB drive.
 

MikeWalsh

Well-Known Member
Joined
Aug 29, 2022
Messages
350
Reaction score
434
Credits
4,506
Exactly what I was going to say, but JasKinasis has beaten me to it!


Mike. ;)
 
OP
rado84

rado84

Well-Known Member
Joined
Feb 25, 2019
Messages
676
Reaction score
547
Credits
3,969
That doesn't work.

Code:
ln -sT /media/500GB/STEAM/steamapps/common/ETS2Mods "~/.local/share/Euro Truck Simulator 2"
ln: unsuccessful creation of a symbolic link „'~/.local/share/Euro Truck Simulator 2'“: No such file or directory

So I tried with a small "t" and it worked - the link was created (in ETS2Mods/) but when I empty "~/.local/share/Euro Truck Simulator 2", the game keeps looking for the data in it, not in ETS2Mods.
If the link works the way I think it works and it's created in ETS2Mods, maybe I should swap the addresses, like this:
Code:
ln -sT "~/.local/share/Euro Truck Simulator 2" /media/500GB/STEAM/steamapps/common/ETS2Mods
That way (at least theoretically) the link will be created in "~/.local/share/Euro Truck Simulator 2" pointing to ETS2Mods and I'll be able to empty "~/.local/share/Euro Truck Simulator 2" leaving only the link inside it to point to the target dir ETS2Mods.

Nope, the second variant doesn't work either.
 
C

CrazedNerd

Guest
Steam used to add a launch icon for me automatically on Desktop, but recently when i ran the client I did it by aliasing it to put terminal errors in /dev/null:

Code:
alias steam='path/to/launch-script.sh &> /dev/null/ &'

That will also free up the terminal for different tasks by putting the task in the background.
 
OP
rado84

rado84

Well-Known Member
Joined
Feb 25, 2019
Messages
676
Reaction score
547
Credits
3,969
Steam used to add a launch icon for me automatically on Desktop, but recently when i ran the client I did it by aliasing it to put terminal errors in /dev/null:

Code:
alias steam='path/to/launch-script.sh &> /dev/null/ &'

That will also free up the terminal for different tasks by putting the task in the background.
What does that have to do with my question?
 

wizardfromoz

Administrator
Staff member
Gold Supporter
Joined
Apr 30, 2017
Messages
8,635
Reaction score
7,593
Credits
35,340
Gracious as ever, Rado ;)

Should this not be in Gaming? Or in Command Line, since you are looking for a string or expression.

Let me know and I can move it there.

Cheers and be nice.

Wiz
 

JasKinasis

Well-Known Member
Joined
Apr 25, 2017
Messages
1,704
Reaction score
2,471
Credits
13,677
That doesn't work.

Code:
ln -sT /media/500GB/STEAM/steamapps/common/ETS2Mods "~/.local/share/Euro Truck Simulator 2"
ln: unsuccessful creation of a symbolic link „'~/.local/share/Euro Truck Simulator 2'“: No such file or directory

So I tried with a small "t" and it worked - the link was created (in ETS2Mods/) but when I empty "~/.local/share/Euro Truck Simulator 2", the game keeps looking for the data in it, not in ETS2Mods.
If the link works the way I think it works and it's created in ETS2Mods, maybe I should swap the addresses, like this:
Code:
ln -sT "~/.local/share/Euro Truck Simulator 2" /media/500GB/STEAM/steamapps/common/ETS2Mods
That way (at least theoretically) the link will be created in "~/.local/share/Euro Truck Simulator 2" pointing to ETS2Mods and I'll be able to empty "~/.local/share/Euro Truck Simulator 2" leaving only the link inside it to point to the target dir ETS2Mods.

Nope, the second variant doesn't work either.
What I've posted should work. The syntax is correct.
I've used symbolic links to trick games into using older, or newer versions of shared libraries a number of times in the past. And I've set up symbolic links to redirect to data stored in directories on external devices.

I'd bet that the problem is one of the following:
1. The ln command didn't perform the expansion of the ~ properly.
I've seen this happen with a few commands in the past.
I'm pretty certain ln works with shell expansions though.
But if the ~/ expansion failed - then the path for the sym-link will be mangled and will therefore be invalid, hence ln will unable to create the link. In which case, try using /home/rado/ or $HOME/ instead of ~/.

2. The .local/share directory doesn't exist
If the .local/share directory does not exist - ln will not be able to create a link in that directory. So that directory MUST exist before running ln.

3. The "Euro Truck Simulator 2" directory already exists in ~/.local/share/.
If the "Euro Truck Simulator2" directory already exists, ln will not be able to create the link because a directory with that name already exists there.
So if there is a directory already there with that name, you'll need to delete, or rename it.

4. You must have the external drive mounted when creating the symbolic link, otherwise ln will also fail.
If the file-system object you want to link to does not exist - then ln will fail to create the link.
If you create a link to something on an external device and then unmount it - the symbolic link will remain on the file-system, but will be broken/invalid until that device is mounted again.
But ln CANNOT create a broken symbolic link. So the file-system containing your target file/directory MUST be mounted at the time that you run ln to create your link. If it isn't, then ln will simply fail to create the link.

So the first thing to try would be this:
Bash:
file ~/.local/share
To check that you have a .local/share directory.
If doesn't exist, create it:
Bash:
mkdir -p ~/.local/share/

If it does exist - check there isn't a "Euro Truck Simulator 2" directory already in there:
Bash:
ls ~/.local/share | \grep -i Euro
If there IS a "Euro Truck Simulator 2" directory in there - then you'll need to remove it, or rename it, in order to be able to use that name for your symbolic link. So either delete it with rm, or rename it using mv.

Finally, once you have confirmed that your .local/share directory exists AND that you don't already have a "Euro Truck Simulator 2" directory in there, then you should be able to create your symbolic link.
Bash:
ln -sT /media/500GB/STEAM/steamapps/common/ETS2Mods "/home/rado/.local/share/Euro Truck Simulator 2"

If that fails for some reason, perhaps try without the double quotes and escape the spaces instead:
Bash:
ln -sT /media/500GB/STEAM/steamapps/common/ETS2Mods /home/rado/.local/share/Euro\ Truck\ Simulator\ 2

If that fails - I don't know what to suggest!

EDIT: Do NOT use the lowercase -t option - that's completely the wrong option. That puts the link in your /media/....../ETS2Mods/ directory....... That's NOT what you want to do.
You need to use the -T option, which specifies the /media/...../ETS2/ directory as the TARGET for the link. In other words, it is what the link in ~/.local/share/ will point/redirect to.


From having a quick play with ln - using ~ does not appear to be problematic. That seems to work properly - so the problem must be one of the other things. Either the filesystem containing the target directory was not mounted, or .local/share does not exist, or .local/share/Euro Truck Simulator 2 already exists.
 
Last edited:
OP
rado84

rado84

Well-Known Member
Joined
Feb 25, 2019
Messages
676
Reaction score
547
Credits
3,969
I had forgotten about this topic! Thank you for the thorough answer and for your patience to write all that! :D
I had never used links before, so naturally I must have messed up something. I didn't know I had to remove the long name directory in ~/.local/share. So I did what you said but before that I moved all of its contents to the new location, then used this command:
Code:
ln -sT /media/500GB/STEAM/steamapps/common/ETS2Mods "/home/rado/.local/share/Euro Truck Simulator 2"
and it worked. So, thank you very much for your help!
Now I'll write it all down just in case I need it again (and for other cases as well - to use it as a template).

Just one question though: if some day, for whatever reason, I have to reinstall Arch, do I have to do this all over again? Or will that link remain active? I suspect I'll have to do it again, since the link is in ~/.local/share which is on the root partition, but it doesn't hurt to ask.
 

JasKinasis

Well-Known Member
Joined
Apr 25, 2017
Messages
1,704
Reaction score
2,471
Credits
13,677
I had forgotten about this topic! Thank you for the thorough answer and for your patience to write all that! :D
I had never used links before, so naturally I must have messed up something. I didn't know I had to remove the long name directory in ~/.local/share. So I did what you said but before that I moved all of its contents to the new location, then used this command:
Code:
ln -sT /media/500GB/STEAM/steamapps/common/ETS2Mods "/home/rado/.local/share/Euro Truck Simulator 2"
and it worked. So, thank you very much for your help!
Now I'll write it all down just in case I need it again (and for other cases as well - to use it as a template).

Just one question though: if some day, for whatever reason, I have to reinstall Arch, do I have to do this all over again? Or will that link remain active? I suspect I'll have to do it again, since the link is in ~/.local/share which is on the root partition, but it doesn't hurt to ask.
Glad you finally got there! Ha ha!

If you reinstall Arch, then yes, you'll almost certainly need to re-create the link.
But if you backup your ~/.local directory, you should be able to restore any links from backup, as long as the file-format you're using for your backups supports symbolic links.
So, off the top of my head - I know for a fact that tar will preserve symbolic links. So if you back up ~/.local as a .tar, or .tar.gz, or .tar.xz etc - any symbolic links will be preserved in the backup.
 
OP
rado84

rado84

Well-Known Member
Joined
Feb 25, 2019
Messages
676
Reaction score
547
Credits
3,969
None of these seem to support symbolic links. If I try to archive any random directories along with the link, they compress the target directory /ETS2Mods, instead of the link itself. But no worries, I can make a script with an alias which will quickly restore things the way I want them to be. Nearly half of my aliases lead to complex bash scripts.

Edit: there, it's done. In case I have to reinstall, it will take a short command to restore the link.

If I forget about the missing link and run the game, it will recreate its default directory, thus making me to create a new profile. In that case I'll use the following alias, which removes "Euro Truck Simulator 2" recursively (bc the main mod contents is already in the other location), recreates the link, changes dir to ~/.local/share and finally - confirms that the link has been created.

Code:
alias ets2relink="/media/1000GB/PROGRAMS/CLI-SCRIPTS/scs-games/ets2-restore-symbolic-link.sh"

ets2-restore-symbolic-link.sh:
rm -rv "/home/rado/.local/share/Euro Truck Simulator 2" && ln -sT /media/500GB/STEAM/steamapps/common/ETS2Mods "/home/rado/.local/share/Euro Truck Simulator 2" && cd /home/rado/.local/share && file "Euro Truck Simulator 2"

But if I remember about the missing link and DON'T run the game, then there's another alias with a script which will simply create the link without having to delete aforementioned directory:

Code:
alias ets2link="/media/1000GB/PROGRAMS/CLI-SCRIPTS/scs-games/ets2-create-link-only.sh"

ets2-create-link-only.sh:
ln -sT /media/500GB/STEAM/steamapps/common/ETS2Mods "/home/rado/.local/share/Euro Truck Simulator 2" && cd /home/rado/.local/share && file "Euro Truck Simulator 2"

So, you could say I'm now prepared for the two most likely scenarios with that link. :) If a third scenario arises, I'll prep another script for it.
 

JasKinasis

Well-Known Member
Joined
Apr 25, 2017
Messages
1,704
Reaction score
2,471
Credits
13,677
None of these seem to support symbolic links. If I try to archive any random directories along with the link, they compress the target directory /ETS2Mods, instead of the link itself. But no worries, I can make a script with an alias which will quickly restore things the way I want them to be. Nearly half of my aliases lead to complex bash scripts.

Edit: there, it's done. In case I have to reinstall, it will take a short command to restore the link.

If I forget about the missing link and run the game, it will recreate its default directory, thus making me to create a new profile. In that case I'll use the following alias, which removes "Euro Truck Simulator 2" recursively (bc the main mod contents is already in the other location), recreates the link, changes dir to ~/.local/share and finally - confirms that the link has been created.

Code:
alias ets2relink="/media/1000GB/PROGRAMS/CLI-SCRIPTS/scs-games/ets2-restore-symbolic-link.sh"

ets2-restore-symbolic-link.sh:
rm -rv "/home/rado/.local/share/Euro Truck Simulator 2" && ln -sT /media/500GB/STEAM/steamapps/common/ETS2Mods "/home/rado/.local/share/Euro Truck Simulator 2" && cd /home/rado/.local/share && file "Euro Truck Simulator 2"

But if I remember about the missing link and DON'T run the game, then there's another alias with a script which will simply create the link without having to delete aforementioned directory:

Code:
alias ets2link="/media/1000GB/PROGRAMS/CLI-SCRIPTS/scs-games/ets2-create-link-only.sh"

ets2-create-link-only.sh:
ln -sT /media/500GB/STEAM/steamapps/common/ETS2Mods "/home/rado/.local/share/Euro Truck Simulator 2" && cd /home/rado/.local/share && file "Euro Truck Simulator 2"

So, you could say I'm now prepared for the two most likely scenarios with that link. :) If a third scenario arises, I'll prep another script for it.
That's odd....
How were you creating your backup files?

You should have just been able to back it up by using:
Bash:
tar -cvzf local.tar.gz ~/.local/
Which will back up everything inside ~/.local and save it in an archive called local.tar.gz

Or if you only want to back up the share sub-directory of ~/.local/:
Bash:
tar -cvzf localshare.tar.gz ~/.local/share/
Which will backup everything inside ~/.local/share/ and save it in an archive called localshare.tar.gz.

The tar command should NOT end up pulling in and compressing the entire target directory, unless you specified the -h option, which follows/dereferences symbolic links.

So as long as you DON'T use the -h option when you create your .tar.gz, your symbolic link should be backed up as a sym-link. That's the only thing I can think of offhand that would cause the entire target directory to be compressed as part of the backup.

As a sanity check, I just created a directory called test and added some symbolic links which point to some valid directories on my system:
e.g.
Bash:
mkdir test && cd test;
ln -sT ~/projects/suckless/dwm/ dwm
ln -sT ~/projects/suckless/dmenu/ dmenu
ln -sT ~/projects/suckless/sent sent
So I have a directory containing three symbolic links.

If I list the contents of the directory, using ls -F where the -F (--classify) option appends an indicator at the end of each file-system object to indicate it's type, I see the following:
And @ at the end of a file-name indicates that it's a symbolic link. So all three objects in the directory are sym-links as we'd expect. Using the command file * also verifies that they are all symbolic links pointing to directories.

Next I cd back into the parent directory and tar the entire test directory as a .tar.gz file:
Bash:
cd ../
tar -cvzf test.tar.gz test
Then I create a directory called test 2, I move the .tar.gz into the test2 directory, I cd into the directory and then extract the .tar.gz archive:
Bash:
mkdir test2 && mv test.tar.gz ./test2 && cd test 2
tar -xvf test.tar.gz
Now the new test2 directory contains the .tar.gz file AND a sub-directory called test.
And if I cd into the test sub-directory and run ls -F, I see the following:

So the files that were backed up were all symbolic links and when extracted, they were still symbolic links. The original directories were NOT included in the backup. I ran the same test using the j and J flags, to use .tar.bz2 and .tar.xz compression methods and they yielded the same results.

As an extra sanity test, I ran the tests again, but using the -h option when compressing.
e.g.
Bash:
tar -cvzhf test.tar.gz test
And exactly as expected, all of the symbolic links were followed and the target directories WERE included in the backup file.
So if you were using -h with tar when backing up, that is why the target directory was getting zipped up. So the simple solution is DON'T use -h with tar! Ha ha!

Otherwise, I honestly don't know how your backup ended up including and compressing your actual mod directory.
 
Last edited:
OP
rado84

rado84

Well-Known Member
Joined
Feb 25, 2019
Messages
676
Reaction score
547
Credits
3,969
I used a GUI - Engrampa and File-Roller. Both support these formats. That works, altough it compresses the wrong thing.
I just copy-pasted your command
Code:
tar -cvzf local.tar.gz ~/.local/
but it keeps showing me the usage of tar - apparently it doesn't like something in the options. Which is weird because based on the usage I see in terminal, it should work. I still see usage if I write /home/rado instead of ~ .
Frankly I've never been a big fan of these formats bc they're slow AF and that's why I don't use them. Just a few days ago I downloaded a 6.5GB free game native for linux (an AVN game) that was compressed as tar.gz (for unknown reasons) and it took 13 minutes to read the thing and then unpack it. If that were a 7z format, it would have been unpacked in 2 minutes tops. Considering I was unpacking it on a pretty new SATA 3 SSD with 550 MB/s write speed, that's an unusually slow unpacking for this format.
At least with my aliased scripts I don't have to deal with these outdated formats.
 

Jig36

New Member
Joined
Feb 14, 2023
Messages
2
Reaction score
0
Credits
13
None of these seem to support symbolic links. If I try to archive any random directories along with the link, they compress the target directory /ETS2Mods, instead of the link itself. But no worries, I can make a script with an alias which will quickly restore things the way I want them to be. Nearly half of my aliases lead to complex bash scripts.

Edit: there, it's done. In case I have to reinstall, it will take a short command to restore the link.

If I forget about the missing link and run the game, it will recreate its default directory, thus making me to create a new profile. In that case I'll use the following alias, which removes "Euro Truck Simulator 2" recursively (bc the main mod contents is already in the other location), recreates the link, changes dir to ~/.local/share and finally - confirms that the link has been created.

Code:
alias ets2relink="/media/1000GB/PROGRAMS/CLI-SCRIPTS/scs-games/ets2-restore-symbolic-link.sh"

ets2-restore-symbolic-link.sh:
rm -rv "/home/rado/.local/share/Euro Truck Simulator 2" && ln -sT /media/500GB/STEAM/steamapps/common/ETS2Mods "/home/rado/.local/share/Euro Truck Simulator 2" && cd /home/rado/.local/share && file "Euro Truck Simulator 2"

But if I remember about the missing link and DON'T run the game, then there's another alias with a script which will simply create the link without having to delete aforementioned directory:

Code:
alias ets2link="/media/1000GB/PROGRAMS/CLI-SCRIPTS/scs-games/ets2-create-link-only.sh"

ets2-create-link-only.sh:
ln -sT /media/500GB/STEAM/steamapps/common/ETS2Mods "/home/rado/.local/share/Euro Truck Simulator 2" && cd /home/rado/.local/share && file "Euro Truck Simulator 2"

So, you could say I'm now prepared for the two most likely scenarios with that link. :) If a third scenario arises, I'll prep another script for it.
The thing about symbolic links are that you use one folder and it basically create a shortcut in the location you set… so if you keep the folder in that location you set the symbolic link doesn’t get create!
 
MALIBAL Linux Laptops

Linux Laptops Custom Built for You
MALIBAL is an innovative computer manufacturer that produces high-performance, custom laptops for Linux.

For more info, visit: https://www.malibal.com

Members online


Top