commit f69924e63f8d2a16d075bf1be4308968120dd31c Author: Daniel Berteaud Date: Wed Dec 9 18:21:43 2015 +0100 First commit Move FWSUpdates into its own package diff --git a/createlinks b/createlinks new file mode 100644 index 0000000..c4e8d65 --- /dev/null +++ b/createlinks @@ -0,0 +1,6 @@ +#!/usr/bin/perl -w + +use esmith::Build::CreateLinks qw(:all); + +templates2events("/home/e-smith/files/shares/wpkg/files/settings/fwsupdates/adm_conf.bat", qw(wpkg-update bootstrap-console-save)); +templates2events("/home/e-smith/files/shares/wpkg/files/settings/fwsupdates/user_conf.bat", qw(wpkg-update bootstrap-console-save)); diff --git a/packages/fwsupdates.xml b/packages/fwsupdates.xml new file mode 100755 index 0000000..0dcf425 --- /dev/null +++ b/packages/fwsupdates.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/root/etc/e-smith/templates/home/e-smith/files/shares/wpkg/files/settings/fwsupdates/adm_conf.bat/10All b/root/etc/e-smith/templates/home/e-smith/files/shares/wpkg/files/settings/fwsupdates/adm_conf.bat/10All new file mode 100644 index 0000000..53733ad --- /dev/null +++ b/root/etc/e-smith/templates/home/e-smith/files/shares/wpkg/files/settings/fwsupdates/adm_conf.bat/10All @@ -0,0 +1,21 @@ +{ + +my $pass = $wpkg{'UserPassword'}; +my $repo = $wpkg{'RepositoryUri'} || 'https://pkgs.' . $DomainName; +my $logs = $wpkg{'LogsUri'} || 'https://pkglogs.' . $DomainName; +my $delay = $wpkg{'RandomDelay'} || '600'; +my $report = $wpkg{'MaxReportDays'} || '7'; + +my $out .=<<"_EOF"; +SET USER=deploiement +SET PASS=$pass +SET REPO=$repo +SET LOGS=$logs +SET RANDOM_DELAY=600 +SET MAX_REPORT=7 +_EOF + +$out =~ s/\n/\r\n/g; +$OUT = $out; + +} diff --git a/root/etc/e-smith/templates/home/e-smith/files/shares/wpkg/files/settings/fwsupdates/adm_conf.bat/template-begin b/root/etc/e-smith/templates/home/e-smith/files/shares/wpkg/files/settings/fwsupdates/adm_conf.bat/template-begin new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/e-smith/templates/home/e-smith/files/shares/wpkg/files/settings/fwsupdates/user_conf.bat/10All b/root/etc/e-smith/templates/home/e-smith/files/shares/wpkg/files/settings/fwsupdates/user_conf.bat/10All new file mode 100644 index 0000000..650ebd5 --- /dev/null +++ b/root/etc/e-smith/templates/home/e-smith/files/shares/wpkg/files/settings/fwsupdates/user_conf.bat/10All @@ -0,0 +1,12 @@ +{ + +my $report = $wpkg{'MaxReportDays'} || '7'; + +my $out .=<<"_EOF"; +SET MAX_REPORT=7 +_EOF + +$out =~ s/\n/\r\n/g; +$OUT = $out; + +} diff --git a/root/etc/e-smith/templates/home/e-smith/files/shares/wpkg/files/settings/fwsupdates/user_conf.bat/template-begin b/root/etc/e-smith/templates/home/e-smith/files/shares/wpkg/files/settings/fwsupdates/user_conf.bat/template-begin new file mode 100644 index 0000000..e69de29 diff --git a/root/home/e-smith/files/shares/tools/files/scripts/fwsupdates/install.bat b/root/home/e-smith/files/shares/tools/files/scripts/fwsupdates/install.bat new file mode 100644 index 0000000..a00bbb8 --- /dev/null +++ b/root/home/e-smith/files/shares/tools/files/scripts/fwsupdates/install.bat @@ -0,0 +1,28 @@ +call %~dp0\conf.bat +if not exist "%SYSTEMROOT%\system32\GroupPolicy\Machine\Scripts\Shutdown" mkdir "%SYSTEMROOT%\system32\GroupPolicy\Machine\Scripts\Shutdown" +copy /Y "\\%IPASSERELLE_IP%\wpkg\softwares\fwsupdates\fwsupdates.vbs" "%SYSTEMROOT%\system32\GroupPolicy\Machine\Scripts\Shutdown\" +del /q "%SYSTEMROOT%\system32\GroupPolicy\Machine\Scripts\Shutdown\wpkg.bat" +if not exist "%SystemDrive%\FWSUpdates" mkdir "%SystemDrive%\FWSUpdates" +xcopy /E /Y "\\%IPASSERELLE_IP%\wpkg\softwares\fwsupdates\FWSUpdates\*" "%SystemDrive%\FWSUpdates\" +if not exist "%SystemDrive%\FWSUpdates\repository" mkdir "%SystemDrive%\FWSUpdates\repository" +if not exist "%SystemDrive%\FWSUpdates\status" mkdir "%SystemDrive%\FWSUpdates\status" +if not exist "%SystemDrive%\FWSUpdates\conf\adm" mkdir "%SystemDrive%\FWSUpdates\conf\adm" +if not exist "%SystemDrive%\FWSUpdates\conf\user" mkdir "%SystemDrive%\FWSUpdates\conf\user" +if not exist "%SystemDrive%\FWSUpdates\prodkeys" mkdir "%SystemDrive%\FWSUpdates\prodkeys" +copy /Y "\\%IPASSERELLE_IP%\wpkg\settings\fwsupdates\adm_conf.bat" "%SystemDrive%\FWSUpdates\conf\adm\conf.bat" +copy /Y "\\%IPASSERELLE_IP%\wpkg\settings\fwsupdates\user_conf.bat" "%SystemDrive%\FWSUpdates\conf\user\conf.bat" +icacls.exe "%SystemDrive%\FWSUpdates" /inheritance:d /t /c /q +REM Authenticated users +icacls.exe "%SystemDrive%\FWSUpdates" /remove:g "*S-1-5-11" /t /c /q +REM Some rep are not accessible at all by simple users +icacls.exe "%SystemDrive%\FWSUpdates\repository" /remove:g "*S-1-5-32-545" /t /c /q +icacls.exe "%SystemDrive%\FWSUpdates\status" /remove:g "*S-1-5-32-545" /t /c /q +icacls.exe "%SystemDrive%\FWSUpdates\conf\adm" /remove:g "*S-1-5-32-545" /t /c /q +icacls.exe "%SystemDrive%\FWSUpdates\prodkeys" /remove:g "*S-1-5-32-545" /t /c /q +copy /Y "\\%IPASSERELLE_IP%\wpkg\softwares\fwsupdates\chkupd_bgmon.vbs" "%ALLUSERSPROFILE%\Microsoft\Windows\Start Menu\Programs\Startup\" +regedit /S "\\%IPASSERELLE_IP%\wpkg\settings\fwsupdates\gp.reg" +regedit /S "\\%IPASSERELLE_IP%\wpkg\settings\fwsupdates\dav_limit.reg" +regini "\\%IPASSERELLE_IP%\wpkg\settings\fwsupdates\run_on_shutdown_reg.txt" +cscript //Nologo "\\%IPASSERELLE_IP%\wpkg\softwares\fwsupdates\localgp.vbs" fwsupdates.vbs false MACHINE +cscript "\\%IPASSERELLE_IP%\wpkg\software\fwsupdates\create_shortcut.vbs" +schtasks.exe /Create /tn "sync_wpkg" /sc hourly /mo 3 /ru "SYSTEM" /tr "%SystemDrive%\FWSUpdates\bin\delayed_sync.bat" /f diff --git a/softwares/FWSUpdates/assets/img/fws.bmp b/softwares/FWSUpdates/assets/img/fws.bmp new file mode 100644 index 0000000..c11355c Binary files /dev/null and b/softwares/FWSUpdates/assets/img/fws.bmp differ diff --git a/softwares/FWSUpdates/assets/img/fws.ico b/softwares/FWSUpdates/assets/img/fws.ico new file mode 100644 index 0000000..f790708 Binary files /dev/null and b/softwares/FWSUpdates/assets/img/fws.ico differ diff --git a/softwares/FWSUpdates/bin/WizApp.exe b/softwares/FWSUpdates/bin/WizApp.exe new file mode 100644 index 0000000..e9d2f00 Binary files /dev/null and b/softwares/FWSUpdates/bin/WizApp.exe differ diff --git a/softwares/FWSUpdates/bin/chkupd.bat b/softwares/FWSUpdates/bin/chkupd.bat new file mode 100644 index 0000000..bd643a0 --- /dev/null +++ b/softwares/FWSUpdates/bin/chkupd.bat @@ -0,0 +1,178 @@ +REM @echo off +setlocal enabledelayedexpansion + +REM Detect if we have admin rights +SET /A ADMIN=0 +net session 1>NUL 2>NUL +IF %ERRORLEVEL% EQU 0 SET /A ADMIN=1 + +IF %ADMIN% EQU 1 CALL %~dp0\..\conf\adm\conf.bat +IF %ADMIN% NEQ 1 CALL %~dp0\..\conf\user\conf.bat + +SET /A WAIT=0 + +CALL %~dp0\..\lang\en.bat +FOR /F "tokens=3" %%A IN ('reg query "HKLM\System\CurrentControlSet\Control\nls\Language" /v Installlanguage') DO SET LANG=%%A +IF EXIST %~dp0\..\lang\%LANG%.bat CALL %~dp0\..\lang\%LANG%.bat + +SET watitle=%L_WINDOW_TITLE% +SET wasig=%L_WINDOW_SIG% +SET walabels=%L_BTN_PREV%;%L_BTN_NEXT%;%L_BTN_OK%;%L_BTN_CANCEL% +SET wabmp=%SystemDrive%\FWSUpdates\assets\img\fws.bmp +SET waico=%SystemDrive%\FWSUpdates\assets\img\fws.ico +SET wabat=%TEMP%\fwsupdates_resp.bat + +:loop +IF NOT "%1" == "loop" IF NOT %WAIT% EQU 0 goto :EOF +timeout /t %WAIT% 1>NUL 2>NUL + +:begin + +SET /A WAIT=300 +SET /A SYNC_IN_PROGRESS=0 +SET /A RUN_ON_SHUTDOWN=0 + +REM Wait if a sync is running +reg query "HKLM\Software\FWS\Updates" /v SyncInProgress 1>NUL 2>NUL +IF %ERRORLEVEL% EQU 0 FOR /F "tokens=3" %%A IN ('reg query "HKLM\Software\FWS\Updates" /v SyncInProgress') DO SET /A SYNC_IN_PROGRESS=%%A +IF %SYNC_IN_PROGRESS% EQU 1 ( + IF "%1" == "loop" goto loop + SET watext=%L_SYNC_ALREADY_IN_PROGRESS% + start /w %SystemDrive%\FWSUpdates\bin\wizapp.exe FINISH NOBACK NOCANCEL TB + goto :EOF +) + +REM if updates are already scheduled for next shutdown, just quit now, there's no point in looping +reg query "HKLM\Software\FWS\Updates\User" /v RunOnShutdown 1>NUL 2>NUL +IF %ERRORLEVEL% EQU 0 FOR /F "tokens=3" %%A IN ('reg query "HKLM\Software\FWS\Updates\User" /v RunOnShutdown') DO SET /A RUN_ON_SHUTDOWN=%%A +IF %RUN_ON_SHUTDOWN% EQU 0 ( + reg query "HKLM\Software\FWS\Updates" /v RunOnShutdown 1>NUL 2>NUL + IF %ERRORLEVEL% EQU 0 FOR /F "tokens=3" %%A IN ('reg query "HKLM\Software\FWS\Updates" /v RunOnShutdown') DO SET /A RUN_ON_SHUTDOWN=%%A +) +IF %RUN_ON_SHUTDOWN% EQU 1 ( + IF "%1" == "loop" goto :EOF + IF %ADMIN% NEQ 1 ( + SET watext=%L_ALREADY_SCHEDULED_ON_SHUTDOWN% + start /w %SystemDrive%\FWSUpdates\bin\wizapp.exe FINISH NOBACK NOCANCEL TB + goto :EOF + ) +) + +SET CHANGES=0 +reg query "HKLM\Software\FWS\Updates" /v PendingChanges 1>NUL 2>NUL +IF %ERRORLEVEL% EQU 0 FOR /F "tokens=3" %%A IN ('reg query "HKLM\Software\FWS\Updates" /v PendingChanges') DO SET /A CHANGES=%%A +IF %CHANGES% LSS 1 IF %ADMIN% NEQ 1 ( + IF "%1" == "loop" goto loop + SET watext=%L_NO_UPDATE_AVAILABLE% %L_FOR_YOUR_SYSTEM%. + start /w %SystemDrive%\FWSUpdates\bin\wizapp.exe FINISH NOBACK NOCANCEL TB + goto :EOF +) + +SET /A NOW=%DATE:~-4%%DATE:~3,2%%DATE:~0,2% +SET /A SINCE=%NOW% +reg query "HKLM\Software\FWS\Updates" /v ChangesAvailableSince 1>NUL 2>NUL +IF %ERRORLEVEL% EQU 0 OR /F "tokens=3 delims= " %%A IN ('reg query "HKLM\Software\FWS\Updates" /v ChangesAvailableSince') DO SET /A SINCE=%%A + +REM Some wording changes if there's only 1 single change to apply +IF %CHANGES% EQU 1 ( + SET INTRO=1 %L_ONE_UPDATE_AVAILABLE% + SET AVAILABLE_SINCE=%L_ONE_UPDATE_AVAILABLE_SINCE% +) ELSE ( + SET INTRO=%CHANGES% %L_X_UPDATES_AVAILABLE% + SET AVAILABLE_SINCE=%L_X_UPDATES_AVAILABLE_SINCE% +) + +REM Compute how many days left we can delay updates +SET /A MAX=%SINCE%+%MAX_REPORT% +SET /A AGE=%NOW%-%SINCE% +SET /A REMAINING=%MAX%-%NOW% + +REM Non admin on RDP shouldn't see updates notif +IF %ADMIN% NEQ 1 IF NOT "%SESSIONNAME%" == "Console" goto :EOF + +REM Check if we can delay updates +REM Users can only delay for %MAX_REPORT% days while admins can always delay +SET /A CAN_REPORT=0 +IF %NOW% LEQ %MAX% SET /A CAN_REPORT=1 +IF %ADMIN% EQU 1 SET /A CAN_REPORT=1 + +IF %CHANGES% LSS 1 IF %ADMIN% EQU 1 ( + SET watext=%L_NO_UPDATE_AVAILABLE% %L_FOR_YOUR_SYSTEM%. + SET wainput= %L_CHECK_ONLINE_FOR_UPDATES% + SET waoutnum=0 + start /w %SystemDrive%\FWSUpdates\bin\wizapp.exe NOBACK RB + IF errorlevel 2 goto cancel_no_update + IF errorlevel 1 goto previous + IF !waoutnum! EQU 0 goto check +) +ELSE ( + IF %CAN_REPORT% EQU 1 ( + SET watext=%INTRO% %L_FOR_YOUR_SYSTEM%.~~%L_YOU_CAN_SCHEDULE%.~~%L_INSTALL_FORCED_IN% %REMAINING% %L_DAYS% + SET wainput= %L_SCHEDULE_ON_SHUTDOWN%; %L_REPORT% + IF %ADMIN% EQU 1 ( + IF %RUN_ON_SHUTDOWN% NEQ 1 ( + SET wainput= %L_SCHEDULE_ON_SHUTDOWN%; %L_REPORT%; %L_INSTALL_NOW%; %L_CHECK_ONLINE_FOR_UPDATES% + ) ELSE ( + SET watext=%INTRO% %L_FOR_YOUR_SYSTEM%.~~%L_ALREADY_SCHEDULED_ON_SHUTDOWN%.~~%L_INSTALL_FORCED_IN% %REMAINING% %L_DAYS% + SET wainput= %L_MAINTAIN_ON_SHUTDOWN%; %L_CANCEL_SCHEDULE_ON_SHUTDOWN%; %L_INSTALL_NOW%; %L_CHECK_ONLINE_FOR_UPDATES% + ) + ) + + SET waoutnum=0 + + start /w %SystemDrive%\FWSUpdates\bin\wizapp.exe NOBACK RB + IF errorlevel 2 goto cancel + IF errorlevel 1 goto previous + CALL %wabat% + IF !waoutnum! EQU 0 goto shutdown + IF !waoutnum! EQU 1 goto later + IF !waoutnum! EQU 2 goto now + IF !waoutnum! EQU 3 goto check + ) ELSE ( + SET watext=%INTRO% %L_FOR_YOUR_SYSTEM%.~~%AVAILABLE_SINCE% %L_SINCE% %AGE% %L_DAYS%.~~%L_CANT_REPORT_ANYMORE% + start /w %SystemDrive%\FWSUpdates\bin\wizapp.exe FINISH TB + goto :shutdown + ) +) + +goto :loop + +:cancel +goto :later + +:cancel_no_update +goto :EOF + +:previous +goto :loop + +:later +reg del "HKLM\Software\FWS\Updates\User" /v RunOnShutdown /f 1>NUL 2>NUL +IF %ADMIN% EQU 1 reg del "HKLM\Software\FWS\Updates" /v RunOnShutdown /f 1>NUL 2>NUL +SET watext=%L_UPDATES_REPORTED%. +start /w %SystemDrive%\FWSUpdates\bin\wizapp.exe FINISH NOBACK TB +SET /A WAIT=WAIT+10800 +goto loop + +:shutdown +reg add "HKLM\Software\FWS\Updates\User" /v RunOnShutdown /t REG_DWORD /d 1 /f +SET watext=%L_UPDATES_SCHEDULED% +%SystemDrive%\FWSUpdates\bin\wizapp.exe FINISH NOBACK TB +goto :EOF + +:now +IF %ADMIN% NEQ 1 goto later +CALL %~dp0\wpkg_feedback.bat %CHANGES% +SET watext=%L_UPDATES_FINISHED% +start /w %SystemDrive%\FWSUpdates\bin\wizapp.exe FINISH NOBACK NOCANCEL TB +goto :loop + +:check +IF %ADMIN% NEQ 1 goto later +SET watext=%L_CHECKING_UPDATES% +start /w %SystemDrive%\FWSUpdates\bin\wizapp.exe PB OPEN NOBACK NOCANCEL +start /w %SystemDrive%\FWSUpdates\bin\wizapp.exe PB UPDATE 10 +CALL %~dp0\sync.bat +start /w %SystemDrive%\FWSUpdates\bin\wizapp.exe PB CLOSE +goto begin + diff --git a/softwares/FWSUpdates/bin/chkupd_launcher.bat b/softwares/FWSUpdates/bin/chkupd_launcher.bat new file mode 100644 index 0000000..c2c45a5 --- /dev/null +++ b/softwares/FWSUpdates/bin/chkupd_launcher.bat @@ -0,0 +1,2 @@ +@echo off +start /min %~dp0\chkupd_wrapper.vbs diff --git a/softwares/FWSUpdates/bin/chkupd_wrapper.vbs b/softwares/FWSUpdates/bin/chkupd_wrapper.vbs new file mode 100644 index 0000000..3a2beaf --- /dev/null +++ b/softwares/FWSUpdates/bin/chkupd_wrapper.vbs @@ -0,0 +1,2 @@ +Set objShell = CreateObject("Wscript.Shell") +objShell.Run """" & objShell.ExpandEnvironmentStrings("%SYSTEMDRIVE%") & "\FWSUpdates\bin\chkupd.bat" & """", 0, False diff --git a/softwares/FWSUpdates/bin/delayed_sync.bat b/softwares/FWSUpdates/bin/delayed_sync.bat new file mode 100644 index 0000000..c039a4f --- /dev/null +++ b/softwares/FWSUpdates/bin/delayed_sync.bat @@ -0,0 +1,5 @@ +CALL %~dp0\..\conf\adm\conf.bat +REM Random delay to spread the load on the server +SET /A DELAY=%RANDOM% %%%RANDOM_DELAY% +timeout /t %DELAY% 1>NUL 2>NUL +CALL %~dp0\sync.bat diff --git a/softwares/FWSUpdates/bin/on_shutdown.bat b/softwares/FWSUpdates/bin/on_shutdown.bat new file mode 100644 index 0000000..487c539 --- /dev/null +++ b/softwares/FWSUpdates/bin/on_shutdown.bat @@ -0,0 +1,13 @@ +@echo off +REM Only run if needed +SET /A USER_RUN=0 +SET /A ADMIN_RUN=0 +reg query "HKLM\Software\FWS\Updates\User" /v RunOnShutdown 1>NUL 2>NUL +IF %ERRORLEVEL% EQU 0 FOR /F "tokens=3" %%A IN ('reg query "HKLM\Software\FWS\Updates\User" /v RunOnShutdown') DO SET /A USER_RUN=%%A +reg query "HKLM\Software\FWS\Updates" /v RunOnShutdown 1>NUL 2>NUL +IF %ERRORLEVEL% EQU 0 FOR /F "tokens=3" %%A IN ('reg query "HKLM\Software\FWS\Updates" /v RunOnShutdown') DO SET /A ADMIN_RUN=%%A + +IF %USER_RUN% NEQ 1 IF %ADMIN_RUN% NEQ 1 goto :EOF + +call %SystemDrive%\FWSUpdates\bin\wpkg_feedback.bat + diff --git a/softwares/FWSUpdates/bin/sync.bat b/softwares/FWSUpdates/bin/sync.bat new file mode 100644 index 0000000..05cf0a3 --- /dev/null +++ b/softwares/FWSUpdates/bin/sync.bat @@ -0,0 +1,188 @@ +setlocal enabledelayedexpansion +CALL %~dp0\..\conf\adm\conf.bat + +SET /A SYNC_IN_PROGRESS=0 +SET /A RUN_ON_SHUTDOWN=0 + +REM exit if another sync is running +reg query "HKLM\Software\FWS\Updates" /v SyncInProgress 1>NUL 2>NUL +IF %ERRORLEVEL% EQU 0 ( + FOR /F "tokens=3" %%A IN ('reg query "HKLM\Software\FWS\Updates" /v SyncInProgress') DO SET /A SYNC_IN_PROGRESS=%%A +) +IF %SYNC_IN_PROGRESS% EQU 1 goto :EOF + +REM or if updates are already scheduled for next shutdown +reg query "HKLM\Software\FWS\Updates\User" /v RunOnShutdown 1>NUL 2>NUL +IF %ERRORLEVEL% EQU 0 FOR /F "tokens=3" %%A IN ('reg query "HKLM\Software\FWS\Updates\User" /v RunOnShutdown') DO SET /A RUN_ON_SHUTDOWN=%%A +IF %RUN_ON_SHUTDOWN% EQU 0 ( + reg query "HKLM\Software\FWS\Updates" /v RunOnShutdown 1>NUL 2>NUL + IF %ERRORLEVEL% EQU 0 FOR /F "tokens=3" %%A IN ('reg query "HKLM\Software\FWS\Updates" /v RunOnShutdown') DO SET /A RUN_ON_SHUTDOWN=%%A +) +IF %RUN_ON_SHUTDOWN% EQU 1 ( + echo %DATE% %TIME% - Updates already scheduled on next shutdown > %SystemDrive%\FWSUpdates\status\sync_log.txt + goto :EOF +) + +REM remove the lock during startup so it'll work if rebooting during a sync +reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" /v ResetWPKGSyncStatus /t REG_SZ /d "%SYSTEMROOT%\System32\reg.exe delete \"HKLM\Software\FWS\Updates\" /v SyncInProgress /f" /f + +REM Now start the sync +echo %DATE% %TIME% - Starting new Sync > %SystemDrive%\FWSUpdates\status\sync_log.txt +reg add "HKLM\Software\FWS\Updates" /v SyncInProgress /t REG_DWORD /d 1 /f + +REM Lets map a network drive +SET DRIVE=unknown +FOR %%D IN (e f g h i j k l m n o p q r s t u v w x y z) do ( + cd %%D: + IF ERRORLEVEL 1 SET DRIVE=%%D + IF ERRORLEVEL 1 goto drivefound +) +echo %DATE% %TIME% - couldn't find any free drive letter > %SystemDrive%\FWSUpdates\status\sync_log.txt +goto :EOF +:drivefound +net use %DRIVE%: %REPO% /PERSISTENT:NO /USER:%USER% %PASS% 1>NUL 2>NUL +REM Check if mapping worked +IF %ERRORLEVEL% NEQ 0 ( + echo %DATE% %TIME% - Error mapping %REPO% >> %SystemDrive%\FWSUpdates\status\sync_log.txt + goto cleanup +) +REM and if wpkg.js exists +IF NOT EXIST "%DRIVE%:\wpkg.js" ( + echo %DATE% %TIME% - %DRIVE%:\wpkg.js not found >> %SystemDrive%\FWSUpdates\status\sync_log.txt + goto cleanup +) +REM Then Mirror the content of the repository on the local drive +robocopy /MIR /R:10 /LOG:%SystemDrive%\FWSUpdates\status\log_robocopy.txt %DRIVE%:\ %SystemDrive%\FWSUpdates\repository\ 1>NUL 2>NUL + + +REM Now, we have to check the exit status of the robocopy command +REM Fatal Error +if %ERRORLEVEL% EQU 16 ( + echo %DATE% %TIME% - Robocopy exited with status %ERRORLEVEL% >> %SystemDrive%\FWSUpdates\status\sync_log.txt + goto xfererror +) +REM Copy done, with errors, mismatches and new files not copied +if %ERRORLEVEL% EQU 15 ( + echo %DATE% %TIME% - Robocopy exited with status %ERRORLEVEL% >> %SystemDrive%\FWSUpdates\status\sync_log.txt + goto xfererror +) +REM Copy failed, with mismatches and new files not copied +if %ERRORLEVEL% EQU 14 ( + echo %DATE% %TIME% - Robocopy exited with status %ERRORLEVEL% >> %SystemDrive%\FWSUpdates\status\sync_log.txt + goto xfererror +) +REM Copy done, with errors and mismatches +if %ERRORLEVEL% EQU 13 ( + echo %DATE% %TIME% - Robocopy exited with status %ERRORLEVEL% >> %SystemDrive%\FWSUpdates\status\sync_log.txt + goto xfererror +) +REM Copy failed with mismatches +if %ERRORLEVEL% EQU 12 ( + echo %DATE% %TIME% - Robocopy exited with status %ERRORLEVEL% >> %SystemDrive%\FWSUpdates\status\sync_log.txt + goto :xfererror +) +REM Copy done with errors and new files not copied +if %ERRORLEVEL% EQU 11 ( + echo %DATE% %TIME% - Robocopy exited with status %ERRORLEVEL% >> %SystemDrive%\FWSUpdates\status\sync_log.txt + goto :xfererror +) +if %ERRORLEVEL% EQU 10 ( + echo %DATE% %TIME% - Robocopy exited with status %ERRORLEVEL% >> %SystemDrive%\FWSUpdates\status\sync_log.txt + goto xfererror +) +REM Copy done with errors +if %ERRORLEVEL% EQU 9 ( + echo %DATE% %TIME% - Robocopy exited with status %ERRORLEVEL% >> %SystemDrive%\FWSUpdates\status\sync_log.txt + goto xfererror +) +REM Copy failed +if %ERRORLEVEL% EQU 8 ( + echo %DATE% %TIME% - Robocopy exited with status %ERRORLEVEL% >> %SystemDrive%\FWSUpdates\status\sync_log.txt + goto xfererror +) +REM Copy done, with mismatches and new files not copied +if %ERRORLEVEL% EQU 7 ( + echo %DATE% %TIME% - Robocopy exited with status %ERRORLEVEL% >> %SystemDrive%\FWSUpdates\status\sync_log.txt + goto xfererror +) +REM Mismatches and new files not copied +if %ERRORLEVEL% EQU 6 ( + echo %DATE% %TIME% - Robocopy exited with status %ERRORLEVEL% >> %SystemDrive%\FWSUpdates\status\sync_log.txt + goto xfererror +) +REM Copy done with mismatches +if %ERRORLEVEL% EQU 5 ( + echo %DATE% %TIME% - Robocopy exited with status %ERRORLEVEL% >> %SystemDrive%\FWSUpdates\status\sync_log.txt + goto :xfererror +) +REM Mismatches +if %ERRORLEVEL% EQU 4 ( + echo %DATE% %TIME% - Robocopy exited with status %ERRORLEVEL% >> %SystemDrive%\FWSUpdates\status\sync_log.txt + goto xfererror +) +REM Copy done, new files detected +if %ERRORLEVEL% EQU 3 goto postcopy +REM New files detected +if %ERRORLEVEL% EQU 2 goto postcopy +REM Copy done, we have new files, updates available +if %ERRORLEVEL% EQU 1 goto postcopy +REM No error, nothing copied, no updates +if %ERRORLEVEL% EQU 0 goto postcopy + +:xfererror +echo %DATE% %TIME% - Error occured during sync. See log_robocopy.txt for details >> %SystemDrive%\FWSUpdates\status\sync_log.txt +goto cleanup + +:postcopy +echo %DATE% %TIME% - Copy finished successfuly, now checking if changes must be applied >> %SystemDrive%\FWSUpdates\status\sync_log.txt +FOR /F %%A IN ('cscript %SystemDrive%\FWSUpdates\repository\wpkg.js /query:m ^| find /V "productkey" ^| find /C "ID:"') DO SET /A CHANGES=%%A +echo %DATE% %TIME% - Found %CHANGES% changes >> %SystemDrive%\FWSUpdates\status\sync_log.txt +SET NOW=%DATE:~-4%%DATE:~3,2%%DATE:~0,2% +SET /A MAX=%SINCE%+%MAX_REPORT% +SET /A DELTA=%NOW%-%SINCE% +reg add "HKLM\Software\FWS\Updates" /v PendingChanges /t REG_DWORD /d %CHANGES% /f +IF %CHANGES% GTR 0 ( + reg query "HKLM\Software\FWS\Updates" /v ChangesAvailableSince 1>NUL 2>NUL + IF ERRORLEVEL 1 ( + reg add "HKLM\Software\FWS\Updates" /v ChangesAvailableSince /t REG_DWORD /d %NOW% /f + ) ELSE ( + FOR /F %%A IN ('reg query "HKLM\Software\FWS\Updates" /v ChangesAvailableSince') DO SET /A SINCE=%%A + IF %NOW% GTR %MAX% add "HKLM\Software\FWS\Updates" /v RunOnShutdown /t REG_DWORD /d 1 /f + ) + goto copylogs +) ELSE ( + reg delete "HKLM\Software\FWS\Updates" /v ChangesAvailableSince /f + goto copylogs +) + +:copylogs +REM map another network drive to push logs +SET LOGDRIVE=unknown +FOR %%D IN (e f g h i j k l m n o p q r s t u v w x y z) do ( + cd %%D: + IF ERRORLEVEL 1 SET LOGDRIVE=%%D + IF ERRORLEVEL 1 goto logdrivefound +) +echo %DATE% %TIME% - couldn't find any free drive letter for logs > %SystemDrive%\FWSUpdates\status\sync_log.txt +goto :EOF + +:logdrivefound +net use %LOGDRIVE%: %LOGS% /PERSISTENT:NO /USER:%USER% %PASS% 1>NUL 2>NUL +REM Check if mapping worked +IF %ERRORLEVEL% NEQ 0 ( + echo %DATE% %TIME% - Error mapping %LOGS% >> %SystemDrive%\FWSUpdates\status\sync_log.txt + goto cleanup +) +IF NOT EXIST "%LOGDRIVE%:\keys" mkdir "%LOGDRIVE%:\keys" +IF NOT EXIST "%LOGDRIVE%:\logs" mkdir "%LOGDRIVE%:\logs" +IF NOT EXIST "%LOGDRIVE%:\databases" mkdir "%LOGDRIVE%:\databases" +IF EXIST "%SystemDrive\FWSUpdates\prodkeys\%COMPUTERNAME%.txt" copy /Y "%SystemDrive\FWSUpdates\prodkeys\%COMPUTERNAME%.txt" "%LOGDRIVE%:\keys" +IF EXIST "%TEMP%\wpkg-%COMPUTERNAME%.log" copy /Y "%TEMP%\wpkg-%COMPUTERNAME%.log" "%LOGDRIVE%:\logs\%COMPUTERNAME%.log" +IF EXIST "%SYSTEMROOT%\system32\wpkg.xml" copy /Y "%SYSTEMROOT%\system32\wpkg.xml" "%LOGDRIVE%:\databases\%COMPUTERNAME%.xml" +net use /D %LOGDRIVE%: 1>NUL 2>NUL +goto cleanup + +:cleanup +reg delete "HKLM\Software\FWS\Updates" /v SyncInProgress /f +net use /D %DRIVE%: 1>NUL 2>NUL + diff --git a/softwares/FWSUpdates/bin/wpkg_feedback.bat b/softwares/FWSUpdates/bin/wpkg_feedback.bat new file mode 100644 index 0000000..9742edb --- /dev/null +++ b/softwares/FWSUpdates/bin/wpkg_feedback.bat @@ -0,0 +1,70 @@ +@echo off +SETLOCAL enabledelayedexpansion + +SET /A CHANGES=1 +reg query "HKLM\Software\FWS\Updates" /v PendingChanges 1>NUL 2>NUL +IF %ERRORLEVEL% EQU 0 FOR /F "tokens=3" %%A IN ('reg query "HKLM\Software\FWS\Updates" /v PendingChanges') DO SET /A CHANGES=%%A + +CALL %~dp0\..\lang\en.bat +FOR /F "tokens=3" %%A IN ('reg query "HKLM\System\CurrentControlSet\Control\nls\Language" /v Installlanguage') DO SET LANG=%%A +IF EXIST %~dp0\..\lang\%LANG%.bat CALL %~dp0\..\lang\%LANG%.bat + +SET watitle=%L_WINDOW_TITLE% +SET wasig=%L_WINDOW_SIG% +SET walabels=%L_BTN_PREV%;%L_BTN_NEXT%;%L_BTN_OK%;%L_BTN_CANCEL% +SET wabmp=%SystemDrive%\FWSUpdates\assets\img\fws.bmp +SET waico=%SystemDrive%\FWSUpdates\assets\img\fws.ico + +SET watext=%L_INITIALIZING_UPDATES% +start /w %SystemDrive%\FWSUpdates\bin\wizapp.exe PB OPEN NOBACK NOCANCEL +SET /A STEP=90/%CHANGES% +SET /A PROGRESS=0 +SET watext=%L_CHECKING_INSTALLS% +SET /A CANCEL=0 +start /w %SystemDrive%\FWSUpdates\bin\wizapp.exe PB UPDATE 1 +FOR /F "tokens=2" %%A IN ('cscript %SystemDrive%\FWSUpdates\repository\wpkg.js /nonotify /quiet:true /query:I ^| find "ID:" ^| find /V "productkey" ') DO ( + SET PACKAGE=%%A + SET watext=%L_INSTALLING_X% !PACKAGE! + start /w %SystemDrive%\FWSUpdates\bin\wizapp.exe PB UPDATE !PROGRESS! + IF !ERRORLEVEL! EQU 2 goto :cancel + cscript %SystemDrive%\FWSUpdates\repository\wpkg.js /install:!PACKAGE! /nonotify /quiet:true /noreboot /logAppend:true 1>NUL 2>NUL + SET /A PROGRESS=PROGRESS+%STEP% +) +SET watext=%L_CHECKING_UPDATES% +start /w %SystemDrive%\FWSUpdates\bin\wizapp.exe PB UPDATE %PROGRESS% +FOR /F "tokens=2" %%A IN ('cscript %SystemDrive%\FWSUpdates\repository\wpkg.js /nonotify /quiet:true /query:u /logAppend:true ^| find "ID:" ^| find /V "productkey"') DO ( + SET PACKAGE=%%A + SET watext=%L_UPDATING_X% !PACKAGE! + start /w %SystemDrive%\FWSUpdates\bin\wizapp.exe PB UPDATE !PROGRESS! + IF !ERRORLEVEL! EQU 2 goto :cancel + cscript %SystemDrive%\FWSUpdates\repository\wpkg.js /upgrade:!PACKAGE! /nonotify /quiet:true /noreboot /logAppend:true 1>NUL 2>NUL + SET /A PROGRESS=PROGRESS+%STEP% +) +SET watext=%L_CHECKING_REMOVES% +start /w %SystemDrive%\FWSUpdates\bin\wizapp.exe PB UPDATE %PROGRESS% +FOR /F "tokens=2" %%A IN ('cscript %SystemDrive%\FWSUpdates\repository\wpkg.js /nonotify /quiet:true /query:r /logAppend:true ^| find "ID:" ^| find /V "productkey"') DO ( + SET PACKAGE=%%A + SET watext=%L_REMOVING_X% !PACKAGE! + start /w %SystemDrive%\FWSUpdates\bin\wizapp.exe PB UPDATE !PROGRESS! + IF !ERRORLEVEL! EQU 2 goto :cancel + cscript %SystemDrive%\FWSUpdates\repository\wpkg.js /remove:!PACKAGE! /nonotify /quiet:true /noreboot /logAppend:true 1>NUL 2>NUL + SET /A PROGRESS=PROGRESS+%STEP% +) +SET watext=%L_SYNCHRONIZING_CHANGES% +start /w %SystemDrive%\FWSUpdates\bin\wizapp.exe PB UPDATE %PROGRESS% +IF %ERRORLEVEL% EQU 2 goto :cancel +cscript %SystemDrive%\FWSUpdates\repository\wpkg.js /synchronize /nonotify /quiet:true /noreboot /logAppend:true 1>NUL 2>NUL +goto :finish + +:cancel +SET watext=%L_CANCELLING_UPDATES% +start /w %SystemDrive%\FWSUpdates\bin\wizapp.exe PB UPDATE 90 +goto :finish + +:finish +FOR /F %%A IN ('cscript %SystemDrive%\FWSUpdates\repository\wpkg.js /nonotify /quiet:true /query:m /logAppend:true ^| find /V "productkey" ^| find /C "ID:"') DO SET /A CHANGES=%%A +reg add "HKLM\Software\FWS\Updates" /v PendingChanges /t REG_DWORD /d %CHANGES% /f +reg delete "HKLM\Software\FWS\Updates\User" /v RunOnShutdown /f 1>NUL 2>NUL +reg delete "HKLM\Software\FWS\Updates" /v RunOnShutdown /f 1>NUL 2>NUL + +start /w %SystemDrive%\FWSUpdates\bin\wizapp.exe PB CLOSE diff --git a/softwares/FWSUpdates/lang/040C_utf8.bat b/softwares/FWSUpdates/lang/040C_utf8.bat new file mode 100644 index 0000000..23e0a24 --- /dev/null +++ b/softwares/FWSUpdates/lang/040C_utf8.bat @@ -0,0 +1,37 @@ +SET L_WINDOW_TITLE=Mise à jour +SET L_WINDOW_SIG=Firewall Services +SET L_BTN_PREV=Précédent +SET L_BTN_NEXT=Suivant +SET L_BTN_OK=Valider +SET L_BTN_CANCEL=Annuler +SET L_ONE_UPDATE_AVAILABLE=mise à jour est disponible +SET L_X_UPDATES_AVAILABLE=mises à jour sont disponibles +SET L_NO_UPDATE_AVAILABLE=Aucune mise à jour n'est disponible +SET L_ONE_UPDATE_AVAILABLE_SINCE=Cette mise à jour est disponible +SET L_X_UPDATES_AVAILABLE_SINCE=Parmi ces mises à jour, certaines sont disponibles +SET L_FOR_YOUR_SYSTEM=pour votre poste +SET L_YOU_CAN_SCHEDULE=Vous pouvez programmer l'installation au prochain arrêt ou la repousser à plus tard +SET L_SCHEDULE_ON_SHUTDOWN=Programmer l'installation au prochain arrêt du système +SET L_INSTALL_NOW=Installer maintenant +SET L_REPORT=Repousser à plus tard +SET L_SINCE=depuis +SET L_DAYS=jour^(s^^^) +SET L_CANT_REPORT_ANYMORE=il n'est plus possible de retarder leur installation, qui sera effectuée au prochain arrêt du système +SET L_UPDATES_REPORTED=L'installation des mises à jour est repoussée. Elle vous sera reproposée ultérieurement +SET L_UPDATES_SCHEDULED=Les mises à jour ont été programmées pour s'installer durant le prochain arrêt du système +SET L_INITIALIZING_UPDATES=Préparation de l'installation des mises à jour +SET L_CHECKING_INSTALLS=Recherche des logiciels à installer +SET L_INSTALLING_X=Installation de +SET L_CHECKING_UPDATES=Recherche des logiciels à mettre à jour +SET L_UPDATING_X=Mise à jour de +SET L_CHECKING_REMOVES=Recherche des logiciels à supprimer +SET L_REMOVING_X=Suppression de +SET L_SYNCHRONIZING_CHANGES=Synchronisation des changements restants +SET L_UPDATES_FINISHED=L'installation des mises à jour est terminée +SET L_SYNC_ALREADY_IN_PROGRESS=Les mises à jour sont en cours de téléchargement depuis le serveur. Veuillez réessayer plus tard +SET L_ALREADY_SCHEDULED_ON_SHUTDOWN=L'installation des mises à jour a déjà été programmé durant le prochain arrêt ou redémarrage de la machine +SET L_CHECK_ONLINE_FOR_UPDATES=Vérifier maintenant en ligne +SET L_CANCELLING_UPDATES=Annulation des mises à jour en cours +SET L_INSTALL_FORCED_IN=L'installation des mises à jour sera forcée dans +SET L_MAINTAIN_ON_SHUTDOWN=Maintenir la programmation +SET L_CANCEL_SCHEDULE_ON_SHUTDOWN=Annuler la programmation diff --git a/softwares/FWSUpdates/lang/en_utf8.bat b/softwares/FWSUpdates/lang/en_utf8.bat new file mode 100644 index 0000000..d94d25a --- /dev/null +++ b/softwares/FWSUpdates/lang/en_utf8.bat @@ -0,0 +1,37 @@ +SET L_WINDOW_TITLE=System updates +SET L_WINDOW_SIG=Firewall Services +SET L_BTN_PREV=Previous +SET L_BTN_NEXT=Next +SET L_BTN_OK=Validate +SET L_BTN_CANCEL=Cancel +SET L_ONE_UPDATE_AVAILABLE=update available +SET L_X_UPDATES_AVAILABLE=updates available +SET L_NO_UPDATE_AVAILABLE=No update available +SET L_ONE_UPDATE_AVAILABLE_SINCE=This update is available +SET L_X_UPDATES_AVAILABLE_SINCE=Among these updates, some are available +SET L_FOR_YOUR_SYSTEM=for your system +SET L_YOU_CAN_SCHEDULE=You can schedule installation on next shutdown, or postpone it +SET L_SCHEDULE_ON_SHUTDOWN=Schedule installation on next shutdown +SET L_INSTALL_NOW=Install now +SET L_REPORT=Postpone +SET L_SINCE=since +SET L_DAYS=day^(s^^^) +SET L_CANT_REPORT_ANYMORE=It's no longer possible to postpone installation, which will run on next shutdown +SET L_UPDATES_REPORTED=Installation was postponed. You'll be asked again to install later to schedule the updates +SET L_UPDATES_SCHEDULED=Updates have been schedule to run on next shutdown +SET L_INITIALIZING_UPDATES=Initializing updates installation +SET L_CHECKING_INSTALLS=Searching software to install +SET L_INSTALLING_X=Installing +SET L_CHECKING_UPDATES=Searching softwares to update +SET L_UPDATING_X=Updating +SET L_CHECKING_REMOVES=Searching softwares to remove +SET L_REMOVING_X=Removing +SET L_SYNCHRONIZING_CHANGES=Synchronizing remaining changes +SET L_UPDATES_FINISHED=Updates have been installed +SET L_SYNC_ALREADY_IN_PROGRESS=Updates are currently being downloaded, please try again later +SET L_ALREADY_SCHEDULED_ON_SHUTDOWN=Installation is already scheduled on next shutdown +SET L_CHECK_ONLINE_FOR_UPDATES=Check now online +SET L_CANCELLING_UPDATES=Cancelling updates +SET L_INSTALL_FORCED_IN=Installation will be enforced in +SET L_MAINTAIN_ON_SHUTDOWN=Keep schedule +SET L_CANCEL_SCHEDULE_ON_SHUTDOWN=Cancel schedule diff --git a/softwares/chkupd_bgmon.vbs b/softwares/chkupd_bgmon.vbs new file mode 100644 index 0000000..8c4f58e --- /dev/null +++ b/softwares/chkupd_bgmon.vbs @@ -0,0 +1,2 @@ +Set objShell = CreateObject("Wscript.Shell") +objShell.Run """" & objShell.ExpandEnvironmentStrings("%SYSTEMDRIVE%") & "\FWSUpdates\bin\chkupd.bat" & """" & " loop", 0, False diff --git a/softwares/create_shortcut.vbs b/softwares/create_shortcut.vbs new file mode 100644 index 0000000..4dee077 --- /dev/null +++ b/softwares/create_shortcut.vbs @@ -0,0 +1,8 @@ +Set objShell = CreateObject("WScript.Shell") +strStartMenu = objShell.SpecialFolders("AllUsersStartMenu") +Set objLink = objShell.CreateShortcut(strStartMenu & "\FWS Updates.lnk") +objLink.IconLocation = objShell.ExpandEnvironmentStrings("%SystemDrive%") & "\FWSUpdates\assets\img\fws.ico" +objLink.TargetPath = objShell.ExpandEnvironmentStrings("%SystemDrive%") & "\FWSUpdates\bin\chkupd_launcher.bat" +objLink.WindowStyle = 3 +objLink.Save +WScript.Quit diff --git a/softwares/fwsupdates.vbs b/softwares/fwsupdates.vbs new file mode 100644 index 0000000..13188fd --- /dev/null +++ b/softwares/fwsupdates.vbs @@ -0,0 +1,2 @@ +Set objShell = CreateObject("Wscript.Shell") +objShell.Run """" & objShell.ExpandEnvironmentStrings("%SYSTEMDRIVE%") & "\FWSUpdates\bin\on_shutdown.bat" & """", 0, True diff --git a/softwares/localgp.vbs b/softwares/localgp.vbs new file mode 100755 index 0000000..b5336f5 --- /dev/null +++ b/softwares/localgp.vbs @@ -0,0 +1,330 @@ +'********************************************************* +' En-tête +'********************************************************* +' °Author : BLUTEAU Erwan et christian grandjean +' °Date : 28.01.2011 +' °Version : 3.0 +' +' °Script description : +' Add entries in local GPO for "Machine => Startup/Shutdown" or "User +' => Logon/Logoff" entries. +' +' °Script parameters : +' sScript = Script or application to run +' sParameters = command line parameters +' sAddInStartupOrLogin +' True = Startup / Logon +' False = Shutdown / Logoff +' sMACHINEorUSER +' MACHINE = Machine Policy +' USER = User Policy +' +' °Script workflow : +' 1. Set ini file to normal mode +' 2. Edit ini file +' 3. Create/Add changes +' 4. Delete GPO registry key +' 5. Set ini file to hidden mode +' 6. Run GPUPDATE to integrate entries in registry +' +' °Remarks : +' The script accept maximum 9 entries in ini file +' +'******************************************************** +' Fin en-tête +'********************************************************* + + +Const ForReading =1 'Constante pour l ouverture en lecture d un fichier +Const ForWriting = 2 +const ForAppending = 8 +Const DeleteReadOnly = True +'********************************************************* +'recupération des paramétres +'********************************************************* +Set objArgs = Wscript.Arguments ' Objet pour récupérer les arguments +'Param 1 +TargetRunningScript=Wscript.Arguments(0) +'Param 2 +if Wscript.Arguments.count <= 3 then + TargetRunningScriptParam="" +else + TargetRunningScriptParam = Wscript.Arguments(1) + if Wscript.Arguments.count >= 5 then + for i = 2 to Wscript.Arguments.count-3 + TargetRunningScriptParam = TargetRunningScriptParam & " " & Wscript.Arguments(i) + next + end if +end if +'Param 3 +TargetTime=Wscript.Arguments(Wscript.Arguments.count-2) +'Param 4 +TargetGPO=Wscript.Arguments(Wscript.Arguments.count-1) + +'wscript.echo "param1=" & TargetRunningScript +'wscript.echo "param2=" & TargetRunningScriptParam +'wscript.echo "param3=" & TargetTime +'wscript.echo "param4=" & TargetGPO + + +'LANCEMENT SCRIPT +WriteGPOScriptPolicyGPTINIFILE TargetTime,TargetGPO +WriteGPOScriptPolicy TargetRunningScript,TargetRunningScriptParam,TargetTime,TargetGPO +'********************************************************* +' FIN +'********************************************************* +'WScript.Sleep 10000 +WScript.Quit + + + + + + +'********************************************************* +' LES FONCTIONS +'********************************************************* +Sub WriteGPOScriptPolicyGPTINIFILE(ByVal sAddInStartupOrLogin, ByVal sMACHINEorUSER) + Dim objFSO,ooShell + Dim sSys32 + Dim FicGptIni, PathGptIni, TmpVar, NbrLigne, i,ext, version + Dim TABGptIni() + Set ooShell = CreateObject("WSCript.Shell") 'Pour RUN de commandes + Set objFSO = CreateObject("Scripting.FileSystemObject") ' + Set sSys32 = objFSO.GetSpecialFolder(1) + + PathGptIni = sSys32 & "\GroupPolicy\gpt.ini" + PathGptIniTMP = PathGptIni & ".tmp" + + NbrLigne = 0 + IF not objFSO.FileExists(PathGptIni) Then + Set FicGptIni = objFSO.OpenTextFile(PathGptIni, ForWriting,true) + FicGptIni.write("[General]") + FicGptIni.close + end if + + Set FicGptIni = objFSO.OpenTextFile(PathGptIni, ForReading) + + Do Until FicGptIni.AtEndOfStream + NbrLigne = NbrLigne + 1 + TmpVar = FicGptIni.ReadLine() + ReDim preserve TABGptIni(NbrLigne) + TABGptIni(NbrLigne)=TmpVar + 'wscript.echo TABGptIni(NbrLigne) + Loop + 'wscript.echo "***********************" + 'wscript.echo "***********************" + + if sMACHINEorUSER = "MACHINE" then + gPCMachineLine = 0 + generalLine = 0 + For i = 0 to NbrLigne + if instr(1,TABGptIni(i),"gPCMachineExtensionNames", 1) then + gPCMachineLine = 1 + if instr(TABGptIni(i),"[{42B5FAAE-6536-11D2-AE5A-0000F87571E3}{40B6664F-4972-11D1-A7CA-0000F87571E3}]") then + 'wscript.echo "deja présent" + else + ext = right(TABGptIni(i),len(TABGptIni(i))-instr(TABGptIni(i),"=")) + TABGptIni(i) = "gPCMachineExtensionNames=" & "[{42B5FAAE-6536-11D2-AE5A-0000F87571E3}{40B6664F-4972-11D1-A7CA-0000F87571E3}]" & ext + end if + end if + + if instr(1,TABGptIni(i),"Version=",1) AND (instr(1,TABGptIni(i),"gPCFunctionalityVersion",1)=0) then + version = right(TABGptIni(i),len(TABGptIni(i))-instr(TABGptIni(i),"=")) + version = version + 65536 + TABGptIni(i) = "Version=" & version + end if + if instr(1,TABGptIni(i),"[General]", 1) then + generalLine = 1 + end if + if i = NbrLigne AND generalLine = 0 then + TABGptIni(i) = TABGptIni(i) & vbNewLine & "[General]" + end if + if i = NbrLigne AND gPCMachineLine = 0 then + TABGptIni(i) = TABGptIni(i) & vbNewLine & "gPCMachineExtensionNames=" & "[{42B5FAAE-6536-11D2-AE5A-0000F87571E3}{40B6664F-4972-11D1-A7CA-0000F87571E3}]" & vbNewLine & "Version=1" + end if + Next + end if + + if sMACHINEorUSER = "USER" then + gPCUserLine = 0 + For i = 0 to NbrLigne + if instr(TABGptIni(i),"gPCUserExtensionNames") then + if instr(TABGptIni(i),"[{42B5FAAE-6536-11D2-AE5A-0000F87571E3}{40B66650-4972-11D1-A7CA-0000F87571E3}]") then + 'wscript.echo "deja présent" + else + ext = right(TABGptIni(i),len(TABGptIni(i))-instr(TABGptIni(i),"=")) + TABGptIni(i) = "gPCUserExtensionNames=" & "[{42B5FAAE-6536-11D2-AE5A-0000F87571E3}{40B66650-4972-11D1-A7CA-0000F87571E3}]" & ext + end if + end if + + if instr(TABGptIni(i),"Version=") AND (instr(TABGptIni(i),"gPCFunctionalityVersion")=0) then + version = right(TABGptIni(i),len(TABGptIni(i))-instr(TABGptIni(i),"=")) + version = version + 1 + TABGptIni(i) = "Version=" & version + end if + if i = NbrLigne AND gPCUserLine = 0 then + TABGptIni(i) = TABGptIni(i) & vbNewLine & "gPCUserExtensionNames=" & "[{42B5FAAE-6536-11D2-AE5A-0000F87571E3}{40B6664F-4972-11D1-A7CA-0000F87571E3}]" & vbNewLine & "Version=1" + end if + Next + end if + + on error goto 0 + If objFSO.FileExists(PathGptIniTMP) Then + objFSO.DeleteFile(PathGptIniTMP) + End If + Set FicGptIniTEMP = objFSO.OpenTextFile(PathGptIniTMP, ForWriting,true) + for k = 0 to NbrLigne + 'wscript.echo TABGptIni(k) + FicGptIniTEMP.write(TABGptIni(k) & vbNewLine) + next + FicGptIniTEMP.close + objFSO.CopyFile PathGptIniTMP, PathGptIni, 1 + If objFSO.FileExists(PathGptIniTMP) Then + objFSO.DeleteFile(PathGptIniTMP) + End If + + +End Sub +'********************************************************* +Sub WriteGPOScriptPolicy(ByVal sScript, ByVal sParameters, ByVal sAddInStartupOrLogin, ByVal sMACHINEorUSER) + Dim sScriptPath, sSys32, sTMP + Dim oINI, ooShell, ooFSO, oINIProperties, oRegFile + Dim iLastStartup, iLastShutdown + Dim sOption1, sOption2, sStartup, sShutdown + sStartup = "" + sShutdown = "" + sMACHINEorUSER = Ucase(sMACHINEorUSER) + + Set ooShell = CreateObject("WSCript.Shell") + Set ooFSO = CreateObject("Scripting.FileSystemObject") + + Set sSys32 = ooFSO.GetSpecialFolder(1) + + ' Check if COMPUTER or USER Policy + If sMACHINEorUSER = "MACHINE" Then + sScriptPath = sSys32 & "\GroupPolicy\Machine\Scripts\scripts.ini" + Elseif sMACHINEorUSER = "USER" Then + sScriptPath = sSys32 & "\GroupPolicy\User\Scripts\scripts.ini" + Else + WScript.Echo "Please set value for sMACHINEorUSER !" + WScript.Quit + End If + + If (Not ooFSO.FileExists(sScriptPath)) Then + ' Add new value in startup or shutdown + If sAddInStartupOrLogin Then + iLastStartup = 0 + If sMACHINEorUSER = "MACHINE" Then sStartup = VbCrLf & "[Startup]" + If sMACHINEorUSER = "USER" Then sStartup = VbCrLf & "[Logon]" + sStartup = sStartup & VbCrLf & iLastStartup & "CmdLine=" & sScript + sStartup = sStartup & VbCrLf & iLastStartup & "Parameters=" & sParameters + Else + iLastShutdown = 0 + If sMACHINEorUSER = "MACHINE" Then sStartup = VbCrLf & "[Shutdown]" + If sMACHINEorUSER = "USER" Then sStartup = VbCrLf & "[Logoff]" + sShutdown = sShutdown & VbCrLf &iLastShutdown & "CmdLine=" & sScript + sShutdown = sShutdown & VbCrLf &iLastShutdown & "Parameters=" & sParameters + End If + Else + ' Set file as normal + Set oINIProperties = ooFSO.GetFile(sScriptPath) + oINIProperties.Attributes = 0 'The File become Hidden! + + ' read + Set oINI = ooFSO.OpenTextFile(sScriptPath, 1) + + iLastStartup = 0 + iLastShutdown = 0 + + Do While 1 = 1 + On Error Resume Next + sTMP = oINI.ReadLine + 'If sTMP = VbCrLf Then sTMP = "" + If Err > 0 Then Exit Do + On Error GoTo 0 + + If InStr(1, UCase(sTMP), UCase("[Startup]")) > 0 And sMACHINEorUSER = "MACHINE" Then sOption1 = sTMP + If InStr(1, UCase(sTMP), UCase("[Shutdown]")) > 0 And sMACHINEorUSER = "MACHINE" Then sOption2 = sTMP + If InStr(1, UCase(sTMP), UCase("[Logon]")) > 0 And sMACHINEorUSER = "USER" Then sOption1 = sTMP + If InStr(1, UCase(sTMP), UCase("[Logoff]")) > 0 And sMACHINEorUSER = "USER" Then sOption2 = sTMP + + If sOption1 = "[Startup]" And sOption2 <> "[Shutdown]" Or sOption1 = "[Logon]" And sOption2 <> "[Logoff]" Then + sStartup = sStartup & VbCrLf & sTMP + + On Error Resume Next + 'WScript.Echo CInt(Left(sTMP, 1)) + iLastStartup = Cint(Left(sTMP, 1)) + 1 + On Error GoTo 0 + 'WScript.Echo "Start Next value = " & iLastStartup + Else + sShutdown = sShutdown & VbCrLf & sTMP + On Error Resume Next + 'WScript.Echo CInt(Left(sTMP, 1)) + iLastShutdown = CInt(Left(sTMP, 1)) + 1 + On Error GoTo 0 + 'WScript.Echo "Shutdown Next value = " & iLastShutdown + End If + Loop + + ' Add new value in startup or shutdown + If sAddInStartupOrLogin Then + ' If key dont exist + If InStr(1, sStartup, "[Startup]") = 0 And sMACHINEorUSER = "MACHINE" Then sStartup = VbCrLf & "[Startup]" + If InStr(1, sStartup, "[Logon]") = 0 And sMACHINEorUSER = "USER" Then sStartup = VbCrLf & "[Logon]" + ' Don't add the script agin if it's already there. Not very foolproof but.... + If InStr(1, sStartup, "CmdLine=" & sScript, 1) = 0 Then + sStartup = sStartup & VbCrLf &iLastStartup & "CmdLine=" & sScript + sStartup = sStartup & VbCrLf & iLastStartup & "Parameters=" & sParameters + End If + Else + ' If key dont exist + If InStr(1, sShutdown, "[Shutdown]") = 0 And sMACHINEorUSER = "MACHINE" Then sShutdown = VbCrLf & "[Shutdown]" + If InStr(1, sShutdown, "[Logoff]") = 0 And sMACHINEorUSER = "USER" Then sShutdown = VbCrLf & "[Logoff]" + If InStr(1, sShutdown, "CmdLine=" & sScript, 1) = 0 Then + sShutdown = sShutdown & VbCrLf & iLastShutdown & "CmdLine=" & sScript + sShutdown = sShutdown & VbCrLf & iLastShutdown & "Parameters=" & sParameters + End If + End If + + ' Close file + oINI.Close + End If + On Error GoTo 0 + ' prin result + 'WScript.Echo sStartup & sShutdown + + ' Write result in ini file + Set oINI = ooFSO.CreateTextFile(sScriptPath, True) + oINI.WriteLine sStartup & sShutdown + oINI.Close + + ' Set file as hidden + Set oINIProperties = ooFSO.GetFile(sScriptPath) + oINIProperties.Attributes = 2 'The File become Hidden! + + ' Remove registry key + 'Set oRegFile = ooFSO.CreateTextFile(CurDir & "\~TMP-REG-WriteGPOScriptPolicy-Script.reg", True) + 'oRegFile.WriteLine "Windows Registry Editor Version 5.00" + 'oRegFile.WriteLine "[-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts]" + 'oRegFile.Close + 'oShell.Run "REGEDIT /S " & CurDir & "\~TMP-REG-WriteGPOScriptPolicy-Script.reg" + 'oFSO.DeleteFile CurDir & "\~TMP-REG-WriteGPOScriptPolicy-Script.reg", True + + ' Check if COMPUTER or USER Policy + If sMACHINEorUSER = "MACHINE" Then + ' Reload configuration from ini file + ooShell.Run "GPUPDATE /Target:Computer /Wait:30", 0, True + 'if err.number <> 0 then + ' wscript.echo "ERREUR : " & err.Number & " : " & err.Description + ' wscript.sleep 10000 + 'end if + Elseif sMACHINEorUSER = "USER" Then + ' Reload configuration from ini file + ooShell.Run "GPUPDATE /Target:User /Force /Wait:30", 0, True + Else + WScript.Echo "Please set value for sMACHINEorUSER !" + WScript.Quit + End If + +End Sub diff --git a/softwares/offline_upgrade.bat b/softwares/offline_upgrade.bat new file mode 100644 index 0000000..cc8b754 --- /dev/null +++ b/softwares/offline_upgrade.bat @@ -0,0 +1,22 @@ +@echo off + +REM perform upgrade of WPKG client + +IF EXIST "%SystemDrive%\FWSUpdates\assets.upgrade" ( + RMDIR /S /Q "%SystemDrive%\FWSUpdates\assets" + RENAME "%SystemDrive%\FWSUpdates\assets.upgrade" assets +) +IF EXIST "%SystemDrive%\FWSUpdates\bin.upgrade" ( + RMDIR /S /Q "%SystemDrive%\FWSUpdates\bin" + RENAME "%SystemDrive%\FWSUpdates\bin.upgrade" bin +) +IF EXIST "%SystemDrive%\FWSUpdates\lang.upgrade" ( + RMDIR /S /Q "%SystemDrive%\FWSUpdates\lang" + RENAME "%SystemDrive%\FWSUpdates\lang.upgrade" lang +) +IF EXIST "%SystemRoot%\System32\GroupPolicy\Machine\Scripts\Shutdown\wpkg.bat" DEL /F /Q "%SystemRoot%\System32\GroupPolicy\Machine\Scripts\Shutdown\wpkg.bat" +IF EXIST "%SystemRoot%\System32\GroupPolicy\Machine\Scripts\Shutdown\fwsupdates.upgrade.vbs" ( + DEL /Q "%SystemRoot%\System32\GroupPolicy\Machine\Scripts\Shutdown\fwsupdates.vbs" + RENAME "%SystemRoot%\System32\GroupPolicy\Machine\Scripts\Shutdown\fwsupdates.upgrade.vbs" fwsupdates.vbs +) +reg delete "HKLM\Software\FWS\Updates" /v PendingChanges /f diff --git a/wpkg-fwsupdates.spec b/wpkg-fwsupdates.spec new file mode 100644 index 0000000..32e235a --- /dev/null +++ b/wpkg-fwsupdates.spec @@ -0,0 +1,61 @@ +%define package fwsupdates +%define version 0.1.0 +%define release 0.beta1 + +Name: wpkg-fwsupdates +Version: %{version} +Release: %{release}%{?dist} +Summary: WPKG Client with a GUI + +Group: System/Softwares +URL: http://www.ipasserelle.com +Source0: %{name}-%{version}.tar.gz +License: misc + +BuildRoot: /var/tmp/%{name}-%{version}-%{release}-buildroot +BuildArch: noarch +BuildRequires: unix2dos +BuildRequires: e-smith-devtools +BuildRequires: /usr/bin/iconv + +Requires: ipasserelle-gp + +%description +Meta package to install WPKG supported softwares on iPasserelle + +%prep +%setup -q -n %{name}-%{version} + +%build +perl createlinks +unix2dos packages/* +for F in $(ls softwares/FWSUpdates/lang/*.bat); do + L=${F%_utf8.bat}.bat + iconv -f UTF-8 -t CP850 -o $L $F + unix2dos $L + rm -f $F +done + +%install +/bin/rm -rf %{buildroot} +cp -a root %{buildroot}/ +mkdir -p %{buildroot}/home/e-smith/files/shares/wpkg/files/packages +mkdir -p %{buildroot}/home/e-smith/files/shares/wpkg/files/softwares/%{package} +mkdir -p %{buildroot}/home/e-smith/files/shares/wpkg/files/settings/%{package} +cp -r softwares/* %{buildroot}/home/e-smith/files/shares/wpkg/files/softwares/%{package}/ +cp -r packages/* %{buildroot}/home/e-smith/files/shares/wpkg/files/packages/ +cp -r settings/* %{buildroot}/home/e-smith/files/shares/wpkg/files/settings/%{package}/ + +%files +%defattr(-,root,root) +%doc CHANGELOG.git +/home/e-smith/files/shares/ +/etc + +%clean +/bin/rm -rf %{buildroot} + +%changelog +* Wed Dec 9 2015 Daniel Berteaud 0.1.0-1 +- First package +