Made the setup not work in root.
This commit is contained in:
@@ -9,17 +9,17 @@ lib C
|
|||||||
fun getuid : UInt32
|
fun getuid : UInt32
|
||||||
end
|
end
|
||||||
|
|
||||||
if C.getuid != 0
|
|
||||||
puts "#{red}#{bold}You must be in root to install wfetch!#{reset}"
|
|
||||||
exit(0)
|
|
||||||
end
|
|
||||||
|
|
||||||
sudo_user = ENV["SUDO_USER"]?
|
sudo_user = ENV["SUDO_USER"]?
|
||||||
home = "/home/#{sudo_user}"
|
home = "/home/#{sudo_user}"
|
||||||
|
|
||||||
OptionParser.parse do |parser|
|
OptionParser.parse do |parser|
|
||||||
parser.banner = "Usage: installer [arguments]"
|
parser.banner = "Usage: installer [arguments]"
|
||||||
parser.on("-i", "--install-only", "Only instals wfetch; Does not run setup") {
|
parser.on("-i", "--install-only", "Only instals wfetch; Does not run setup") {
|
||||||
|
if C.getuid != 0
|
||||||
|
puts "#{red}#{bold}You must be in root to install wfetch!#{reset}"
|
||||||
|
exit(0)
|
||||||
|
end
|
||||||
|
|
||||||
puts "#{orange}#{bold}wfetch installer 1.0.0#{reset}"
|
puts "#{orange}#{bold}wfetch installer 1.0.0#{reset}"
|
||||||
|
|
||||||
File.copy("data/wfetch", "/usr/bin/wfetch")
|
File.copy("data/wfetch", "/usr/bin/wfetch")
|
||||||
@@ -28,6 +28,11 @@ OptionParser.parse do |parser|
|
|||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
parser.on("-u", "--uninstall", "Uninstalls wfetch"){
|
parser.on("-u", "--uninstall", "Uninstalls wfetch"){
|
||||||
|
if C.getuid != 0
|
||||||
|
puts "#{red}#{bold}You must be in root to uninstall wfetch!#{reset}"
|
||||||
|
exit(0)
|
||||||
|
end
|
||||||
|
|
||||||
File.delete("/usr/bin/wfetch")
|
File.delete("/usr/bin/wfetch")
|
||||||
File.delete("#{home}/.local/share/Wfetch/disp.toml")
|
File.delete("#{home}/.local/share/Wfetch/disp.toml")
|
||||||
File.delete("#{home}/.local/share/Wfetch/config.toml")
|
File.delete("#{home}/.local/share/Wfetch/config.toml")
|
||||||
@@ -36,6 +41,11 @@ OptionParser.parse do |parser|
|
|||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
parser.on("-s", "--setup", "Runs setup") {
|
parser.on("-s", "--setup", "Runs setup") {
|
||||||
|
if C.getuid = 0
|
||||||
|
puts "#{red}#{bold}Don't run the setup in root!#{reset}"
|
||||||
|
exit(0)
|
||||||
|
end
|
||||||
|
|
||||||
Dir.mkdir("/home/#{sudo_user}/.local/share/Wfetch")
|
Dir.mkdir("/home/#{sudo_user}/.local/share/Wfetch")
|
||||||
|
|
||||||
|
|
||||||
@@ -81,38 +91,5 @@ OptionParser.parse do |parser|
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
puts "#{orange}#{bold}wfetch installer 1.0.0#{reset}"
|
if ARGV.empty?
|
||||||
|
puts "Run installer -h"
|
||||||
File.copy("data/wfetch", "/usr/bin/wfetch")
|
|
||||||
|
|
||||||
puts "#{orange}#{bold}Finished installing! Let's setup.#{reset}"
|
|
||||||
|
|
||||||
puts "Please enter your WeatherApi key (Learn to get one at README.md):"
|
|
||||||
|
|
||||||
api = gets
|
|
||||||
|
|
||||||
puts "Please enter the (closest) city you live in: "
|
|
||||||
|
|
||||||
city = gets
|
|
||||||
|
|
||||||
puts "#{orange}#{bold}Config setup finished. Starting disp setup.#{reset}"
|
|
||||||
|
|
||||||
File.write("/home/#{sudo_user}/.local/share/Wfetch/config.toml", "
|
|
||||||
api = \"#{api}\"
|
|
||||||
city = \"#{city}\"")
|
|
||||||
|
|
||||||
puts "#{orange}#{bold}Would you like customary (1), metric (2), or both (3)?#{reset}"
|
|
||||||
|
|
||||||
choice = gets
|
|
||||||
|
|
||||||
if choice == "1"
|
|
||||||
File.copy("data/1.toml", "/home/#{sudo_user}/.local/share/Wfetch/disp.toml")
|
|
||||||
elsif choice == "2"
|
|
||||||
File.copy("data/2.toml", "/home/#{sudo_user}/.local/share/Wfetch/disp.toml")
|
|
||||||
elsif choice == "3"
|
|
||||||
File.copy("data/3.toml", "/home/#{sudo_user}/.local/share/Wfetch/disp.toml")
|
|
||||||
else
|
|
||||||
File.copy("data/1.toml", "/home/#{sudo_user}/.local/share/Wfetch/disp.toml")
|
|
||||||
end
|
|
||||||
|
|
||||||
puts "#{orange}#{bold}Install finnished. Enjoy!#{reset}"
|
|
||||||
Reference in New Issue
Block a user