Advertisement
J2897

Cygwin Upgrader v1.3

Oct 11th, 2014
630
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 2.16 KB | None | 0 0
  1. :: Released under the GNU General Public License version 3 by J2897.
  2.  
  3. @echo OFF
  4. setlocal
  5. title Cygwin Upgrader.
  6. cls
  7.  
  8. :: Command-line parameters...
  9. :: https://cygwin.com/faq/faq.html#faq.setup.cli
  10. ::
  11. :: Add this to your .bashrc file...
  12. :: alias cyg-upgrade="cygstart schtasks.exe /run /tn \"\Updates\Update Cygwin\""
  13.  
  14. REM Check for administrative privileges.
  15. ver | find "Version 6." >nul
  16. if %ERRORLEVEL% == 0 (
  17.     openfiles >nul 2>&1
  18.     if errorlevel 1 (
  19.         msg %USERNAME% /time:600 Update aborted. You must run '%~nx0' as an administrator.
  20.         exit /b 1
  21.     )
  22. )
  23.  
  24. REM Set the appropriate variables.
  25. set "MIRROR=http://mirrors.kernel.org/sourceware/cygwin/"
  26. set "CYGFILE32=setup-x86.exe"
  27. set "CYGFILE64=setup-x86_64.exe"
  28. set "LSF=%SYSTEMDRIVE%\cygstore"
  29. set "UCS=%LSF%\scripts\update-cygwin-setup.py"
  30.  
  31. REM Find the Cygwin Setup File.
  32. if exist "%LSF%\%CYGFILE64%" (set "FSF=%LSF%\%CYGFILE64%")
  33. if exist "%LSF%\%CYGFILE32%" (set "FSF=%LSF%\%CYGFILE32%")
  34.  
  35. REM Upgrade Cygwin if the Folder and Setup File exists.
  36. if not defined FSF (
  37.     msg %USERNAME% /time:600 Update aborted. You may have deleted or renamed the Cygwin setup file.
  38.     endlocal
  39.     exit /b 1
  40. )
  41.  
  42. REM Update the setup file if the Python script exists.
  43. if exist "%SYSTEMDRIVE%\Python27\python.exe" (
  44.     echo Attempting to update the setup file...
  45.     "%SYSTEMDRIVE%\Python27\python.exe" "%UCS%" || echo Failed to update the setup file.
  46. ) else (
  47.     echo Python 2.* isn't installed. So cannot check to see if the there's a newer
  48.     echo setup file available. If there is, please put it in the 'cygstore' folder
  49.     echo before your next auto-upgrade: %LSF%
  50. )
  51.  
  52. echo.
  53. echo Attempting to stop the sshd service...
  54. net stop sshd
  55.  
  56. echo Killing processes...
  57. taskkill /im "bash.exe" >nul 2>&1 || taskkill /im "bash.exe" /f >nul 2>&1
  58. taskkill /im "sshd.exe" >nul 2>&1 || taskkill /im "sshd.exe" /f >nul 2>&1
  59. echo.
  60.  
  61. echo Upgrading Cygwin packages...
  62. if not exist "%USERPROFILE%\Logs" (md "%USERPROFILE%\Logs")
  63. "%FSF%" -D -L -s "%MIRROR%" -q -g -o >"%USERPROFILE%\Logs\Cygwin Upgrade.log"
  64.  
  65. echo.
  66. echo Attempting to start the sshd service...
  67. net start sshd
  68.  
  69. :end
  70. echo Ending . . .
  71. endlocal
  72. timeout /t 15 /nobreak >nul
  73. exit /b 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement