aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--player/config.f903
-rw-r--r--player/instructions.f9087
-rw-r--r--player/main.F90 (renamed from player/main.f90)30
3 files changed, 112 insertions, 8 deletions
diff --git a/player/config.f90 b/player/config.f90
index 96c775c..c6c1b0c 100644
--- a/player/config.f90
+++ b/player/config.f90
@@ -4,5 +4,8 @@ implicit none
character(len=:), pointer::working_directory
character(len=:), pointer::logfile
character(len=1024)::captain
+
character(len=36)::token
+ character(len=256)::identity
+
end module config
diff --git a/player/instructions.f90 b/player/instructions.f90
index 8c671c4..ce28413 100644
--- a/player/instructions.f90
+++ b/player/instructions.f90
@@ -99,6 +99,25 @@ contains
end function get_task_string
+ function get_task_logical(j, i, component, res) result(found)
+ use json_module
+ implicit none
+
+ class(json_file)::j
+ integer, intent(in)::i
+ character(*), intent(in)::component
+ logical, intent(out)::res
+ logical::found
+
+ character(len=64)::label
+ character(len=:), allocatable::json_string_value
+
+ call task_component(i, component, label)
+
+ call j%get(trim(label), res, found)
+
+ end function get_task_logical
+
subroutine get_task_name(j, i, description)
use json_module
implicit none
@@ -147,7 +166,9 @@ contains
character(32)::operation
character(256)::url
character(256)::filename
+ character(256)::branch
+ logical::destructive
logical, dimension(4)::found
call get_task_operation(j, i, operation)
@@ -176,23 +197,81 @@ contains
else if(trim(operation) == "git_update") then
capture_filename => generate_temporary_filename()
- found(1) = get_task_string(j, i, "url", url)
- found(2) = get_task_string(j, i, "filename", filename)
+ found(1) = get_task_string(j, i, "origin", url)
+ found(2) = get_task_string(j, i, "branch", branch)
+ found(3) = get_task_string(j, i, "directory", filename)
+ found(4) = get_task_logical(j, i, "destructive", destructive)
+ if(.not. found(4)) then
+ destructive = .false.
+ found(4) = .true.
+ end if
+
if(.not. all(found,1)) then
success = .false.
else
- success = download(url, filename)
+ success = git_update(url, branch, filename, destructive, capture_filename)
end if
else if(trim(operation) == "shell") then
+ capture_filename => generate_temporary_filename()
+ found(1) = get_task_string(j, i, "command", url)
+ found(2) = get_task_string(j, i, "directory", filename)
+
+ if(.not. all(found,1)) then
+ success = .false.
+ else
+ success = shell(command, directory, capture_filename)
+ end if
else if(trim(operation) == "delete_tree") then
-
+ found(1) = get_task_string(j, i, "directory", filename)
+
+ if(.not. all(found,1)) then
+ success = .false.
+ else
+ success = delete_tree(command, directory, capture_filename)
+ end if
end if
end function perform_task
+ subroutine perform_tasks(j)
+ use json_module
+ implicit none
+
+ class(json_file)::j
+ integer::task_count
+ integer::i
+ logical::res
+
+ character(len=:), pointer::captured_filename
+
+ task_count = get_task_count(j)
+
+ do i = 1, task_count
+
+ res = perform_task(j, i, captured_filename)
+
+ if(associated(captured_filename)) then
+ if(res) then
+
+ else
+
+ exit
+ endif
+ else
+ if(res) then
+
+ else
+
+ exit
+ endif
+ end if
+ end do
+
+ end subroutine perform_tasks
+
end module instructions \ No newline at end of file
diff --git a/player/main.f90 b/player/main.F90
index cdf646e..127a8f7 100644
--- a/player/main.f90
+++ b/player/main.F90
@@ -7,6 +7,8 @@ implicit none
integer::slen
integer::i
+ identity = " "
+
i = 1
do while(i <= command_argument_count())
call get_command_argument(i, option)
@@ -30,6 +32,10 @@ implicit none
allocate(character(len=slen) :: logfile)
call get_command_argument(i, logfile)
+ else if(trim(option) == "-i") then
+ i = i + 1
+ call get_command_argument(i, identity)
+
end if
i = i + 1
@@ -58,11 +64,26 @@ implicit none
allocate(character(len=256) :: logfile)
logfile = "/tmp/levitating.log"
end if
-
+
+ ! Assign this computer an identity if not explicitly specified
+ if(len_trim(identity) == 0) then
+#ifdef GNU
+ call hostnm(identity)
+#else
+ Print *, "Could not determine host identity"
+ stop
+#endif
+ end if
+
! Change directory to the working directory now
call chdir(working_directory)
+
+ do while(.true.)
+
+ end do
+
contains
subroutine usage()
@@ -78,9 +99,10 @@ contains
Print *, " "
Print *, "Options:"
- Print *, " -h Display this help"
- Print *, " -w <dir> Use dir as the working directory"
- Print *, " -l <log> Use log as the logfile"
+ Print *, " -h Display this help"
+ Print *, " -w <dir> Use dir as the working directory"
+ Print *, " -l <log> Use log as the logfile"
+ Print *, " -i <identity> This players identity"
end subroutine usage