Author: arkurth
Date: Tue Aug  1 15:43:55 2017
New Revision: 1803661

URL: http://svn.apache.org/viewvc?rev=1803661&view=rev
Log:
VCL-1065
Reverted changes to update_cygwin.cmd previously committed which added an 
attempt to call mkgroup.exe and mkpasswd.exe with "-l localhost" arguments. 
Added sed.exe commands to strip the '<HOST>+ section from the beginning of 
lines in group and passwd if it exists.

Removed "-t rsa1" argument from ssh-keygen.exe command. Recent versions don't 
support this and display an error. Without the argument, the key will be 
generated with the default type.

Added command at the end of update_cygwin.cmd to delete the 'VCL Update Cygwin' 
scheduled task if it exists. It doesn't need to be called on every reboot.

Added call to Windows.pm::post_load to delete the 'VCL Post Load' scheduled 
task if it exists. Also added identical call to 
Windows.pm::create_update_cygwin_startup_scheduled_task to make sure that both 
the 'VCL Post Load' and 'VCL Update Cygwin' scheduled tasks don't both exist 
because they cause conflicts.

Added call to 8.pm::pre_capture to delete the 'VCL Update Cygwin' scheduled 
task if it exists before adding the 'VCL Post Load' scheduled task.

Added '/RL HIGHEST' argument to schtasks.exe call in 
Windows.pm::create_startup_scheduled_task. It causes the task to run with 
"highest privileges". This seems to have corrected issues on at least one image 
where update_cygwin.cmd failed to run because of what seems to be a UAC issue.

Added call to Windows.pm::create_update_cygwin_startup_scheduled_task to copy 
the update_cygwin.cmd file from the management node to ensure the most recent 
copy is used.

Modified:
    vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm
    vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_6/8.pm
    vcl/trunk/managementnode/tools/Windows/Scripts/update_cygwin.cmd

