43 lines
1.3 KiB
Lua
43 lines
1.3 KiB
Lua
#!/usr/bin/env lua5.3
|
|
|
|
local SQL = require"luasql.mysql"
|
|
|
|
do
|
|
local st, res = pcall(io.popen, "uname -s", "r")
|
|
if not st or res:read"*l" ~= "Linux" then
|
|
print"Only Linux is supported by the uninstaller at this moment."
|
|
return
|
|
end
|
|
end
|
|
|
|
local code = [[YES, I AM REALLY SURE I REALLY WANT TO DELETE EVERYTHING ON IKIBOORU]]
|
|
|
|
print"Are you sure you wish to uninstall Ikibooru? Perhaps you want to only disable the service? This script will not do that.
|
|
print"This script will: remove the user; its directory, which includes all object data and ID-hiding key; delete the database (that means ALL ACCOUNTS, COMMENTS AND POSTS!); remove as a service."
|
|
print"ARE YOU SURE YOU WANT THIS?"
|
|
print("If you are sure, type \""..code.."\" exactly.")
|
|
|
|
if io.read"*l" ~= code then return end
|
|
|
|
if not os.getenv"SUDO_COMMAND" then
|
|
print"Please run under sudo or as root."
|
|
return
|
|
end
|
|
|
|
if pcall(io.popen, "systemd --version") then
|
|
os.execute"systemctl stop ikibooru"
|
|
os.execute"systemctl disable ikibooru"
|
|
os.execute"rm /etc/systemd/system/ikibooru.service"
|
|
os.execute"systemctl daemon-reload"
|
|
end
|
|
|
|
local cfg = loadfile("/home/ikibooru/ikibooru/cfg.lua", "t", {})
|
|
|
|
local SQLConn = SQL.mysql():connect("", cfg.sqlu, cfg.sqlp, cfg.sqlh)
|
|
SQLConn:execute[[DROP DATABASE `ikibooru`;]]
|
|
|
|
os.execute"deluser ikibooru"
|
|
os.execute"rm -r /home/ikibooru"
|
|
|
|
print""
|
|
print"It was pleasure doing business." |