Bisa / factorio-init

Factorio init script
MIT License
414 stars 82 forks source link

Add feature that creates user&folder #189

Closed buson94 closed 2 years ago

buson94 commented 3 years ago

As requested by @Bisa i'll open a new issue for this ☺ It's been a month now but i'll try to recreate what i wrote down in this issue. Info beforehand: I'm using headless Ubuntu 20.04.2 LTS

It seems like the script doesn't create the directory for installing the factorio server, neither a seperate user. So what i did first was: sudo adduser factorio --home /home/factorio (i have all my game servers running in /home)

After i edited the config file with my correct directory i tried to run the script again but it fails already here since the home directory is not empty by default (the users bash config will be put in there after creating the user). So my solution was to just to comment out this block of the script and then i could install the factorio server without any further problems.

So i would suggest to either add sudo adduser factorio --home ${FACTORIO_PATH} to the factorio install function (maybe support other linux systems as well? I just knew the Ubuntu command 😅) and/or make the script ignore bash config/non-factorio related files in FACTORIO_PATH somehow.

I hope i didn't forget anything!

tmzasz commented 2 years ago

My 2 cents : have the script check to see if both the user/directory exist if the user does not exist prompt for creation - If yes then create the user with the -M flag ( this prevents a home directory at all ) if the directory does not exist (assuming script run as either root/sudo) create and then chown the directory to the new user and then proceed with the install

adding the user with -M will prevent the home directory issue from being present and the script if ran as sudo/root should have no difficulties in the mkdir $FACTORIO_PATH and chown $USERNAME:$USERGROUP $FACTORIO_PATH method nor the adduser $USERNAME -M method

Bisa commented 2 years ago

Having pondered this for a bit I figured I'll rather not increase the scope of the install command further - for now I'll try to err on the side of caution, give me an empty directory that root or the "factorio" user can write to, should be simple enough for anyone using a nix shell these days :)