-
Notifications
You must be signed in to change notification settings - Fork 3
/
ConCygSys-installer.cmd
733 lines (668 loc) · 29 KB
/
ConCygSys-installer.cmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
@echo off
:: ConCygSys: Cygwin and ConEmu portable installer https://github.com/zhubanRuban/ConCygSys
:: This is the independent fork of https://github.com/vegardit/cygwin-portable-installer project
set CONCYGSYS_VERSION=171123
::####################### begin SCRIPT SETTINGS #######################::
:: You can customize the following variables to your needs before running the batch file
:: choose a user name under Cygwin, leave empty to use your Windows username
set CYGWIN_USERNAME=
:: home folder name e.g. /home/HOME_FOLDER, leave empty to use default one - concygsys
set HOME_FOLDER=
:: override processor architecture: setup-x86.exe for 32bit or setup-x86_64.exe for 64bit system, leave empty for autodetect
set CYGWIN_SETUP=
:: change the URL to the closest mirror: https://cygwin.com/mirrors.html
set CYGWIN_MIRROR=http://ftp.inf.tu-dresden.de/software/windows/cygwin32
:: select the packages to be installed automatically: https://cygwin.com/packages/package_list.html
set CYGWIN_PACKAGES=bind-utils,curl,inetutils,openssh,openssl,vim,whois
:: select command line language: https://docs.oracle.com/cd/E23824_01/html/E26033/glset.html , leave empty for autodetect
set LOCALE=
:: Cygwin uses ACLs to implement real Unix permissions which are not supported by Windows: https://cygwin.com/cygwin-ug-net/using-filemodes.html
:: However, if you move installation to different directory or PC, ACLs will be broken and will have troubles running Cygwin binaries
:: Set to 'yes' if you want real Unix permissions to the detriment of portability
:: Set to 'no' if you want fully portable environment
:: Minimal permissions you will be able to set with disabled ACLs: "-r--r--r--" or "444"
:: Maximal: "-rw-r--r--" or "644". Files with exe extension or beginning with shebang will automatically have 755 permissions
set INSTALL_ACL=no
:: install apt-cyg command line package manager: https://github.com/transcode-open/apt-cyg
set INSTALL_APT_CYG=yes
:: install bash-funk adaptive Bash prompt: https://github.com/vegardit/bash-funk
set INSTALL_BASH_FUNK=yes
:: install parallel ssh tool: https://github.com/zhubanRuban/cygwin-extras#pssh-parallelssh
set INSTALL_PSSH=yes
:: install parallel scp tool: https://github.com/zhubanRuban/cygwin-extras#pscp-parallelscp
set INSTALL_PSCP=yes
:: install SSH agent tweak https://github.com/zhubanRuban/cygwin-extras#ssh-agent-tweak
set INSTALL_SSH_AGENT_TWEAK=yes
:: install custom bashrc rules for better experience https://github.com/zhubanRuban/cygwin-extras#custom-bashrc
:: if set to 'yes', will disable bash-funk adaptive Bash prompt (see INSTALL_BASH_FUNK) to prevent conflicts
set INSTALL_BASHRC_CUSTOMS=yes
:: install multitab terminal https://conemu.github.io/
set INSTALL_CONEMU=yes
:: https://conemu.github.io/en/ConEmuArgs.html
set CONEMU_OPTIONS=-Title ConCygSys
:: paths where to look for binaries, add more path if required, but at the cost of runtime performance
set CYGWIN_PATH=%%SystemRoot%%\system32;%%SystemRoot%%;%%CYGWIN_ROOT%%\bin;%%CYGWIN_ROOT%%\usr\sbin;%%CYGWIN_ROOT%%\usr\local\sbin
:: set proxy if required (unfortunately Cygwin setup.exe does not have commandline options to specify proxy user credentials)
set PROXY_HOST=
set PROXY_PORT=8080
:: set Mintty options used in ConEmu task: https://cdn.rawgit.com/mintty/mintty/master/docs/mintty.1.html#CONFIGURATION
:: the main goal is to set options (they will overwrite whatyou configured in main Mintty window) to make Mintty working properly with ConEmu
set MINTTY_OPTIONS=--nopin ^
--Border frame ^
-o BellType=5 ^
-o FontHeight=10 ^
-o BoldAsFont=yes ^
-o AllowBlinking=yes ^
-o CopyOnSelect=yes ^
-o RightClickAction=paste ^
-o ScrollbackLines=5000 ^
-o Transparency=off ^
-o ConfirmExit=no
::####################### end SCRIPT SETTINGS #######################::
echo.
set CONCYGSYS_LINK=https://github.com/zhubanRuban/ConCygSys
set CONCYGSYS_INFO=ConCygSys v.%CONCYGSYS_VERSION% %CONCYGSYS_LINK%
echo [7;96m%CONCYGSYS_INFO%[0m
echo.
:: %~dp0 means current directory with backslash at the end
set INSTALL_ROOT=%~dp0
set CYGWIN_ROOT=%INSTALL_ROOT%cygwin
set Concygsys_settings_name=update.cmd
set Concygsys_settings=%INSTALL_ROOT%%Concygsys_settings_name%
:: to use 'set' in full in 'if' loop below: https://ss64.com/nt/delayedexpansion.html
setlocal EnableDelayedExpansion
if not exist "%CYGWIN_ROOT%" (
echo Creating Cygwin folder [%CYGWIN_ROOT%]...
md "%CYGWIN_ROOT%"
) else (
echo Existing Cygwin folder detected [%CYGWIN_ROOT%], entering update mode...
set UPDATEMODE=yes
wmic process get ExecutablePath 2>NUL | find /I "%CYGWIN_ROOT%">NUL
:: rem is used below instead of :: for commenting as loops produce "system cannot find disk" warning when using :: in miltiple lines
rem for those wondering why I didn't use if "%ERRORLEVEL%"=="0"
rem https://social.technet.microsoft.com/Forums/en-US/e72cb532-3da0-4c7f-a61e-9ffbf8050b55/batch-errorlevel-always-reports-back-level-0?forum=ITCG
if not ErrorLevel 1 (
echo.
echo [7;91mActive Cygwin processes detected, please close them and re-run update[0m
wmic process get ExecutablePath | find /I "%CYGWIN_ROOT%"
goto :fail
) else (
if exist "%Concygsys_settings%" (
call "%Concygsys_settings%" cygwinsettings
call "%Concygsys_settings%" installoptions
) else (
set UPDATEFROMOLD=yes
)
echo.
set /p UPDATECYGWINONLY=[0m [1;7m 1 [0m update Cygwin only [1;7m ENTER [0m update everything
if not "!UPDATECYGWINONLY!" == "" goto :updatecygwinonly
echo.
echo [7;93mBefore you proceed with update...[0m
if "!UPDATEFROMOLD!" == "yes" (
echo It seems that you are upgrading from one of the oldest ConCygSys releases
echo Please BACKUP your personal records in .bashrc
echo Hit ENTER when done
echo.
pause
) else (
echo To customize update process:
echo - close this window
echo - modify :installoptions section of [%Concygsys_settings%] file accordingly
echo - re-run update
echo.
echo If you are good with existing setup, just hit ENTER
echo.
pause
)
)
)
:: not needed anymore and to prevent issues in bash script generation down below (they conatin ! which should have been escaped by ^^)
setlocal DisableDelayedExpansion
:updatecygwinonly
:: There is no true-commandline download tool in Windows
:: creating VB script that can download files...
:: not using PowerShell which may be blocked by group policies
set DOWNLOADER=%INSTALL_ROOT%downloader.vbs
echo.
echo Creating script that can download files [%DOWNLOADER%]...
if "%PROXY_HOST%" == "" (
set DOWNLOADER_PROXY=.
) else (
set DOWNLOADER_PROXY= req.SetProxy 2, "%PROXY_HOST%:%PROXY_PORT%", ""
)
(
echo url = Wscript.Arguments(0^)
echo target = Wscript.Arguments(1^)
echo WScript.Echo "Downloading '" ^& url ^& "' to '" ^& target ^& "'..."
echo Set req = CreateObject("WinHttp.WinHttpRequest.5.1"^)
echo%DOWNLOADER_PROXY%
echo req.Open "GET", url, False
echo req.Send
echo If req.Status ^<^> 200 Then
echo WScript.Echo "FAILED to download: HTTP Status " ^& req.Status
echo WScript.Quit 1
echo End If
echo Set buff = CreateObject("ADODB.Stream"^)
echo buff.Open
echo buff.Type = 1
echo buff.Write req.ResponseBody
echo buff.Position = 0
echo buff.SaveToFile target
echo buff.Close
echo.
) >"%DOWNLOADER%" || goto :fail
echo.
echo Choosing correct version of Cygwin installer...
if "%CYGWIN_SETUP%" == "" (
echo CYGWIN_SETUP setting is empty, autodetecting...
if "%PROCESSOR_ARCHITEW6432%" == "AMD64" (
set CYGWIN_SETUP=setup-x86_64.exe
) else (
if "%PROCESSOR_ARCHITECTURE%" == "x86" (
set CYGWIN_SETUP=setup-x86.exe
) else (
set CYGWIN_SETUP=setup-x86_64.exe
)
)
)
echo Chosen installer: %CYGWIN_SETUP%
:: Removing existing setup.exe
del "%CYGWIN_ROOT%\%CYGWIN_SETUP%" >NUL 2>&1
:: downloading Cygwin installer
echo.
cscript //Nologo "%DOWNLOADER%" http://cygwin.org/%CYGWIN_SETUP% "%CYGWIN_ROOT%\%CYGWIN_SETUP%" || goto :fail
del "%DOWNLOADER%" >NUL 2>&1
:: Cygwin command line options: https://cygwin.com/faq/faq.html#faq.setup.cli
if "%PROXY_HOST%" == "" (
set CYGWIN_PROXY=
) else (
set CYGWIN_PROXY=--proxy "%PROXY_HOST%:%PROXY_PORT%"
)
:: adding required packages for special software
if "%INSTALL_CONEMU%" == "yes" (
set CYGWIN_PACKAGES=bsdtar,wget,%CYGWIN_PACKAGES%
)
if "%INSTALL_APT_CYG%" == "yes" (
set CYGWIN_PACKAGES=wget,%CYGWIN_PACKAGES%
)
if "%INSTALL_BASHRC_CUSTOMS%" == "yes" (
set INSTALL_BASH_FUNK=no
)
if "%INSTALL_BASH_FUNK%" == "yes" (
set CYGWIN_PACKAGES=git,git-svn,subversion,%CYGWIN_PACKAGES%
)
if "%INSTALL_PSSH%" == "yes" (
set CYGWIN_PACKAGES=wget,%CYGWIN_PACKAGES%
)
if "%INSTALL_PSCP%" == "yes" (
set CYGWIN_PACKAGES=wget,%CYGWIN_PACKAGES%
)
if "%INSTALL_SSH_AGENT_TWEAK%" == "yes" (
set CYGWIN_PACKAGES=openssh,%CYGWIN_PACKAGES%
)
:: all Cygwin installer commandline options: https://www.cygwin.com/faq/faq.html#faq.setup.cli
echo.
echo Running Cygwin setup...
"%CYGWIN_ROOT%\%CYGWIN_SETUP%" --no-admin ^
--site %CYGWIN_MIRROR% %CYGWIN_PROXY% ^
--root "%CYGWIN_ROOT%" ^
--local-package-dir "%CYGWIN_ROOT%\pkg-cache" ^
--no-shortcuts ^
--no-desktop ^
--delete-orphans ^
--upgrade-also ^
--no-replaceonreboot ^
--quiet-mode ^
--packages dos2unix,wget,%CYGWIN_PACKAGES% || goto :fail
:: deleting standard Cygwin launcher
del "%CYGWIN_ROOT%\Cygwin.bat" >NUL 2>&1
echo %CONCYGSYS_INFO% >"%CYGWIN_ROOT%\DO-NOT-LAUNCH-CYGWIN-FROM-HERE"
if not "%UPDATECYGWINONLY%" == "" goto :aftercygwinupdate
echo.
echo Creating portable settings files...
set Portable_init_name=portable-init.sh
set Portable_init=%CYGWIN_ROOT%\%Portable_init_name%
echo Creating init script to keep the installation portable [%Portable_init%]...
(
echo #!/usr/bin/env bash
echo # %CONCYGSYS_INFO%
echo.
echo # Setting custom Cygwin username
echo (
echo mkpasswd -c^|awk -F: -v OFS=: "{\$1=\"$USERNAME\"; \$6=\"$HOME\"; print}"
echo ^) ^>/etc/passwd
echo.
echo (
if not "%INSTALL_ACL%" == "yes" (
echo echo $(cygpath -m "$CYGWIN_ROOT"^|sed 's/\ /\\040/g'^)/bin /usr/bin none binary,auto,noacl 0 0
echo echo $(cygpath -m "$CYGWIN_ROOT"^|sed 's/\ /\\040/g'^)/lib /usr/lib none binary,auto,noacl 0 0
echo echo $(cygpath -m "$CYGWIN_ROOT"^|sed 's/\ /\\040/g'^) / none override,binary,auto,noacl 0 0
)
echo echo none /mnt cygdrive binary,noacl,posix=0,user 0 0
echo ^) ^>/etc/fstab
echo.
echo # adjust Cygwin packages cache path
echo pkg_cache_dir=$(cygpath -w "$CYGWIN_ROOT/pkg-cache"^)
echo sed -i '/^^last-cache/!b;n;c\\t'"${pkg_cache_dir//\\/\\\\}"'' /etc/setup/setup.rc
) >"%Portable_init%" || goto :fail
:: converting script to unix format as it was created via Windows command line
"%CYGWIN_ROOT%\bin\dos2unix" "%Portable_init%" || goto :fail
echo Generating one-file settings and updater file [%Concygsys_settings%]...
(
echo @echo off
echo :: %CONCYGSYS_INFO%
echo.
echo if "%%1" == "cygwinsettings" goto :cygwinsettings
echo if "%%1" == "installoptions" goto :installoptions
echo if "%%1" == "launcherheader" goto :launcherheader
echo goto :update
echo.
echo :cygwinsettings
echo :: %CONCYGSYS_LINK%#customization
echo set CYGWIN_USERNAME=%CYGWIN_USERNAME%
echo set HOME_FOLDER=%HOME_FOLDER%
echo set LOCALE=%LOCALE%
echo exit /b 0
echo.
echo :installoptions
echo :: %CONCYGSYS_LINK%#customization
echo set CYGWIN_SETUP=%CYGWIN_SETUP%
echo set CYGWIN_MIRROR=%CYGWIN_MIRROR%
echo :: fill only if new packages should be installed during next update
echo set CYGWIN_PACKAGES=
echo set INSTALL_ACL=%INSTALL_ACL%
echo set INSTALL_APT_CYG=%INSTALL_APT_CYG%
echo set INSTALL_BASH_FUNK=%INSTALL_BASH_FUNK%
echo set INSTALL_PSSH=%INSTALL_PSSH%
echo set INSTALL_PSCP=%INSTALL_PSCP%
echo set INSTALL_SSH_AGENT_TWEAK=%INSTALL_SSH_AGENT_TWEAK%
echo set INSTALL_BASHRC_CUSTOMS=%INSTALL_BASHRC_CUSTOMS%
echo set INSTALL_CONEMU=%INSTALL_CONEMU%
echo set PROXY_HOST=%PROXY_HOST%
echo set PROXY_PORT=%PROXY_PORT%
echo exit /b 0
echo.
echo :launcherheader
echo set CYGWIN_ROOT=%%~dp0cygwin
echo call "%%~dp0%Concygsys_settings_name%" cygwinsettings
echo set PATH=%CYGWIN_PATH%
echo set ALLUSERSPROFILE=%%CYGWIN_ROOT%%\ProgramData
echo set ProgramData=%%ALLUSERSPROFILE%%
echo if not "%%CYGWIN_USERNAME%%" == "" (
echo set USERNAME=%%CYGWIN_USERNAME%%
echo ^)
echo if "%%HOME_FOLDER%%" == "" (
echo set HOME_FOLDER=concygsys
echo ^)
echo set HOME=/home/%%HOME_FOLDER%%
echo rd /s /q "%%CYGWIN_ROOT%%\pkg-cache" 2^>NUL
echo type NUL ^>"%%CYGWIN_ROOT%%\etc\fstab"
echo "%%CYGWIN_ROOT%%\bin\bash" "%%CYGWIN_ROOT%%\%Portable_init_name%"
echo exit /b 0
echo.
echo :update
echo echo [96m%CONCYGSYS_INFO%[0m
echo set INSTALL_ROOT=%%~dp0
echo set DOWNLOADER=%%INSTALL_ROOT%%downloader.vbs
echo echo Creating a script that can download files [%%DOWNLOADER%%]...
echo (
echo echo url = Wscript.Arguments(0^^^)
echo echo target = Wscript.Arguments(1^^^)
echo echo WScript.Echo "Downloading '" ^^^& url ^^^& "' to '" ^^^& target ^^^& "'..."
echo echo Set req = CreateObject("WinHttp.WinHttpRequest.5.1"^^^)
echo echo req.Open "GET", url, False
echo echo req.Send
echo echo If req.Status ^^^<^^^> 200 Then
echo echo WScript.Echo "FAILED to download: HTTP Status " ^^^& req.Status
echo echo WScript.Quit 1
echo echo End If
echo echo Set buff = CreateObject("ADODB.Stream"^^^)
echo echo buff.Open
echo echo buff.Type = 1
echo echo buff.Write req.ResponseBody
echo echo buff.Position = 0
echo echo buff.SaveToFile target
echo echo buff.Close
echo echo.
echo ^) ^>"%%DOWNLOADER%%" ^|^| goto :fail
echo set INSTALLER=ConCygSys-installer.cmd
echo cscript //Nologo "%%DOWNLOADER%%" https://raw.githubusercontent.com/zhubanRuban/ConCygSys/master/%%INSTALLER%% "%%INSTALLER%%" ^|^| goto :fail
echo start "" "%%INSTALLER%%" ^|^| goto :fail
echo exit 0
echo :fail
echo del "%%DOWNLOADER%%" ^>NUL 2^>^&1
echo echo.
echo echo [101;30mUpdate FAILED![0m
echo echo Try uploading installer manually from %CONCYGSYS_LINK%
echo echo.
echo pause
echo exit 1
) >"%Concygsys_settings%" || goto :fail
echo Launching init script...
call "%Concygsys_settings%" launcherheader || goto :fail
set Pre_install=%CYGWIN_ROOT%\pre-install.sh
echo.
echo Creating script to install required software [%Pre_install%]...
(
echo #!/usr/bin/env bash
echo.
if not "%PROXY_HOST%" == "" (
echo if [[ $HOSTNAME == "%COMPUTERNAME%" ]]; then
echo export http_proxy=http://%PROXY_HOST%:%PROXY_PORT%
echo export https_proxy=$http_proxy
echo fi
)
if "%INSTALL_CONEMU%" == "yes" (
echo conemu_dir=$(cygpath -w "$CYGWIN_ROOT/../conemu"^)
echo if [[ ! -e $conemu_dir ]]; then
echo echo "Installing ConEmu..."
echo conemu_url="https://github.com$(wget https://github.com/Maximus5/ConEmu/releases/latest -O - 2>/dev/null | egrep '/.*/releases/download/.*/.*7z' -o)"
echo echo "Download URL=$conemu_url"
echo wget -nv --show-progress -O "${conemu_dir}.7z" $conemu_url
echo mkdir "$conemu_dir"
echo bsdtar -xvf "${conemu_dir}.7z" -C "$conemu_dir"
echo rm "${conemu_dir}.7z"
echo fi
echo echo %CONCYGSYS_INFO% ^> "$CYGWIN_ROOT/../conemu/DO-NOT-LAUNCH-CONEMU-FROM-HERE"
) else (
echo rm -rf $(cygpath -w "$CYGWIN_ROOT/../conemu"^)
)
if "%INSTALL_APT_CYG%" == "yes" (
echo echo "Installing/updating apt-cyg..."
echo wget -nv --show-progress -O /usr/local/bin/apt-cyg https://raw.githubusercontent.com/transcode-open/apt-cyg/master/apt-cyg
echo chmod +x /usr/local/bin/apt-cyg
) else (
echo rm -f /usr/local/bin/apt-cyg
)
if "%INSTALL_PSSH%" == "yes" (
echo echo "Installing/updating parallel ssh tool..."
echo wget -nv --show-progress -O /usr/local/bin/pssh https://raw.githubusercontent.com/zhubanRuban/cygwin-extras/master/pssh
echo chmod +x /usr/local/bin/pssh
) else (
echo rm -f /usr/local/bin/pssh
)
if "%INSTALL_PSCP%" == "yes" (
echo echo "Installing parallel scp tool..."
echo wget -nv --show-progress -O /usr/local/bin/pscp https://raw.githubusercontent.com/zhubanRuban/cygwin-extras/master/pscp
echo chmod +x /usr/local/bin/pscp
) else (
echo rm -f /usr/local/bin/pscp
)
if "%INSTALL_BASH_FUNK%" == "yes" (
echo if [[ ! -e /opt ]]; then mkdir /opt; fi
echo if [[ ! -e /opt/bash-funk/bash-funk.sh ]]; then
echo echo Installing [bash-funk]...
echo if hash git ^&^>/dev/null; then
echo git clone https://github.com/vegardit/bash-funk --branch master --single-branch /opt/bash-funk
echo elif hash svn ^&^>/dev/null; then
echo svn checkout https://github.com/vegardit/bash-funk/trunk /opt/bash-funk
echo else
echo mkdir /opt/bash-funk ^&^& \
echo cd /opt/bash-funk ^&^& \
echo wget -qO- --show-progress https://github.com/vegardit/bash-funk/tarball/master ^| tar -xzv --strip-components 1
echo fi
echo fi
) else (
echo rm -rf /opt/bash-funk
)
) >"%Pre_install%" || goto :fail
"%CYGWIN_ROOT%\bin\dos2unix" "%Pre_install%" || goto :fail
echo Launching pre-install script...
"%CYGWIN_ROOT%\bin\bash" "%Pre_install%" || goto :fail
del "%Pre_install%" >NUL 2>&1
echo.
echo Generating main launchers...
set Launch_conemu=%INSTALL_ROOT%Cygwin-ConEmu.cmd
if "%INSTALL_CONEMU%" == "yes" (
echo Generating ConEmu launcher [%Launch_conemu%]...
(
echo @echo off
echo :: %CONCYGSYS_INFO%
echo call "%%~dp0%Concygsys_settings_name%" launcherheader
echo :: to be in win home dir if running cmd from conemu
echo %%HOMEDRIVE%%
echo cd %%HOMEPATH%%
echo if "%%PROCESSOR_ARCHITEW6432%%" == "AMD64" (
echo start "" "%%~dp0conemu\ConEmu64.exe" %CONEMU_OPTIONS%
echo ^) else (
echo if "%%PROCESSOR_ARCHITECTURE%%" == "x86" (
echo start "" "%%~dp0conemu\ConEmu.exe" %CONEMU_OPTIONS%
echo ^) else (
echo start "" "%%~dp0conemu\ConEmu64.exe" %CONEMU_OPTIONS%
echo ^)
echo ^)
echo :: not to leave this launcher open if called from another batch file
echo exit 0
) >"%Launch_conemu%" || goto :fail
)
set Launch_cmd=%INSTALL_ROOT%Cygwin-Cmd.cmd
echo Generating cmd launcher [%Launch_cmd%]...
(
echo @echo off
echo :: %CONCYGSYS_INFO%
echo call "%%~dp0%Concygsys_settings_name%" launcherheader
echo if "%%1" == "" (
echo "%%CYGWIN_ROOT%%\bin\bash.exe" --login -i
echo ^) else (
echo "%%CYGWIN_ROOT%%\bin\bash.exe" --login -c %%*
echo ^)
) >"%Launch_cmd%" || goto :fail
set Launch_mintty=%INSTALL_ROOT%Cygwin-Mintty.cmd
echo Generating Mintty launcher [%Launch_mintty%]...
(
echo @echo off
echo :: %CONCYGSYS_INFO%
echo call "%%~dp0%Concygsys_settings_name%" launcherheader
echo start "" "%%CYGWIN_ROOT%%\bin\mintty.exe" --Title ConCygSys -
echo :: not to leave this launcher open if called from another batch file
echo exit 0
) >"%Launch_mintty%" || goto :fail
echo.
echo Launching bash once to initialize user home dir...
call "%Launch_cmd%" whoami || goto :fail
set Post_install=%CYGWIN_ROOT%\post-install.sh
echo.
echo Generating post-install script [%Post_install%]...
(
echo echo #!/usr/bin/env bash
echo mkdir -p /opt
:: delete messy bashrc if updating from earliest ConCygSys versions
if "%UPDATEFROMOLD%" == "yes" (
echo cat /etc/skel/.bashrc ^> ${HOME}/.bashrc
)
:: inserting proxy settings to .bashrc
if not "%PROXY_HOST%" == "" (
echo echo Adding proxy settings for host [%COMPUTERNAME%] to [${HOME}/.bashrc]...
echo (
echo echo if [[ $HOSTNAME == "%COMPUTERNAME%" ]]; then
echo echo export http_proxy=http://%PROXY_HOST%:%PROXY_PORT%
echo echo export https_proxy=$http_proxy
echo echo export no_proxy="::1,127.0.0.1,localhost,169.254.169.254,%COMPUTERNAME%,*.%USERDNSDOMAIN%"
echo echo export HTTP_PROXY=$http_proxy
echo echo export HTTPS_PROXY=$http_proxy
echo echo export NO_PROXY=$no_proxy
echo echo fi
echo ^) ^> /opt/bash_proxy
echo if grep -q '/opt/bash_proxy' "${HOME}/.bashrc"; then
echo sed -i '/bash_proxy/c\if [ -f "/opt/bash_proxy" ]; then source "/opt/bash_proxy"; fi' "${HOME}/.bashrc"
echo else
echo echo 'if [ -f "/opt/bash_proxy" ]; then source "/opt/bash_proxy"; fi' ^>^> "${HOME}/.bashrc"
echo fi
) else (
echo rm -f /opt/bash_proxy
echo sed -i '/bash_proxy/d' "${HOME}/.bashrc"
)
:: inserting soursing bash-funk in .bashrc if one is selected to install
if "%INSTALL_BASH_FUNK%" == "yes" (
echo echo Adding bash-funk to [${HOME}/.bashrc]...
echo if grep -q '/opt/bash-funk/bash-funk.sh' "${HOME}/.bashrc"; then
echo sed -i '/bash-funk.sh/c\if [ -f "/opt/bash-funk/bash-funk.sh" ]; then source "/opt/bash-funk/bash-funk.sh"; fi' "${HOME}/.bashrc"
echo else
echo echo 'if [ -f "/opt/bash-funk/bash-funk.sh" ]; then source "/opt/bash-funk/bash-funk.sh"; fi' ^>^> "${HOME}/.bashrc"
echo fi
) else (
echo sed -i '/bash-funk.sh/d' "${HOME}/.bashrc"
)
:: inserting custom .bashrc settings
if "%INSTALL_BASHRC_CUSTOMS%" == "yes" (
echo echo Adding .bashrc customizations to [${HOME}/.bashrc] and [${HOME}/.inputrc]...
echo wget -nv --show-progress -O /opt/bashrc_custom https://raw.githubusercontent.com/zhubanRuban/cygwin-extras/master/bashrc_custom
echo if grep -q '/opt/bashrc_custom' "${HOME}/.bashrc"; then
echo sed -i '/bashrc_custom/c\if [ -f "/opt/bashrc_custom" ]; then source "/opt/bashrc_custom"; fi' "${HOME}/.bashrc"
echo else
echo echo 'if [ -f "/opt/bashrc_custom" ]; then source "/opt/bashrc_custom"; fi' ^>^> "${HOME}/.bashrc"
echo fi
echo cat /etc/skel/.inputrc ^> "${HOME}/.inputrc"
echo wget -nv --show-progress https://raw.githubusercontent.com/zhubanRuban/cygwin-extras/master/inputrc_custom -O- ^>^> "${HOME}/.inputrc"
) else (
echo rm -f /opt/bashrc_custom
echo sed -i '/bashrc_custom/d' "${HOME}/.bashrc"
echo cat /etc/skel/.inputrc ^> "${HOME}/.inputrc"
)
:: inserting ssh-agent settings
set ssh_agent_config=%INSTALL_ROOT%ssh_agent_config
if "%INSTALL_SSH_AGENT_TWEAK%" == "yes" (
echo echo Adding SSH agent tweak to [${HOME}/.bashrc]...
echo wget -nv --show-progress -O /opt/ssh-agent-tweak https://raw.githubusercontent.com/zhubanRuban/cygwin-extras/master/ssh-agent-tweak
echo if grep -q '/opt/ssh-agent-tweak' "${HOME}/.bashrc"; then
echo sed -i '/ssh-agent-tweak/c\if [ -f "/opt/ssh-agent-tweak" ]; then source "/opt/ssh-agent-tweak"; fi' "${HOME}/.bashrc"
echo else
echo echo 'if [ -f "/opt/ssh-agent-tweak" ]; then source "/opt/ssh-agent-tweak"; fi' ^>^> "${HOME}/.bashrc"
echo fi
) else (
echo rm -f /opt/ssh-agent-tweak
echo sed -i '/ssh-agent-tweak/d' "${HOME}/.bashrc"
)
) > "%Post_install%" || goto :fail
"%CYGWIN_ROOT%\bin\dos2unix" "%Post_install%" || goto :fail
echo Launching post-install script...
"%CYGWIN_ROOT%\bin\bash" "%Post_install%" || goto :fail
del "%Post_install%" >NUL 2>&1
set Conemu_config=%INSTALL_ROOT%conemu\ConEmu.xml
if "%INSTALL_CONEMU%" == "yes" (
echo.
echo Replacing ConEmu config...
(
echo ^<?xml version="1.0" encoding="utf-8"?^>
echo ^<!--
echo %CONCYGSYS_INFO%
echo --^>
echo ^<key name="Software"^>
echo ^<key name="ConEmu"^>
echo ^<key name=".Vanilla"^>
echo ^<value name="StartTasksName" type="string" data="{Cygwin::Mintty}"/^>
echo ^<value name="WindowMode" type="dword" data="00000520"/^>
echo ^<value name="ShowScrollbar" type="hex" data="01"/^>
echo ^<value name="QuakeStyle" type="hex" data="01"/^>
echo ^<value name="QuakeAnimation" type="ulong" data="50"/^>
echo ^<value name="Min2Tray" type="hex" data="01"/^>
echo ^<value name="TryToCenter" type="hex" data="01"/^>
echo ^<value name="TabFontHeight" type="long" data="12"/^>
echo ^<value name="TabsLocation" type="hex" data="01"/^>
echo ^<value name="TabFontFace" type="string" data="Arial Black"/^>
echo ^<value name="TabConsole" type="string" data="%%m⬛ m%%s"/^>
echo ^<value name="TabModifiedSuffix" type="string" data="*"/^>
echo ^<value name="TabDblClick" type="ulong" data="3"/^>
echo ^<value name="AlphaValue" type="hex" data="dd"/^>
echo ^<value name="StatusBar.Show" type="hex" data="00"/^>
echo ^<value name="CTS.IntelligentExceptions" type="string" data="far"/^>
echo ^<value name="CTS.ResetOnRelease" type="hex" data="01"/^>
echo ^<value name="KeyboardHooks" type="hex" data="01"/^>
echo ^<value name="UseInjects" type="hex" data="01"/^>
echo ^<value name="Update.CheckOnStartup" type="hex" data="01"/^>
echo ^<value name="Update.UseBuilds" type="hex" data="02"/^>
echo ^<value name="FontUseUnits" type="hex" data="01"/^>
echo ^<value name="FontSize" type="ulong" data="14"/^>
echo ^<value name="StatusFontHeight" type="long" data="12"/^>
echo ^<value name="KillSshAgent" type="hex" data="00"/^>
echo ^<key name="HotKeys"^>
echo ^<value name="MinimizeRestore" type="dword" data="000011c0"/^>
echo ^<value name="Multi.NewSplitV" type="dword" data="00a05b4f"/^>
echo ^<value name="Multi.NewSplitH" type="dword" data="00a05b45"/^>
echo ^</key^>
echo ^<key name="Tasks"^>
echo ^<value name="Count" type="long" data="4"/^>
echo ^<key name="Task1"^>
echo ^<value name="Name" type="string" data="{Cygwin::Connector}"/^>
echo ^<value name="Flags" type="dword" data="00000004"/^>
echo ^<value name="Hotkey" type="dword" data="00005b54"/^>
echo ^<value name="GuiArgs" type="string" data=""/^>
rem Removed path to icon to get more space for tabs
rem Terminal changed to cygwin instead of xterm-256color to prevent issues in screen session over SSH
if "%CYGWIN_SETUP%" == "setup-x86_64.exe" (
echo ^<value name="Cmd1" type="string" data=""%%ConEmuBaseDirShort%%\conemu-cyg-64.exe" -new_console:p -new_console:P:"<xterm>" -new_console:h5000"/^>
)
if "%CYGWIN_SETUP%" == "setup-x86.exe" (
echo ^<value name="Cmd1" type="string" data=""%%ConEmuBaseDirShort%%\conemu-cyg-32.exe" -new_console:p -new_console:P:"<xterm>" -new_console:h5000"/^>
)
echo ^<value name="Active" type="long" data="0"/^>
echo ^<value name="Count" type="long" data="1"/^>
echo ^</key^>
echo ^<key name="Task2"^>
echo ^<value name="Name" type="string" data="{Cygwin::Cmd}"/^>
echo ^<value name="Flags" type="dword" data="00000004"/^>
echo ^<value name="Hotkey" type="dword" data="00005b42"/^>
echo ^<value name="GuiArgs" type="string" data=""/^>
echo ^<value name="Cmd1" type="string" data=""%%ConEmuDir%%\..\cygwin\bin\bash.exe" --login -i -new_console:p -new_console:P:"<xterm>" -new_console:h5000"/^>
echo ^<value name="Active" type="long" data="0"/^>
echo ^<value name="Count" type="long" data="1"/^>
echo ^</key^>
echo ^<key name="Task3"^>
echo ^<value name="Name" type="string" data="{Cygwin::Mintty}"/^>
echo ^<value name="Flags" type="dword" data="00000005"/^>
echo ^<value name="Hotkey" type="dword" data="00005b4d"/^>
echo ^<value name="GuiArgs" type="string" data="/icon " ""/^>
echo ^<value name="Cmd1" type="string" data=""%%ConEmuDir%%\..\cygwin\bin\mintty.exe" %MINTTY_OPTIONS% - -new_console:pm:/mnt -new_console:P:"<xterm>""/^>
echo ^<value name="Active" type="long" data="0"/^>
echo ^<value name="Count" type="long" data="1"/^>
echo ^</key^>
echo ^<key name="Task4"^>
echo ^<value name="Name" type="string" data="{WSL}"/^>
echo ^<value name="Flags" type="dword" data="00000004"/^>
echo ^<value name="Hotkey" type="dword" data="00005b55"/^>
echo ^<value name="GuiArgs" type="string" data="-icon "%%USERPROFILE%%\AppData\Local\lxss\bash.ico""/^>
echo ^<value name="Cmd1" type="string" data=""%%SystemRoot%%\system32\bash.exe" ~ -new_console:pm:/mnt -new_console:P:"<ubuntu>" -new_console:h5000"/^>
echo ^<value name="Active" type="long" data="0"/^>
echo ^<value name="Count" type="long" data="1"/^>
echo ^</key^>
echo ^</key^>
echo ^</key^>
echo ^</key^>
echo ^</key^>
)> "%Conemu_config%" || goto :fail
)
echo.
echo Cleaning up...
:: deleting obsolete files used by previous concygsys versions
rd /s /q "%INSTALL_ROOT%data" >NUL 2>&1
del "%CYGWIN_ROOT%\updater.cmd" >NUL 2>&1
del "%CYGWIN_ROOT%\cygwin-settings.cmd" >NUL 2>&1
del "%CYGWIN_ROOT%\cygwin-install-options.cmd" >NUL 2>&1
:: delting readme and licence files
del "%INSTALL_ROOT%LICENSE" >NUL 2>&1
del "%INSTALL_ROOT%README.md" >NUL 2>&1
:aftercygwinupdate
echo.
if "%UPDATEMODE%" == "yes" (
echo [102;30mUpdate SUCCEEDED![0m
) else (
echo [102;30mInstallation SUCCEEDED![0m
)
echo.
echo Use launchers in [%INSTALL_ROOT%] to run Cygwin Portable.
echo.
pause
:: deleting installer and old launchers
del "%INSTALL_ROOT%ConCygSys*" >NUL 2>&1
exit 0
:fail
echo.
if "%UPDATEMODE%" == "yes" (
echo [101;30mUpdate FAILED![0m
echo Try uploading installer manually from %CONCYGSYS_LINK%
) else (
echo [101;30mInstallation FAILED![0m
)
echo.
pause
exit 1