This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
BigSHinyToys's profile picture

[INSTALLER] file instlation from disk

Started by BigSHinyToys, 18 August 2012 - 06:45 PM
BigSHinyToys #1
Posted 18 August 2012 - 08:45 PM
This program is designed to install files from a disk to a computer.
Instructions:
note: this program is case sensitive
1 ) Put the bellow code into a file called "startup" on the disk
2 ) Create a folder called "install" on the disk
3 ) Put the files you want installed in the "install" folder
4 ) In install make a file called "LIST" in "install"
5 ) edit the file "LIST" to using the example A
6 ) reboot or run startup select y or n
7 ) install complete

Example A
Spoiler

program
user/program
programB
/startup
sysextract
win/exe
commander
win/programs/CMD
This Example shows four files and four file paths.
the file program is located "disk#/install/program" this file will be copied to "user" and named program
the file programB is located "disk#/install/programB" this file will be copied to the root of the computer and named "startup"
the file sysextract is located "disk#/install/sysextract" this file will be copied to the folder "win" named "exe"
the file commander is located "disk/install/commander" this file will be copied to the folder "win/programs" named "CMD"
the # is representing number it doesn't matter witch number disk it is or if other disks are connected to the same computer it will always install its own disk.
if a directory does not exist It will be created.
[WARNING]
if a previous file exists it will be over written.
as you can see this is extremely versatile allowing you to create what ever directory structurer you would like

Download
current stable ver 0.1
http://pastebin.com/wNxmzB35

pastebin get wNxmzB35 Installer
Spoiler

local ver = 0.1
local progName = "Random"
local bProblem = false
local function varifing()
	local sParth = shell.getRunningProgram()
		print("Parth:"..sParth)
	if fs.getName(sParth) == "startup" then
		local sDir = string.sub(sParth,1,#sParth-8)
		print("Disk: "..sDir)
		if fs.exists(sDir..[[]].."install") and fs.isDir(sDir..[[]].."install") and fs.exists(sDir..[[]].."install"..[[]].."LIST") and not fs.isDir(sDir..[[]].."install"..[[]].."LIST") then
			print("Found Install folder")
			file = io.open(sDir..[[]].."install"..[[]].."LIST","r")
			local tInstruction = {}
			local last = file:read()
			repeat
				table.insert(tInstruction,last)
				last = file:read()
				print(last)
			until last == nil
			file:close()
			-- check that files are avalible
			local tNames = {}
			local tParths = {}
			print("Cheking LIST :")
			local termX,termY = term.getCursorPos()
			for i = 1,#tInstruction do
				term.setCursorPos(termX,termY)
				term.clearLine()
				write("Completed: "..tostring((100/#tInstruction)*i)..[[ %]])
			  
				if math.fmod(i,2) == 1 then -- odd number
					table.insert(tNames,tInstruction[i])
				else -- even number
					table.insert(tParths,tInstruction[i])
				end
			end
			local proceed = true
			for i = 1,#tNames do
				if fs.exists(sDir..[[]].."install"..[[]]..tNames[i]) then
				else
					proceed = false
				end
			end
			if #tNames == #tParths then
			  
			else
				proceed = false
			end
			if proceed then
				--local tFileList = fs.list(sDir..[[]].."install")
				print("nInstalling ...")
				termX,termY = term.getCursorPos()
				for i = 1,#tNames do
					term.setCursorPos(termX,termY)
					term.clearLine()
					write("Completed: "..tostring((100/#tNames)*i)..[[ %]])
					local temp = tParths[i] -- ..[[]]..tNames[i]
					if fs.exists(temp) then -- fs.delete
						fs.delete(temp)
					end
					local temp2 = string.sub(temp,1,#temp - (string.len(fs.getName(temp))+1))
					if fs.isDir(temp2) then
					  
					else
						fs.makeDir(temp2)
					end
					fs.copy(sDir..[[]].."install"..[[]]..tNames[i],tParths[i])
				end
				print("nInstall Completed")
			else
				print("[ERROR] installer varification failed")
			end
		end
	end
end
while true do
	term.clear()
	term.setCursorPos(1,1)
	print("Welcom to Quick Install ver: "..ver)
	print("[WARNING] Will override existing Files")
	if bProblem then
		print("Please select y Y n or N ")
		bProblem = false
	end
	write("Do you want to install "..progName..[[ Y/N ]])
	local selection = string.lower(read())
	if selection == "y" then
		print("varifing Install")
		varifing()
		break
	elseif selection == "n" then
		print("Install aborted")
		break
	else
		bProblem = true
	end
end
MadCrayolaz #2
Posted 19 August 2012 - 12:04 AM
Question, how do I do the root directory on the computer?
And where do we make the folder?
BigSHinyToys #3
Posted 19 August 2012 - 05:02 AM
Question, how do I do the root directory on the computer?
And where do we make the folder?

make a disk
place it ina computer disk drive
place the above ^ code into a file called startup on that diks
make a folder called "install" on the disk
put files to be installed in "install"
make a file in "install" called LIST
follow instructions using EXAMPLE A to create LIST file

reboot or run startup and it will start installer
MadCrayolaz #4
Posted 19 August 2012 - 03:55 PM
make a disk
place it ina computer disk drive
place the above ^ code into a file called startup on that diks
make a folder called "install" on the disk
put files to be installed in "install"
make a file in "install" called LIST
follow instructions using EXAMPLE A to create LIST file

reboot or run startup and it will start installer

Doesn't answer my question of how I use the root directory as the install location.
BigSHinyToys #5
Posted 20 August 2012 - 11:58 AM
you have found a bug I apologist for now the simplest way is to put a slash in front.
this is fixed example

program
user/program
programB
/startup
sysextract
win/exe
commander
win/programs/CMD
that will work i have tested it