-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathatom.xml
executable file
·6186 lines (4840 loc) · 389 KB
/
atom.xml
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
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title><![CDATA[Learn-a-holic Geek Notes]]></title>
<link href="http://learnaholic.me/atom.xml" rel="self"/>
<link href="http://learnaholic.me/"/>
<updated>2015-07-05T14:46:32+02:00</updated>
<id>http://learnaholic.me/</id>
<author>
<name><![CDATA[Kornelije Sajler]]></name>
<email><![CDATA[[email protected]]]></email>
</author>
<generator uri="http://octopress.org/">Octopress</generator>
<entry>
<title type="html"><![CDATA[Ubuntu VPS Step-By-Step Configuration Notes]]></title>
<link href="http://learnaholic.me/2014/01/09/ubuntu-vps-step-by-step-config-notes/"/>
<updated>2014-01-09T14:54:00+01:00</updated>
<id>http://learnaholic.me/2014/01/09/ubuntu-vps-step-by-step-config-notes</id>
<content type="html"><![CDATA[<p><strong>UPDATED</strong> (June 30th, 2015)</p>
<p><strong>Changes</strong>:</p>
<p><em>June 30th, 2015</em></p>
<ul>
<li>Covering <em>Ubuntu 14.04 LTS</em>.</li>
<li>Adde extra <em>SSH</em> security, using <em>Public Keys</em> and some more tweaks in <code>sshd_config</code>.</li>
<li>Added usual <em>PHP</em> & <em>MySQL</em> install and configure.</li>
<li>Using <code>service <COMMAND> <ACTION></code> seems <em>Ubuntu</em> nowdays have problem with <code>/etc/init.d</code>, it is old school, but I’ve liked it. (Thanks to <em>Rapha</em> for mention it in comments).</li>
<li>Latest Ruby <code>2.2.2</code></li>
</ul>
<p><em>January 9th, 2014</em></p>
<ul>
<li>First version covering <em>Ubuntu 13</em>.</li>
</ul>
<p>Here are notes and step-by-step tutorial to set <em>Ubuntu VPS</em> secure and with <em>nginx</em>, <em>node.js</em>, <em>ruby</em>, <em>PostgreSQL</em>, …</p>
<p>It should work for <em>Ubuntu</em> 12 or 13 or 14 versions. My <em>VPS</em> provider still doesn’t have support <em>Ubuntu</em> 15, but I don’t think that there would be any problem using this for <em>Ubuntu</em> 15.</p>
<p>It assumes knowledge of <em>SSH</em> and connecting to your fresh VPS install.</p>
<p>Throughout the install process for editing I’m using <em>vi</em>, you can use what ever makes you happy: <em>emacs</em>, <em>nano</em>, …</p>
<p>Those are just my notes, if someone has something better or can improve it please do comment!</p>
<h2>Security</h2>
<h3>Update and installing essential software</h3>
<pre><code>sudo apt-get -y update
sudo apt-get -y install curl git-core python-software-properties software-properties-common
</code></pre>
<h3>Locale problem</h3>
<p>Very annoying error in apt: <em>locale: Cannot set LC_CTYPE</em>. It is probably due to your local machine, add this to your <code>.bashrc</code> or <code>.zshrc</code>:</p>
<pre><code>export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
</code></pre>
<h3>User - Admin Group & SSH</h3>
<pre><code>sudo groupadd admin
sudo adduser <USERNAME>
sudo usermod -a -G admin <USERNAME>
sudo dpkg-statoverride --update --add root admin 4750 /bin/su
</code></pre>
<p>Test new user and test that has <code>sudo</code> privileges:</p>
<pre><code>su <USERNAME>
</code></pre>
<p>Secure SSH:</p>
<pre><code>sudo vi /etc/ssh/sshd_config
</code></pre>
<p>Make these changes:</p>
<ul>
<li><code>Port</code> <DESIRED_PORT_NUMBER> (Don’t use default 22)</li>
<li><code>PermitRootLogin</code> <code>no</code></li>
<li><code>X11Forwarding</code> <code>no</code></li>
<li><code>AllowTcpForwarding</code> <code>no</code></li>
<li><code>AllowUsers</code> USERNAME USERNAME2</li>
</ul>
<p>If your SSH is very slow setting <code>X11Forwarding</code> to <code>no</code> can really help in this case!</p>
<pre><code>sudo service ssh restart
</code></pre>
<p>Connect to <em>VPS SSH</em>:</p>
<pre><code>ssh <USERNAME>@<VPS_DOMAIN_OR_IP> -p <PORT>
</code></pre>
<h3>SSH Extra Security</h3>
<p>The idea is to not permit passwords and use <em>SSH</em> keys for authentication, and some other tweaks to <em>SSH</em>.</p>
<pre><code>mkdir ~/.ssh
vi ~/.ssh/authorized_keys
</code></pre>
<p>And paste the content of your local machine <em>Public Key</em> file: <code>.ssh/id_rsa.pub</code> and make it <code>rw</code> only for current user:</p>
<pre><code>chmod 600 ~/.ssh/authorized_keys
</code></pre>
<p>Or use <code>ssh-copy-id</code> from your local machine, which isn’t on <em>Mac</em>, and can be installed with <code>brew</code> but I have no luck:</p>
<pre><code>brew install ssh-copy-id
ssh-copy-id "<USERNAME>@<VPS_DOMAIN_OR_IP> -p <PORT>"
</code></pre>
<p>Try to connect to <em>SSH</em> and it should not ask you for password, it should be instant login:</p>
<pre><code>ssh <USERNAME>@<VPS_DOMAIN_OR_IP> -p <PORT>
</code></pre>
<p>Open <em>SSH</em> config file, uncomment <code>PasswordAuthentication</code> which is by default set to <code>yes</code>:</p>
<pre><code>sudo vi /etc/ssh/sshd_config
</code></pre>
<p>Change it to <code>no</code>:</p>
<pre><code>PasswordAuthentication no
</code></pre>
<p>Restart <em>SSH</em> and try to connect again:</p>
<pre><code>sudo service ssh restart
</code></pre>
<p>Exit the VPS shell and try to connect to VPS <em>SSH</em>.</p>
<h3>Firewall</h3>
<p>To have <code>ping</code> and <code>apt-get</code> working, add the following into <em>iptables</em>, as <em>ufw</em> just interfaces with it.</p>
<pre><code>sudo iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
sudo apt-get -y install ufw
sudo vi /etc/default/ufw
</code></pre>
<p>Make this change:</p>
<pre><code>IPV6=no
</code></pre>
<p>Allow some ports and services:</p>
<pre><code>sudo ufw allow <PORT_NUMBER_CHANGED_TO_SSH>
sudo ufw limit ssh
sudo ufw allow 80/tcp
sudo ufw allow out 53
sudo ufw logging on
</code></pre>
<p>Be sure that you allowed the changed port for <em>SSH</em> because otherwise, you’ll be unable to get into VPS!!!</p>
<pre><code>sudo ufw enable
</code></pre>
<p>Check the Firewall status with:</p>
<pre><code>sudo ufw status verbose
</code></pre>
<h3>sysctl</h3>
<pre><code>sudo mv /etc/sysctl.conf /etc/sysctl.conf.orig
sudo vi /etc/sysctl.conf
</code></pre>
<p>Add this to a <code>sysctl.conf</code>:</p>
<pre><code># IP Spoofing protection
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.default.rp_filter = 1
# Ignore ICMP broadcast requests
net.ipv4.icmp_echo_ignore_broadcasts = 1
# Disable source packet routing
net.ipv4.conf.all.accept_source_route = 0
net.ipv6.conf.all.accept_source_route = 0
net.ipv4.conf.default.accept_source_route = 0
net.ipv6.conf.default.accept_source_route = 0
# Ignore send redirects
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
# Block SYN attacks
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_max_syn_backlog = 2048
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 5
# Log Martians
net.ipv4.conf.all.log_martians = 1
net.ipv4.icmp_ignore_bogus_error_responses = 1
# Ignore ICMP redirects
net.ipv4.conf.all.accept_redirects = 0
net.ipv6.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv6.conf.default.accept_redirects = 0
# Ignore Directed pings
net.ipv4.icmp_echo_ignore_all = 1
</code></pre>
<p> Then run, there can be possible some errors, especially on <em>VPS</em> with <em>OpenVZ</em>…</p>
<pre><code>sudo sysctl -p
</code></pre>
<h3>Denyhost or Fail2Ban</h3>
<p>Before <em>Denyhost</em> was uset but it seems it is no longer maintained and there is no Ubuntu package anymore so the <em>Fail2Ban</em> is alternative, but since the SSH is set to permit only <em>SSH</em> keys, both of those are redundant.</p>
<h3>Remove Samba File Sharing</h3>
<p>If for some reason you have completely unnecessary <em>Samba</em> installed by default on VPS you can remove it with:</p>
<pre><code>sudo apt-get -y remove --purge samba
</code></pre>
<h3>Remove Bind DNS Server</h3>
<p>Same with Bind, if you don’t need it, remove it!</p>
<pre><code>sudo apt-get -y remove --purge bind9
sudo rm -rf /var/cache/bind
sudo rm -rf /usr/share/bind9
sudo rm -rf /etc/bind
</code></pre>
<h2>SSH Key and GitHub</h2>
<p>Check if <code>~/.ssh</code> has <code>*.pub</code> files, if not generate the <em>SSH</em> key:</p>
<pre><code>ssh-keygen -t rsa -C "<YOUR_EMAIL>"
</code></pre>
<p>Use default place to store: <code>~/.ssh</code></p>
<p>Do not use passphrase, unless you want to type every time you commit to <em>GitHub</em>. <em>(Or anyone knows better way?).</em></p>
<pre><code>cat ~/.ssh/id_rsa.pub
</code></pre>
<p>Copy the contents to clipboard.
Go to <em>GitHub</em> > Account Settings > SSH Keys.
Hit <code>Add SSH Key</code> give title and in <code>Key</code> paste public key from clipboard.</p>
<pre><code>ssh [email protected]
eval `ssh-agent -s`
ssh-add -k
</code></pre>
<h2>Software Install</h2>
<h3>Instal nginx</h3>
<pre><code>sudo add-apt-repository ppa:nginx/stable
sudo apt-get -y update
sudo apt-get -y install nginx
sudo service start nginx
</code></pre>
<p>If error is <code>nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)</code> then probably <em>Apache</em> is installed beforehand:</p>
<pre><code>sudo apt-get remove apache2-mpm-prefork
sudo apt-get remove apache2-mpm-worker
sudo apt-get remove apache2
</code></pre>
<p>You can check and purge installed <em>Apache</em>:</p>
<pre><code>sudo dpkg --get-selections | grep apache
# Purge others that are given as result from above command
sudo dpkg --purge apache2
sudo service nginx start
</code></pre>
<p>If something is wrong look for nginx logs:</p>
<pre><code>sudo vi /var/log/nginx/error.log
</code></pre>
<h3>Install and configure PostgreSQL, create DB and DB User</h3>
<pre><code>sudo add-apt-repository ppa:pitti/postgresql
sudo apt-get -y update
sudo apt-get install -y postgresql libpq-dev
</code></pre>
<p>Log into <code>postgres</code> change main password, create db user with password and create new database with previously created user as owner:</p>
<pre><code>sudo -u postgres psql
\password "<PASSWORD>"
create user <USERNAME> with password '<USER_PASSWORD>';
create database <DB_NAME> owner <USERNAME>;
\q
</code></pre>
<h3>Install MySQL, create DB and DB User</h3>
<pre><code>sudo apt-get install mysql-server
</code></pre>
<p>The install will prompt you for <code>root</code> user password that needs to be re-entered, choose password wisely and try to remember it! After install log into <em>MySQL</em>:</p>
<pre><code>mysql -u root -p # After enter there is need to write password and hit enter again
</code></pre>
<p>Use mysql command line app for interacting with <em>MySQL</em>, lets create user and DB with user granted on this DB:</p>
<pre><code>mysql> CREATE DATABASE <DB_NAME>;
mysql> SHOW DATABASES; # The new db should be listed.
mysql> CREATE USER '<DB_USERNAME>'@'localhost';
mysql> SELECT User,Host FROM mysql.user; # The new user should be listed on host localhost.
mysql> GRANT ALL ON <DB_NAME>.* to '<DB_USERNAME>'@'localhost' identified by '<DB_PASSWORD>'; # It will grant all on this DB by this user.
mysql> exit # Or new command \q
</code></pre>
<p>If you need to run <em>SQL</em> script for database, use this from command line:</p>
<pre><code>mysql -u <DB_USERNAME> -p <DB_NAME> < <SCRIPT_NAME>.sql
</code></pre>
<h3>Install Ruby with rbenv and rbenv-installer</h3>
<pre><code>cd
curl https://raw.github.com/fesplugas/rbenv-installer/master/bin/rbenv-installer | bash
vi .bashrc
</code></pre>
<p>At top add:</p>
<pre><code>export RBENV_ROOT="${HOME}/.rbenv"
if [ -d "${RBENV_ROOT}" ]; then
export P
ATH="${RBENV_ROOT}/bin:${PATH}"
eval "$(rbenv init -)"
fi
</code></pre>
<p>Reset <code>.bashrc</code>:</p>
<pre><code>. ~/.bashrc
</code></pre>
<p>Note that <code>bootstrap-ubuntu-12-04</code> works fine for <em>Ubuntu</em> 13 & 14 (probably 15 too):</p>
<pre><code>rbenv bootstrap-ubuntu-12-04
</code></pre>
<p>Firstly list <em>rbenv</em> available <em>Ruby</em> versions and pick one to install:</p>
<pre><code>rbenv install -l
rbenv install 2.2.2
</code></pre>
<p>Set chosen <em>Ruby</em> version to be “global”, and test it:</p>
<pre><code>rbenv global 2.2.2
ruby -v
</code></pre>
<h3>Install PHP & friends</h3>
<p>The long list of <em>PHP</em> packages covering <em>Imagemagick</em>, <em>MySQL</em>, <em>bcrypt</em>,…:</p>
<pre><code>sudo apt-get install imagemagick php5-fpm php5-mysql php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl php5-xcache
</code></pre>
<p>Change usaul suspects of <code>php.ini</code> properties:</p>
<pre><code>sudo vi /etc/php5/fpm/php.ini
</code></pre>
<ul>
<li><code>upload_max_filesize</code> = (SOME_NUMBER)M (Default 2Mb - safe to use 25M)</li>
<li><code>post_max_size</code> = (SOME_NUMBER)M (Default 8Mb - safe to use 25M)</li>
<li><code>memory_limit</code> = (SOME_NUMBER)M (Default 128Mb - safe to use 512M)</li>
</ul>
<p>Restart <em>PHP-FPM</em> and <em>Nginx</em>:</p>
<pre><code>sudo pkill php5-fpm; service php5-fpm start
sudo service nginx restart
</code></pre>
<h3>Install node.js</h3>
<pre><code>sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get -y update
sudo apt-get install -y nodejs
</code></pre>
<h3>Install and Configure redis</h3>
<pre><code>sudo apt-get -y install redis-server
sudo cp /etc/redis/redis.conf /etc/redis/redis.conf.default
</code></pre>
<ul>
<li><code>pidfile /var/run/redis-server.pid</code></li>
<li><code>logfile /var/log/redis-server.log</code></li>
</ul>
<h2>Esoteric Installments</h2>
<h3>Install erlang</h3>
<pre><code>sudo apt-get -y install erlang-nox
</code></pre>
<h3>Install and Configure riak</h3>
<pre><code>curl http://apt.basho.com/gpg/basho.apt.key | sudo apt-key add -
sudo bash -c "echo deb http://apt.basho.com $(lsb_release -sc) main > /etc/apt/sources.list.d/basho.list"
</code></pre>
<p>If <em>Ubuntu</em> is not <em>LTS</em> instead of <code>lsb_release -sc</code> use name of <em>LTS</em>, eg. <em>Ubuntu</em> 14.10 (<em>Utopic</em>) is not LTS use 14.04 codename <em>trusty</em> instead. Use this <a href="https://en.wikipedia.org/wiki/List_of_Ubuntu_releases#Table_of_versions">Wikipedia table</a> to help with names for particular <em>Ubuntu</em> version(s).</p>
<pre><code>sudo apt-get -y update
sudo apt-get -y install riak
</code></pre>
<h4>Change PAM Based Limits for riak</h4>
<pre><code>sudo vi /etc/pam.d/common-session
</code></pre>
<p>Add at the end of file:</p>
<pre><code>session required pam_limits.so
</code></pre>
<p>Update <code>limits.conf</code>:</p>
<pre><code>sudo vi /etc/security/limits.conf
# Add this to limits.conf
* soft nofile 65536
* hard nofile 65536
</code></pre>
<p>If accessing riak nodes via <em>SSH</em>:</p>
<pre><code>sudo vi /etc/ssh/sshd_config
UseLogin yes
</code></pre>
<p>Reboot machine and test that limit of open files is <code>65536</code> with:</p>
<pre><code>ulimit -a
> open files (-n) 65536
</code></pre>
<p>or with:</p>
<pre><code>ulimit -n
</code></pre>
<p>Hope it helps, please give feedback and comments with any missing/wrong parts to this
<em>Ubunt VPS</em> install, because I’m far from <em>Linux</em> guru, but appreciate secure and stable <em>Linux</em> machine!</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[Enable NTFS write on Mac OS X Mavericks for free and geeky way]]></title>
<link href="http://learnaholic.me/2013/11/11/enable-ntfs-write-on-mac-os-x-mavericks/"/>
<updated>2013-11-11T16:03:00+01:00</updated>
<id>http://learnaholic.me/2013/11/11/enable-ntfs-write-on-mac-os-x-mavericks</id>
<content type="html"><![CDATA[<p>By default Mac OS X Mavericks (same goes for older distribution) has <em>Microsoft</em> file system <em>NTFS</em> read-only. There are proprietary software like <em>Tuxera</em> that can enable to write to NTFS. Interesting point is that you don’t need to buy it is for free, you just need to geek a bit to make it writable.</p>
<p>Are you geeky enough?</p>
<p>Surely you guessed it, this will not go without console application in <em>Mac</em> this is <em>Terminal</em>, and some of us may us better one <em>iTerm2</em>, either way you’ll need to know how to open it.</p>
<p>Easiest way is to use <em>Spotlight</em> just hit <code>Cmd + Space</code> and write <em>Terminal</em> and here we go…
The other way is in your <em>Finder</em> <code>Applications > Utilities > Terminal</code>. (Those who use <em>iTerm2</em>, I bet they know how to open it :D)</p>
<p>Before we start on, <strong>MAKE SURE</strong> that your USB stick, external HDD, has single name to it, or better yet without spaces in name! e.g. ”<code>MyPrecious</code>” is fine, ”<code>My Precious</code>” is not!<br/>
And what I mean by name is the label name that you get in <em>Finder</em> or <em>Desktop</em> when you plug your device, that is underneath the HDD icon, this is mostly set by manufacture, and if you know how to format on <em>Windows</em>, you can also set custom name!</p>
<p>In <em>Terminal</em> create <code>/etc/fstab</code> with <code>nano</code>, easier for most users, others can use <code>vim</code>, <code>emacs</code>… (it will ask you for your username password if you have it, write it, if not just hit enter):</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'>sudo nano /etc/fstab
</span></code></pre></td></tr></table></div></figure>
<p>When is created enter this content inside of <code>/etc/fstab</code>, be sure that you know the name of your device:</p>
<p><img src="http://learnaholic.me/images/mounted_disk_label_name.png"></p>
<p>In my case in image is <code>Elements</code>, be sure to change below “device-name” to name you got, and there is no spaces in name!!!</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="nv">LABEL</span><span class="o">=</span>device-name none ntfs rw,auto,nobrowse
</span></code></pre></td></tr></table></div></figure>
<p>When you finished entering content, use <code>Ctrl + X</code> (it is lowercase x), it will prompt you to save it or not, enter <code>y</code>, you’ll get another prompt to write to file, just hit enter.<br/>
And that’s essentially it, I will not even try to explain what we just did, it will melt brain for most users, just believe me… I know what I’m doing!</p>
<p>The only problem is now, when you plug your device, you’re not gonna get a icon on <em>Desktop</em> or <em>Finder</em>.<br/>
Mac stores its mounted devices in hidden folder <code>/Volumes</code>, so while we have <em>Terminal</em> up and running, make symbolic link of it to the <em>Desktop</em>:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'>sudo ln -s /Volumes ~/Desktop/Volumes
</span></code></pre></td></tr></table></div></figure>
<p>Afterwards unmount your device (right click on device icon and choose <code>Eject</code>), sometimes is needed to reboot (restart) your Mac, so it is safe to do so!</p>
<p>Now on your <em>Desktop</em>, you’ll have a “folder” named <code>Volumes</code>, and when you plug your <em>NTFS</em> device, go into this folder, and you’ll find there your device armed and ready!<br/>
If you want to save from some other application, when the dialog is open, got to <code>Desktop > Volumes > [Name of Device]</code> and save it!</p>
<p>And best thing is, if you are in no need to have support for NTFS anymore, remove <code>/etc/fstab</code>:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'>sudo rm /etc/fstab
</span></code></pre></td></tr></table></div></figure>
<p>… and everything is as before and live happily ever after!</p>
<p>This is how you can have writable <em>NTFS</em> support on your <em>Mac</em>, totally for free, and for bonus feeling geeky :)</p>
<p>But nevertheless, if you want to buy the software that does it for you, sure, be my guest… nobody is geek!</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[ArchLinux VirtualBox Install Notes]]></title>
<link href="http://learnaholic.me/2013/11/10/archlinux-virtualbox-install-notes/"/>
<updated>2013-11-10T14:54:00+01:00</updated>
<id>http://learnaholic.me/2013/11/10/archlinux-virtualbox-install-notes</id>
<content type="html"><![CDATA[<p>For a few years now I really wanted to get some time to learn/install and play around with <a href="https://www.archlinux.org/">ArchLinux</a>. <em>ArchLinux</em> is very minimal, highly customizable, but powerful distribution of <em>Linux</em> based on one of oldest distribution <em>Slackware</em> and <em>BSD</em> like Unix.</p>
<p><em>ArchLinux</em> is not for everybody, if you want everything out-of-box, then probably <em>Ubuntu</em>, <em>Mint</em>, <em>Fedora</em> or like are for you. But for me, and I have <em>Mac</em>, I see no difference between <em>Ubuntu</em> and <em>Mac</em>. Because for both, out-of-box you’ll get a predefined UI, apps. I’m not going into discussion that most of this can be change in <em>Ubuntu</em>, but how much of them really change?</p>
<p><em>ArchLinux</em> is completely opposite, the install is not really easy (for average PC user), nor GUI like, and after install you are left with bare minimal packages needed for OS to run and configure, and without GUI too.</p>
<p>This installation is not for Linux <em>n00bs</em>, some familiarity with console and Linux commands should be expected, because some of notes are really not in depth and there are thing assumed, like basic knowledge of <code>vim</code> (or you can replace <code>vim</code> with <code>nano</code>).</p>
<p>This is all part of my learning <em>ArchLinux</em>, and then to dual boot it on my <em>Mac</em> with <em>Mac OS X</em>. And even though I really like <em>Mac</em>, I really have huge respect and likeness for <em>Linux</em>, and my minimalistic side was in real need of distribution like <em>ArchLinux</em>. Why <em>ArchLinux</em>?</p>
<p>Just look into their <a href="https://wiki.archlinux.org/">wiki</a>, that much of content and expressiveness (sometimes maybe too much) it is really what it makes <em>ArchLinux</em> great, and second is the <a href="https://aur.archlinux.org/"><em>Arch User Repository</em> (<em>AUR</em>)</a> where you can search for packages, install and comment them (very helpful comments!).</p>
<p>Another strength is that <em>ArchLinux</em> has no release versions, it is rolling released distribution, and if you update weekly or monthly, you’ll always have latest versions of your applications and <em>ArchLinux</em> respectively. Another strength (that is for someone is weakness) is that mostly <em>ArchLinux</em> packages are latest stable releases of software, and even this can get you to <em>dependency hell</em>, in most cases, you’ll end up with latest software with all new features and bug fixes immediately, and not waiting for next version release of OS distribution.</p>
<blockquote><p>Note:</p>
<p>I use <a href="http://en.wikipedia.org/wiki/Dvorak_Simplified_Keyboard">Dvorak keyboard layout</a> and it is throughout the installation, if you use <code>us</code> layout ignore all of it, but if you use some other layout e.g. <code>hr</code> then replace where <code>dvorak</code> to <code>hr</code>!</p></blockquote>
<h2>VirtualBox Pre-installation</h2>
<ul>
<li><a href="https://www.virtualbox.org/wiki/Downloads">Download</a>, install and create new <em>VirtualBox</em> machine, for <em>ArchLinux</em> x64.</li>
<li>Download “dual” ISO from <a href="https://www.archlinux.org/download/">ArchLinux mirrors</a>.</li>
<li>Add <em>ISO</em> to <em>VirtualBox</em> and set it for CD/DVD.</li>
</ul>
<h2>Installation</h2>
<p>Choose <code>x86_64</code> version.<br/>
Change to <code>Dvorak</code> layout:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>loadkeys dvorak</span></code></pre></td></tr></table></div></figure>
<p>Ping <em>google.com</em> to see if there is Internet connection, if not run:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>dhcpcd</span></code></pre></td></tr></table></div></figure>
<p>Update <code>pacman</code> package manager repository:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>pacman -Sy</span></code></pre></td></tr></table></div></figure>
<p>Install <code>vim</code> as a default editor for installation (even though you can use installed plain old <code>vi</code> or <code>nano</code>):</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>pacman -S vim</span></code></pre></td></tr></table></div></figure>
<p>See what disk structure there is:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>lsblk</span></code></pre></td></tr></table></div></figure>
<p>For <strong>MBR</strong> installation use <code>cfdisk</code>:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>cfdisk /dev/sda</span></code></pre></td></tr></table></div></figure>
<p>Create new partition with choosing <code>[ New ]</code> with 1024 Mb for <code>boot</code> directory (not necessary!).</p>
<p>Make it bootable by choosing <code>[ Bootable ]</code>.</p>
<p>Create new partition with choosing <code>[ New ]</code> with rest of your disk space for <code>root</code> folder.</p>
<p>Create filesystems:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>mkfs.ext4 /dev/sda1
</span><span class='line'>mkfs.ext4 /dev/sda2</span></code></pre></td></tr></table></div></figure>
<p>Mount partitions and create <code>boot</code> dir, for boot partition:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>mount /dev/sda2 /mnt
</span><span class='line'>mkdir /mnt/boot
</span><span class='line'>mount /dev/sda1 /mnt/boot</span></code></pre></td></tr></table></div></figure>
<p>Change mirror for <code>pacman</code>, I use anything in <em>Germany</em>, and paste to top of <code>mirrorlist</code>:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>vim /etc/pacman.d/mirrorlist</span></code></pre></td></tr></table></div></figure>
<p>Install base and devel system (this can take for while, so better choose good mirror to be fast as possible!):</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>
</span><span class='line'>pacstrap -i /mnt base base-devel</span></code></pre></td></tr></table></div></figure>
<p>Generate <code>fstab</code> and check it:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>genfstab -U -p /mnt >> /mnt/etc/fstab
</span><span class='line'>vim /mnt/etc/fstab</span></code></pre></td></tr></table></div></figure>
<h3>Chroot and configure system</h3>
<p>Chroot to <code>mnt</code>:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>arch-chroot /mnt</span></code></pre></td></tr></table></div></figure>
<p>Create custom Keyboard Layout in <code>vconsole.conf</code>, and and add keyboard map for <em>Dvorak</em>:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>vim /etc/vconsole.conf
</span><span class='line'>
</span><span class='line'> # add content to it
</span><span class='line'>
</span><span class='line'>"KEYMAP=dvorak"</span></code></pre></td></tr></table></div></figure>
<p>Update with <code>pacman</code> and install <code>vim</code> (again, omit if you’re using <code>vi</code> or <code>nano</code>):</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>pacman -Sy
</span><span class='line'>pacman -S vim</span></code></pre></td></tr></table></div></figure>
<p>Set up locale, for me uncomment <code>en_US UTF-8</code> in <code>locale.gen</code>:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>vim /etc/locale.gen
</span><span class='line'>locale-gen</span></code></pre></td></tr></table></div></figure>
<p>Create <code>locale.conf</code> and export locale:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>echo LANG=en_US.UTF-8 > /etc/locale.conf
</span><span class='line'>export LANG=en_US.UTF-8</span></code></pre></td></tr></table></div></figure>
<p>Set Time Zone by linking to time zone info to <code>localtime</code>:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
</pre></td><td class='code'><pre><code class=''><span class='line'> # use to see all zone infos
</span><span class='line'>ls /usr/share/zoneinfo
</span><span class='line'>
</span><span class='line'> # use to see all zone sub infos
</span><span class='line'>ls /usr/share/zoneinfo/Europe
</span><span class='line'>
</span><span class='line'>ln -s /usr/share/zoneinfo/Europe/Zagreb /etc/localtime</span></code></pre></td></tr></table></div></figure>
<p>Set Hardware Clock to UTC:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>hwclock --systohc --utc</span></code></pre></td></tr></table></div></figure>
<p>Set Hostname:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>echo vbox-arch > /etc/hostname</span></code></pre></td></tr></table></div></figure>
<p>Configure Network:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>systemctl enable dhcpcd.service</span></code></pre></td></tr></table></div></figure>
<h3>Root passwd and new sudo user</h3>
<p>Set <code>root</code> password:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>passwd</span></code></pre></td></tr></table></div></figure>
<p>Create new user that will be sudo:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>useradd -m -g users -G wheel,video -s /bin/bash <username></span></code></pre></td></tr></table></div></figure>
<p>Install <code>sudo</code> with <code>pacman</code>:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>pacman -S sudo</span></code></pre></td></tr></table></div></figure>
<p>Uncomment <code>wheel</code> group from sudoers ”<code>%wheel ALL=(ALL)</code>”, so that user just created can be sudo:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>visudo</span></code></pre></td></tr></table></div></figure>
<p>Set password to created user:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>passwd <username></span></code></pre></td></tr></table></div></figure>
<h3>Bootloader</h3>
<p>Since we use <strong>MBR</strong> not <strong>GPT</strong> lets install <code>GRUB BIOS</code> bootloader:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>pacman -S grub-bios</span></code></pre></td></tr></table></div></figure>
<p>Install and configure <code>GRUB</code> to <code>/dev/sda</code>:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>grub-install --recheck /dev/sda
</span><span class='line'>grub-mkconfig -o /boot/grub/grub.cfg</span></code></pre></td></tr></table></div></figure>
<p>Exit <code>chroot</code>, unmount mounted partitions and reboot:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>exit
</span><span class='line'>umount -R /mnt/boot
</span><span class='line'>umount -R /mnt
</span><span class='line'>reboot</span></code></pre></td></tr></table></div></figure>
<h2>Post Install</h2>
<p>Install <em>Yaourt</em> from <em>archlinuxfr</em>, for easier interaction/installation from <em>AUR</em>.<br/>
Add <em>archlinuxfr</em> repository to <code>/etc/pacman.conf</code>:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>[archlinuxfr]
</span><span class='line'>SigLevel = Never
</span><span class='line'>Server = http://repo.archlinux.fr/$arch</span></code></pre></td></tr></table></div></figure>
<p>Update <code>pacman</code> and install <code>yaourt</code>:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>pacman -Sy yaourt</span></code></pre></td></tr></table></div></figure>
<h3>GUI</h3>
<p>Install X server:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>pacman -S xorg-server xorg-server-utils xorg-xinit</span></code></pre></td></tr></table></div></figure>
<p>Install <code>mesa</code> for 3D support</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>pacman -S mesa</span></code></pre></td></tr></table></div></figure>
<h3>VirtualBox</h3>
<p>Install Guest additions:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>pacman -S virtualbox-guest-utils
</span><span class='line'>modprobe -a vboxguest vboxsf vboxvideo</span></code></pre></td></tr></table></div></figure>
<p>Create <code>virtualbox.conf</code> in <code>/etc/modules-load.d</code></p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>vim /etc/modules-load.d/virtualbox.conf</span></code></pre></td></tr></table></div></figure>
<p>Add modules guest and video to <code>virtualbox.conf</code>:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>vboxguest
</span><span class='line'>vboxsf
</span><span class='line'>vboxvideo</span></code></pre></td></tr></table></div></figure>
<p>Log or <code>su</code> as created user.
Copy <code>.xinitrc</code> and add following content:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>cp /etc/X11/xinit/xinitrc ~/.xinitrc
</span><span class='line'>vim ~/.xinitrc
</span><span class='line'>
</span><span class='line'> # add this inside .xinitrc (at the top!)
</span><span class='line'>
</span><span class='line'>/usr/bin/VBoxClient-all</span></code></pre></td></tr></table></div></figure>
<h3>Setup keyboard (non US)</h3>
<p>We did setup for console now we need to set up for X:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>localectl set-x11-keymap dvorak</span></code></pre></td></tr></table></div></figure>
<h3>Test X</h3>
<p>Install <code>xterm</code>, <code>xclock</code> and <code>lwm</code>:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>pacman -S xorg-twm xorg-xclock xterm</span></code></pre></td></tr></table></div></figure>
<p>Start X</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>startx</span></code></pre></td></tr></table></div></figure>
<p><img src="http://learnaholic.me/images/arch-alsi.png"></p>
<p>This is a first part of <em>ArchLinux</em> covering installation, configuration and testing that <em>X</em> or <em>GUI</em> is functioning properly.
Next part is installing and configuring <em>Window Manager</em>. And since the <em>Gnome</em> and <em>KDE</em> are most popular, we will not use them at all!
Intention is to use <em>Tiled Window Manager</em>…</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[Configuring TeamCity 7 with Git revision short hash, Uploading to Amazon S3 and sending email with release link and Developer commit details]]></title>
<link href="http://learnaholic.me/2013/06/05/configuring-teamcity-7-with-git-revisions-uploading-to-amazon-s3-and-sending-email-with-release-link/"/>
<updated>2013-06-05T20:37:00+02:00</updated>
<id>http://learnaholic.me/2013/06/05/configuring-teamcity-7-with-git-revisions-uploading-to-amazon-s3-and-sending-email-with-release-link</id>
<content type="html"><![CDATA[<p>Here is a short tutorial (with extra long title!) how to improve the <a href="http://www.jetbrains.com/">JetBrains</a>
<a href="http://www.jetbrains.com/teamcity/">TeamCity</a> Build Server for <em>CI</em> (Continuos Integration).</p>
<p>This is what wiill do to improve <em>TeamCity 7</em>:</p>
<ul>
<li>Change the Build version number to include Git short hash (7 chars) as Revison e.g. <em>1.0.1.53e7986</em>.</li>
<li>Upload file to <a href="http://aws.amazon.com/s3/">Amazon S3</a>.</li>
<li>Send email via Gmail with:
<ul>
<li>Latest downloadable link of release from <em>Amazon S3</em>.</li>
<li>Developer commit message details.</li>
</ul>
</li>
</ul>
<blockquote><p>Note:</p>
<p>This is not blog post how to set up <em>TeamCity</em>, this is usually really straight forward thing to do.
So in this blog post I assume that there is <em>TeamCity</em> project and at least one <em>Build Configuration</em>
already created!</p></blockquote>
<h2>Setting Git Short Hash as Revision of TeamCity Build Number</h2>
<ul>
<li>In <em>TeamCity</em> go to desired named ”<em>Build Configuration</em>” in our case ”<em>aeon</em>”.</li>
<li>Click somewhere on right side on <em>Edit Configuration Settings</em> to enter <em>aeon Configuration Steps</em>.</li>
<li>In <em>(1) General Settings</em> set <em>Build format number</em> to something like 1.0.{0} and <em>Save</em>.</li>
<li>In <em>(3) Build Steps</em> click <em>Add build step</em> choose <em>Powershell</em> in listbox.</li>
<li>Set <em>Name</em> if you want like ”<em>Get Build Number with short Git Hash</em>”.</li>
<li>For <em>Script</em> choose ”<em>Source code</em>” from drop down box.</li>
<li>In <em>Script Source</em> add following <em>Powershell</em> code and click <em>Save</em>:</li>
</ul>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class='powershell'><span class='line'><span class="nv">$BuildNumber</span> <span class="p">=</span> <span class="s2">"%build.number%"</span>
</span><span class='line'><span class="nv">$Hash</span> <span class="p">=</span> <span class="s2">"%build.vcs.number%"</span>
</span><span class='line'><span class="nv">$ShortHash</span> <span class="p">=</span> <span class="nv">$Hash</span><span class="p">.</span><span class="n">substring</span><span class="p">(</span><span class="n">0</span><span class="p">,</span><span class="n">7</span><span class="p">)</span>
</span><span class='line'><span class="nb">Write-Host</span> <span class="s2">"##teamcity[buildNumber '$BuildNumber.$ShortHash']"</span>
</span></code></pre></td></tr></table></div></figure>
<ul>
<li><em>Script execution mode</em> should not matter, mine is “Execute .ps1 script…”.</li>
<li>After save <strong>make sure that this <em>Build Step</em> is first</strong>!!!!</li>
<li>Use <em>Reorder build steps</em> link, if you have existing build setps.</li>
</ul>
<blockquote><p>Note:</p>
<p>When build starts by Agent, it will be 1.0.1 and at the end it will change to
1.0.1.53e7986!</p></blockquote>
<h3>Shell version (<em>Linux</em> or <em>Mac</em>)</h3>
<ul>
<li>All same as <em>Powershell</em> until <em>(3) Build Steps</em>.</li>
<li>In <em>(3) Build Steps</em> click <em>Add build step</em> choose <em>Command line</em> in listbox.</li>
<li>In <em>Custom Script</em> add following <em>shell</em> script and click <em>Save</em>:</li>
</ul>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>