Modified: vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm
URL: 
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm?rev=1803661&r1=1803660&r2=1803661&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm Tue Aug  1 15:43:55 
2017
@@ -1012,6 +1012,15 @@ sub post_load {
 
 =item *
 
+ Delete the VCL Post Load' scheduled task if it exists
+
+=cut
+
+       # Make sure the 'VCL Post Load' task is removed up if it exists to 
avoid conflicts
+       $self->delete_scheduled_task('VCL Post Load');
+
+=item *
+
  Call OS.pm::post_load
 
 =cut
@@ -3599,7 +3608,7 @@ sub create_startup_scheduled_task {
        # Run schtasks.exe to add the task
        # Occasionally see this error even though it schtasks.exe returns exit 
status 0:
        # WARNING: The Scheduled task "System Startup Script" has been created, 
but may not run because the account information could not be set.
-       my $command = "$system32_path/schtasks.exe /Create /RU \"$task_user\" 
/RP \"$task_password\" /SC ONSTART /TN \"$task_name\" /TR \"$task_command\"";
+       my $command = "$system32_path/schtasks.exe /Create /RU \"$task_user\" 
/RP \"$task_password\" /RL HIGHEST /SC ONSTART /TN \"$task_name\" /TR 
\"$task_command\"";
        my ($exit_status, $output) = $self->execute($command);
        if (!defined($output)) {
                notify($ERRORS{'WARNING'}, 0, "failed to execute ssh command 
created scheduled task '$task_name' on $computer_node_name");
@@ -3640,6 +3649,7 @@ sub create_update_cygwin_startup_schedul
        }
        
        my $request_state = $self->data->get_request_state_name();
+       my $node_configuration_directory = 
$self->get_node_configuration_directory();
        
        my $root_password;
        if ($request_state =~ /(image|checkpoint)/) {
@@ -3660,8 +3670,13 @@ sub create_update_cygwin_startup_schedul
                return;
        }
        
+       # Make sure the 'VCL Post Load' task doesn't exist or they will conflict
+       $self->delete_scheduled_task('VCL Post Load');
+       
+       # Copy the current version of update_cygwin.cmd to the computer
+       
$self->copy_file_to("$SOURCE_CONFIGURATION_DIRECTORY/Scripts/update_cygwin.cmd",
 "$node_configuration_directory/Scripts/update_cygwin.cmd");
+
        # Create a scheduled task to run post_load.cmd when the image boots
-       my $node_configuration_directory = 
$self->get_node_configuration_directory();
        my $task_command = 
"$node_configuration_directory/Scripts/update_cygwin.cmd >> 
$node_configuration_directory/Logs/update_cygwin.log";
        if ($self->create_startup_scheduled_task('VCL Update Cygwin', 
$task_command, 'root', $root_password)) {
                $self->{created_update_cygwin_startup_scheduled_task} = 1;

Modified: vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_6/8.pm
URL: 
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_6/8.pm?rev=1803661&r1=1803660&r2=1803661&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_6/8.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_6/8.pm Tue Aug  
1 15:43:55 2017
@@ -121,13 +121,15 @@ sub pre_capture {
                return;
        }
        
+       # Make sure the 'VCL Update Cygwin' task doesn't exist or they will 
conflict
+       $self->delete_scheduled_task('VCL Update Cygwin');
+       
        # Create a scheduled task to run post_load.cmd when the image boots
-       my $task_name     = 'VCL Post Load';
        my $task_command  = 
"$node_configuration_directory/Scripts/post_load.cmd > 
$node_configuration_directory/Logs/post_load.log";
        my $task_user     = 'root';
        my $task_password = $WINDOWS_ROOT_PASSWORD;
-       if (!$self->create_startup_scheduled_task($task_name, $task_command, 
$task_user, $task_password)) {
-               notify($ERRORS{'WARNING'}, 0, "failed to create '$task_name' 
scheduled task");
+       if (!$self->create_startup_scheduled_task('VCL Post Load', 
$task_command, $task_user, $task_password)) {
+               notify($ERRORS{'WARNING'}, 0, "failed to create 'VCL Post Load' 
scheduled task");
                return;
        }
        

Modified: vcl/trunk/managementnode/tools/Windows/Scripts/update_cygwin.cmd
URL: 
http://svn.apache.org/viewvc/vcl/trunk/managementnode/tools/Windows/Scripts/update_cygwin.cmd?rev=1803661&r1=1803660&r2=1803661&view=diff
==============================================================================
--- vcl/trunk/managementnode/tools/Windows/Scripts/update_cygwin.cmd (original)
+++ vcl/trunk/managementnode/tools/Windows/Scripts/update_cygwin.cmd Tue Aug  1 
15:43:55 2017
@@ -64,17 +64,24 @@ echo ERRORLEVEL: %ERRORLEVEL%
 echo.
 
 echo %TIME%: Creating new "group" file...
-C:\Cygwin\bin\mkgroup.exe -l localhost || C:\Cygwin\bin\mkgroup.exe -l > 
C:\Cygwin\etc\group
+C:\Cygwin\bin\mkgroup.exe -l > C:\Cygwin\etc\group
 echo ERRORLEVEL: %ERRORLEVEL%
 set /A STATUS+=%ERRORLEVEL%
 echo.
 
-echo %TIME%: Creating new "passwd" file and changing root's primary group from 
'None' to 'None'
-C:\Cygwin\bin\mkpasswd.exe -l localhost || C:\Cygwin\bin\mkpasswd.exe -l | 
C:\Cygwin\bin\sed.exe -e 's/\(^root.*:\)513\(:.*\)/\1544\2/' > 
C:\Cygwin\etc\passwd
+echo %TIME%: Creating new "passwd" file
+C:\Cygwin\bin\mkpasswd.exe -l > C:\Cygwin\etc\passwd
 echo ERRORLEVEL: %ERRORLEVEL%
 set /A STATUS+=%ERRORLEVEL%
 echo.
 
+rem Remove leading computer name: VCLV98-249+root: --> root:
+C:\Cygwin\bin\sed.exe -i -e "s/^[^:]\++//" /etc/group
+C:\Cygwin\bin\sed.exe -i -e "s/^[^:]\++//" /etc/passwd
+
+rem Change root's primary group from 'None' to 'Administrators'
+C:\Cygwin\bin\sed.exe -i -e "s/\(^root:.*:\)\(513\|197121\)\(:.*\)/\1544\3/" 
/etc/passwd
+
 echo ----------------------------------------------------------------------
 
 echo %TIME%: Restoring ownership of /etc/ssh* files...
@@ -115,7 +122,7 @@ echo ERRORLEVEL: %ERRORLEVEL%
 echo.
 
 echo %TIME%: Regenerating /etc/ssh_host_key...
-C:\Cygwin\bin\bash.exe -c 'C:/Cygwin/bin/ssh-keygen.exe -t rsa1 -f 
/etc/ssh_host_key -N ""' 2>&1
+C:\Cygwin\bin\bash.exe -c 'C:/Cygwin/bin/ssh-keygen.exe -f /etc/ssh_host_key 
-N ""' 2>&1
 echo ERRORLEVEL: %ERRORLEVEL%
 set /A STATUS+=%ERRORLEVEL%
 echo.
@@ -134,6 +141,29 @@ echo.
 
 echo ----------------------------------------------------------------------
 
+echo %TIME%: Killing any cyg* processes...
+"%SystemRoot%\System32\taskkill.exe" /F /FI "IMAGENAME eq cyg*" 2>NUL
+echo ERRORLEVEL: %ERRORLEVEL%
+echo.
+
+echo %TIME%: Killing any ssh* processes...
+"%SystemRoot%\System32\taskkill.exe" /F /FI "IMAGENAME eq ssh*" 2>NUL
+echo ERRORLEVEL: %ERRORLEVEL%
+echo.
+
+echo %TIME%: Killing any bash* processes...
+"%SystemRoot%\System32\taskkill.exe" /F /FI "IMAGENAME eq bash*" 2>NUL
+echo ERRORLEVEL: %ERRORLEVEL%
+echo.
+
+echo %TIME%: Killing any ash* processes...
+"%SystemRoot%\System32\taskkill.exe" /F /FI "IMAGENAME eq ash*" 2>NUL
+echo ERRORLEVEL: %ERRORLEVEL%
+echo.
+
+echo %TIME%: Tasks running before attempting to executing rebaseall:
+"%SystemRoot%\System32\tasklist.exe" /V
+
 echo %TIME%: Running /usr/bin/rebaseall in the ash.exe shell
 C:\cygwin\bin\ash.exe -c '/usr/bin/rebaseall' 2>&1
 echo ERRORLEVEL: %ERRORLEVEL%
@@ -153,6 +183,14 @@ echo %TIME%: Starting the sshd service..
 echo ERRORLEVEL: %ERRORLEVEL%
 set /A STATUS+=%ERRORLEVEL%
 echo.
+
+echo ----------------------------------------------------------------------
+
+echo %TIME%: Deleting 'VCL Update Cygwin' scheduled task...
+"%SystemRoot%\system32\schtasks.exe" /Delete /F /TN "VCL Update Cygwin"
+echo ERRORLEVEL: %ERRORLEVEL%
+set /A STATUS+=%ERRORLEVEL%
+echo.
 
 echo ----------------------------------------------------------------------
 


Reply via email to