factorio-init icon indicating copy to clipboard operation
factorio-init copied to clipboard

Add feature that creates user&folder

Open buson94 opened this issue 4 years ago • 1 comments

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!

buson94 avatar Jun 19 '21 16:06 buson94

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

tmzasz avatar Nov 03 '21 01:11 tmzasz

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 :)

Bisa avatar Aug 21 '22 21:08 Bisa