diff --git a/updater/bootstrappers/bootstrap-lin.sh b/updater/bootstrappers/bootstrap-lin.sh new file mode 100644 index 0000000..59420ba --- /dev/null +++ b/updater/bootstrappers/bootstrap-lin.sh @@ -0,0 +1,33 @@ +#!/bin/bash +MoveToTarget() { + #This takes to 2 arguments: source and target + echo ""$1" "$2"" + cp -rf "$1"/* "$2" + rm -r "$1" +} + +WaitForProcessToEnd() { + #This takes 1 argument. The PID to wait for + #Unlike the AutoIt version, this sleeps 1 second + while [ $(kill -0 "$1") ]; do + sleep 1 + done +} + +RunApplication() { + #This takes 1 application, the path to the thing to execute + python "$1" +} + +#our main code block +pid="$1" +SourcePath="$2" +DestPath="$3" +ToExecute="$4" +WaitForProcessToEnd $pid +MoveToTarget $SourcePath $DestPath +RunApplication $ToExecute +exit + + + diff --git a/updater/bootstrappers/bootstrap-mac.sh b/updater/bootstrappers/bootstrap-mac.sh new file mode 100644 index 0000000..71e49a7 --- /dev/null +++ b/updater/bootstrappers/bootstrap-mac.sh @@ -0,0 +1,36 @@ +#!/bin/bash -x +MoveToTarget() { + #This takes to 2 arguments: source and target + echo ""$1" "$2"" + cp -rf "$1"/* "$2" + rm -r "$1" +} + +WaitForProcessToEnd() { + #This takes 1 argument. The PID to wait for + #Unlike the AutoIt version, this sleeps 1 second + while [ $(kill -0 "$1") ]; do + sleep 1 + done +} + +RunApplication() { + #This takes 1 application, the path to the thing to execute + echo "toExec: "$1"" + exec "$1" +} + +#our main code block +pid="$1" +SourcePath="$2" +DestPath="$3" +ToExecute="$4" +WaitForProcessToEnd $pid +MoveToTarget "$SourcePath" "$DestPath" +RunApplication "$ToExecute" + +osascript< bytesReturned : Break : EndIf +cb*2 +ReDim pids(cb/4) +ForEver +Define.l nPids = bytesReturned/4 +Define.l i +For i = 0 To nPids-1 + If pids(i) = pid + ProcedureReturn 1 + EndIf +Next + ProcedureReturn 0 + EndProcedure +Procedure WaitForProcessToEnd(pid.l, timeout.l) + Protected h=OpenProcess_(#SYNCHRONIZE, 0, pid) + If h + WaitForSingleObject_(h, timeout) + CloseHandle_(h) + EndIf +EndProcedure +Procedure execute(program.s) + ShellExecute_(#Null, "open", program, #Null, #Null, #SW_NORMAL) +EndProcedure +Procedure kill(pid, exitcode) + Protected handle = OpenProcess_(#PROCESS_TERMINATE, 0, pid) +If handle > 0 + Protected r=TerminateProcess_(handle, exitcode) + CloseHandle_(handle) + ProcedureReturn r +EndIf +ProcedureReturn 0 +EndProcedure + +Define sd.s{#MAX_PATH} +GetSystemDirectory_(@sd, #MAX_PATH-1) +OpenLibrary(0, sd+"\psapi.dll") +Global EnumProcesses = GetFunction(0, "EnumProcesses") +If CountProgramParameters() < 4 + MessageBox_(0, "Please note: this is a stand-alone bootstrapper For the autoupdate facility. It cannot be run independently.", "Update Bootstrapper", 0) + End +EndIf +Define pid=Val(ProgramParameter(0)) +Define source.s = ProgramParameter(1) +Define dest.s = ProgramParameter(2) +Define prg.s = ProgramParameter(3) +WaitForProcessToEnd(pid, 500) +kill(pid, 1) +WaitForProcessToEnd(pid, 500) +moveToTarget(source, dest) +execute(prg) + +; IDE Options = PureBasic 4.51 (Windows - x86) +; CursorPosition = 62 +; FirstLine = 7 +; Folding = 1 +; EnableUnicode +; EnableXP +; EnableAdmin +; Executable = bootstrap.exe +; Compiler = PureBasic 4.51 (Windows - x86) +; IncludeVersionInfo +; VersionField0 = 1,2,0 +; VersionField1 = 5,0,1 +; VersionField2 = Mongoose Enterprises +; VersionField3 = Autoupdate Bootstrapper +; VersionField4 = 2.0 +; VersionField5 = 1.2.1 +; VersionField6 = Moves files around and relaunches the updated application. +; VersionField7 = bootstrap +; VersionField8 = bootstrap.pb +; VersionField17 = 0409 English (United States) \ No newline at end of file