From 72886e567661a6c89091e0c722d537de54f70b9a Mon Sep 17 00:00:00 2001 From: mid <> Date: Sun, 29 Sep 2024 20:59:32 +0300 Subject: [PATCH] Better error resistance (don't fail if user already exists) --- install.lua | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/install.lua b/install.lua index 197f093..eb613a0 100755 --- a/install.lua +++ b/install.lua @@ -75,9 +75,23 @@ if baad then return end -if not os.execute"adduser --shell /bin/sh --disabled-password ikibooru" then - print"Failed to create user ikibooru." - return +if select(3, os.execute"id ikibooru") == 0 then + while true do + io.stdout:write"User ikibooru already exists. Can use? (y/n): " + local o = io.read"*l":lower() + if o == "y" then + break + elseif o == "n" then + print"Exiting." + return + end + print"Try again." + end +else + if not os.execute"useradd -U -m -s /bin/sh ikibooru" then + print"Failed to create user ikibooru." + return + end end io.stdout:write"MySQL host: " @@ -301,4 +315,4 @@ end print"" -print"Installation complete. Remember: Ikibooru is only an HTTP server. It must be used together with a relay or reverse proxy." +print"Installation complete. Reminder: Ikibooru is only an HTTP server. It must be used together with a relay or reverse proxy."