Skip to content

Commit 36c7311

Browse files
author
kotrfa
committed
release
1 parent d953a8c commit 36c7311

File tree

3 files changed

+119
-115
lines changed

3 files changed

+119
-115
lines changed

docs/source/Arch.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Installation
1212
------------
1313

1414
There are tons of step-by-step guides how to install Arch so I will not
15-
go to deep here. Just look here: . Anyway, short summary:
15+
go to deep here. Just look to `<nstallation guide <https://wiki.archlinux.org/index.php/installation_guide>`_. Anyway, short summary:
1616

1717
Primary installation
1818
~~~~~~~~~~~~~~~~~~~~

docs/source/RPi.rst

+51-114
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ Making Raspberry Pi usable
44
Introduction
55
----------------
66

7-
After 3 months of using RPi, I decided to make this tutorial for same
7+
After 8 months of using RPi, I decided to make second version of this tutorial for same
88
people as I'm - who looks for easy, understandable way to make RPi as
9-
awesome as possible.
9+
awesome as possible. Several things have changed since last realease of this tutorial, so I decided to rewrite some parts and also to delete some parts which are not necessary today.
1010

1111
In this tutorial I will walk you through whole process of making from
1212
Raspberry Pi secure, reliable, efficient, fast and easy to maintain
@@ -44,6 +44,7 @@ What you don't need
4444
-------------------
4545

4646
- Monitor or ability to connect RPi to some monitor
47+
- Keyboard or mouse connected to your RPi
4748

4849
Start
4950
-----
@@ -55,7 +56,7 @@ found them satisfaing.
5556
Installing Arch Linux ARM to SD card
5657
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5758

58-
Go `here <http://Arch Linuxarm.org/platforms/armv6/raspberry-pi>`__ and
59+
Go `here <http://Arch Linuxarm.org/platforms/armv6/raspberry-pi>`__, choose installation and
5960
make first 3 steps. That's it! You have done it. You have you Arch Linux
6061
ARM SD card :)
6162

@@ -71,24 +72,23 @@ connects to the network (or even internet) as usuall?
7172

7273
If yes, it is great! You can procced. It is what we need - we need RPi,
7374
when it boots up, to automatically connect to the network. Then we will
74-
able to connect to it. You will need one more think to find out - which
75-
IP address router asign to you when you connected by cable - it is very
76-
probable that RPi will get the same, or similiar. Don't be afraid - it
77-
is easy to get (IP address)[how to get ip address]. On modern systems,
75+
able to connect to it. You will need one more thing to find out - which
76+
IP address does router assign to you when you connect by cable - it is very
77+
probable that RPi will get very similiar. Don't be afraid - it
78+
is easy to get `IP address <http://apple.stackexchange.com/questions/19783/how-do-i-know-the-ip-addresses-of-other-computers-in-my-network>`_. On modern systems,
7879
one command :) .
7980

8081
Ok, now you have to insert SD card to RPi and connect it to your router
8182
with ethernet cable and then turn RPi on by inserting power supply. The
82-
diodes starts flashing. Now back to your computer and we will try to
83+
diods start flashing. Now back to your computer and we will try to
8384
connect it using **SSH**. SSH is just "magic power" which enables to
84-
connect from one to other computer.
85+
connect to another computer.
8586

86-
RPi is already ready and waits for connection. How to use ssh and some
87-
utilities (Linux, Mac) or programs (Windows) is supereasy - you will
87+
RPi is already ready and waits for SSH connection. How to use SSH is supereasy - you will
8888
find a tons of tutorials on the internet (keywords: how to use ssh). IP
8989
address is the probably the one you assigned before. It will be
9090
something like this: ``192.168.0.x``, ``10.0.0.14x`` or similar. Next
91-
thing you need is username. It's just "root".
91+
thing you need is username. It's just "root" (and password also).
9292

9393
If your RPi haven't got this address (ssh is not working), than there
9494
are two options.
@@ -102,53 +102,49 @@ are two options.
102102
**Example** You have this address assigned: ``192.168.0.201``. Then you
103103
have to type (in linux): ``ssh [email protected]``.
104104

105-
Youshould end up in RPi console.
105+
You should now end up in RPi console.
106106

107-
Enough for networking just now. We'll set a proper network configuration later in this guide, but first some *musthaves*.
107+
Enough of networking for now. We'll set a proper network configuration later in this guide, but first some *musthaves*.
108108

109109

110110
First setup
111111
-----------
112112

113113
This is covered over the internet, so I will just redirect you.
114-
`elinux <http://elinux.org/Arch Linux_Install_Guide>`__ - from this guide
114+
`elinux <http://elinux.org/ArchLinux_Install_Guide>`__ - from this guide
115115
finish these parts (in RPi console):
116116

117117
- Change root password
118-
- Modify filesystem files
118+
- Modify system files
119119
- Mount extra partitions (if you don't know what it is, nevermind)
120120
- Update system
121-
- Install Sudo
121+
- Install sudo
122122
- Create regular user account
123123

124+
My usuall procedure (which is strongly related to my needs!)::
125+
126+
passwd # change root password to something important
127+
rm -rf /etc/localtime # dont care about this
128+
ln -s /usr/share/zoneinfo/Europe/Prague /etc/localtime # set appropriate timezone
129+
echo "my_raspberry" > /etc/hostname # set name of your RPi
130+
131+
useradd -m -aG wheel -s /usr/bin/bash common_user #
132+
groupadd webdata # for sharing
133+
useradd -M -aG webdata -s /usr/bin/false nginx
134+
usermod -aG webdata common_user
135+
136+
visudo # uncomment this line: %wheel ALL=(ALL) ALL
137+
138+
pacman -Syu
139+
124140
That's enough for now. Logout from ssh (type ``exit``) and connect
125141
again, but as user who was created. Similiar to previous:
126-
``ssh username@ip.address``. From now, you'll need to type "sudo" in
142+
``ssh common_user@ip.address``. From now, you'll need to type "sudo" in
127143
front of every command, which is possibly danger. I will warn you in
128144
next chapter.
129145

130-
We must be sure that after reboot RPi will reconnect. Type
131-
``sudo systemctl status netctl-ifplugd@eth0``. In should show something
132-
like this:
133-
134-
::
135-
136-
[email protected] - Automatic wired network connection using netctl profiles
137-
Loaded: loaded (/usr/lib/systemd/system/[email protected]; enabled)
138-
Active: active (running) since Thu 2014-06-26 17:38:12 CEST; 4h 26min ago
139-
Docs: man:netctl.special(7)
140-
Main PID: 302 (ifplugd)
141-
CGroup: /system.slice/system-netctl\x2difplugd.slice/[email protected]
142-
└─302 /usr/bin/ifplugd -i eth0 -r /etc/ifplugd/netctl.action -bfIns
143-
144-
Jun 26 17:38:12 530uarch ifplugd[302]: ifplugd 0.28 initializing.
145-
Jun 26 17:38:12 530uarch ifplugd[302]: Using interface eth0/E8:03:9A:97:B5:A7 with driver <r8169> (version: 2.3LK-NAPI)
146-
Jun 26 17:38:12 530uarch ifplugd[302]: Using detection mode: SIOCETHTOOL
147-
Jun 26 17:38:12 530uarch ifplugd[302]: Initialization complete, link beat not detected.
146+
We must be sure that after reboot RPi will reconnect.
148147

149-
Keywords here are **active (running)** in "Active" and **enabled** in
150-
"loaded". If there is **disabled**, just enable it by
151-
``systemctl enable [email protected]``
152148

153149
Now try if you are connected to the internet. Type ``ping 8.8.8.8``. If
154150
you don't see ``ping: unknown host 8.8.8.8`` it's good! If you do, your
@@ -272,7 +268,7 @@ For reasons I will mention in future, we need to set RPi to connect with
272268
the same and you can connect it. Right now is probably getting
273269
automatically assigned IP address from router (it's called **dhcp**).
274270

275-
We will use ``systemd-network``.
271+
We will use ``systemd-networkd``.
276272

277273
Type ``ip addr``. It should shows something like this:
278274

@@ -293,7 +289,7 @@ Type ``ip addr``. It should shows something like this:
293289

294290
you are interested just in name **eth0**. If it is there, it is ok. In
295291
future versions of system it can change to something other, for example
296-
*eth0ps1*. Don't be afraid of it and just use that instead in next
292+
*enp0s1*. Don't be afraid of it and just use that instead in next
297293
chapters.
298294

299295
In this part you'll need to get address of your router. `How to obtain
@@ -324,7 +320,6 @@ in front of ``vim``, or you'll not be able to save it!) and paste this:
324320
[Network]
325321
Address=the.static.address.rpi/24
326322
Gateway=your.router.ip.address
327-
a
328323

329324
my example:
330325

@@ -334,53 +329,14 @@ my example:
334329
Name=eth0
335330

336331
[Network]
337-
Address=192.168.0.201/24
332+
Address=192.168.0.111/24
338333
Gateway=192.168.0.1
339334

340-
now we need to try it - we don't to close us out. The connection is
341-
right now ensuring by thing called ``netctl-ifplugd@eth0``. We want to
342-
do this:
335+
Now you need to remove old non-static default profile ``/etc/systemd/network/eth0.network``. Move it to your home folder just to be safe if something didn't work.
343336

344-
- Turn ``netctl`` off
345-
- Turn ``networkd`` on
346-
- Try if RPi is connected to the internet
347-
- If yes, than do nothing - we can connect now by ssh
348-
- If not, turn off ``networkd`` and turn on working ``netctl``
337+
Try to restart RPi and try to SSH again. If you just can't connect, try to find out if RPi hadn't connected at all or it just doesn't use IP specified IP address (try to ssh to old IP, look into your router DHCP table, nmap...). If you want to get it back, just turn off RPi (plug off the power cable), take out SD card, plug in to your PC, move ``eth0.network`` from home directory to ``/etc/systemd/network/``, turn RPi back and try it again.
349338

350-
why so complicated? Because when you are changing network, it will
351-
disconnect - and of course, we will disconnected also from SSH. And it
352-
discouraged to use more network managers at once, because they'd
353-
interferate and you don't want that.
354-
355-
This script will do what we want:
356-
357-
::
358-
359-
#!/usr/bin/bash
360-
systemctl stop netctl-ifplugd@eth0
361-
systemctl restart systemd-networkd
362-
363-
sleep 10
364-
systemctl status systemd-networkd >> log.txt
365-
ping -c 1 google.com
366-
if [[ `echo $?` != 0 ]]
367-
then
368-
systemctl stop systemd-networkd
369-
systemctl start netctl-ifplugd@eth0
370-
fi
371-
372-
to run this script you need to login as root. You can do it by typing
373-
this: ``sudo -i``. This will log you as a root. Now type
374-
``vim script.sh`` and insert script there. Save and close (in vim using
375-
``:x``). Now just type ``chmod +x script.sh``. It will make the script
376-
executable. Finally this: ``./script.sh``.
377-
378-
The connection will close now. Wait 30 seconds. If everything worked
379-
properly, you should be able to connect to RPi again by using same ssh
380-
command as previous. In that case find out it works -> does
381-
systemd-networkd care about connection and netctl is stopped?
382-
383-
To find it out, type: ``systemctl status systemd-networkd``. Does it
339+
If you successfuly connected, check how is ``systemd-networkd`` doing. To find out, type: ``systemctl status systemd-networkd``. Does it
384340
shows "active (running)" and something like ``gained carrier``?
385341

386342
::
@@ -397,20 +353,6 @@ shows "active (running)" and something like ``gained carrier``?
397353
Jun 17 17:52:01 smecpi systemd-networkd[213]: eth0: lost carrier
398354
Jun 17 17:52:02 smecpi systemd-networkd[213]: eth0: gained carrier
399355

400-
If yes, great! We can get rid off netctl by uninstalling it by
401-
``pacman -Rnsc netctl`` and enable ``networkd`` to start at boot by
402-
``systemctl enable systemd-networkd``.
403-
404-
If not, ``netctl`` should be started again and save the day. Find it out
405-
by ``systemctl status netctl-ifplugd@eth0``. It should be active,
406-
otherwise there is some magic power which care about your connection.
407-
Try to find out why ``networkd`` didn't workd and repair it (probably
408-
bad IP address...). There should be some info in file ``log.txt``.
409-
410-
If you can't connect, don't panic. Just turn off RPi (take out power
411-
suppy) and turn it on. It should reconnect normally with
412-
``netctl-ifplugd``. Try to find out why it is not working and try it
413-
again.
414356

415357
Timesynchronization
416358
-------------------
@@ -419,9 +361,8 @@ You've maybe noticed that time is quite weird on your RPi. It is beacuse
419361
it does not have real hardware clock. Every time RPi is waken up, it
420362
thinks that is June 1970. You don't have to care about it, but after
421363
boot it would be fine that time is correctly set. You can do it by using
422-
really great part of ``systemd``. Go ahead and enable service, which
423-
takes care about that: ``systemctl enable systemd-timesyncd``. Thats
424-
all. It will start after next reboot. If you want it to start now, just run ``systemctl start systemd-timesyncd``.
364+
really great part of ``systemd``. Go ahead and check service that
365+
takes care about that: ``systemctl status systemd-timesyncd``.
425366

426367
Configuring SSH
427368
-------------------
@@ -455,9 +396,9 @@ Since now, only ``ssh bob@ipadress`` is not enough. You will have to add
455396
port which should be used (in default is assumed port 22).
456397
``ssh -p 1234 [email protected]`` will do it for you :) .
457398

458-
The next thing we are going to do is set up ``sshguard``. More about it
399+
If you want to be really safe, the next thing you want to do is set up ``sshguard``. More about it
459400
`here <https://wiki.Arch Linux.org/index.php/Sshguard>`__. You don't need
460-
more :) . Just remember to use your port (in my case 1234) for settings.
401+
more :) . Just remember to use your port (in my case 1234) for settings. Personally I stopped to use it, since just changing port what SSH use was enough to reduce uninvited connections.
461402

462403
It is anoying still typing same username and password when we want to
463404
connect to RPi. And now, we have to add "-p 1234" also. We will make it
@@ -543,7 +484,7 @@ Other tweaks of /boot/config.txt
543484

544485
Since you don't need any of gpu memory - which cares about shiny things
545486
like windows etc., you can disable it in favor of the rest of memory
546-
which we use.
487+
which we use. Don't do this if you want to use monitor.
547488

548489
::
549490

@@ -737,8 +678,8 @@ protected etc.
737678
System analyzing and cleaning
738679
-----------------------------
739680

740-
Use your friend ``systemd-analyze``. It will show you which units are
741-
loading long time. Also ``systemctl status`` is great for finding failed
681+
Use your friend ``systemd-analyze``. It will show you which units
682+
load really long time. Also ``systemctl status`` is great for finding failed
742683
units.
743684

744685
Disable things that you dont need
@@ -747,19 +688,15 @@ Disable things that you dont need
747688
I guess you don't use ipv6 (if you don't know what it is, you don't need
748689
it :D). ``systemctl disable ip6tables``. In case you use sshguard, you
749690
need also edit file ``/cat /usr/lib/systemd/system/sshguard.service``
750-
and from **Wants** delete ip6tables. Like this:
751-
752-
::
753-
754-
Wants=iptables.service
691+
and from **Wants** delete ``ip6tables.service``.
755692

756693
Usefull utilites
757694
----------------
758695

759696
Simple to use, just install them and run:
760697

761-
- iftop - for internet usage
762-
- iotop - for disk usage
698+
- nmon - for internet usage
699+
- htop - for disk usage
763700

764701
Torrents
765702
~~~~~~~~

docs/source/ndg.rst

+67
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,73 @@ After every change in configuration of nginx you need to restart it by running `
387387

388388
To see what processes are spawned you can use your task manager like ``htop`` or ``ps``.
389389

390+
391+
Integration with GitHub
392+
=======================
393+
394+
For starter it's necessary to say, that GitHub...
395+
396+
...is awesome! If you don't needed and you went through whole process above, you can probably save a lot of headaches just by using GitHub. You don't need any special knowledge for start, but you will need to learn them on the fly while reading this tutorial (there is really a lot about git out there, google is your friend).
397+
398+
The variant I propose here is very easy, scalable and fast. Probably the most easy and effective I've found.
399+
400+
Why to use it
401+
--------------
402+
403+
I was so happy when I deployd my first django project. But few weeks later I've found that it's just not feeling right to make changes on live version of the website (sometimes refered as *production*). So I started to use GitHub and found a solution.
404+
405+
Here I will cover this:
406+
For every your website you end up with one directory including three subdirectories.
407+
408+
1. First called **production** - it's the one which is live on the internet - the one what ``nginx`` refers.
409+
2. Second called **mydomain.git** - this one is necessary for our github configuration. You will barely change there anything
410+
3. Last one - **work_dir** - the one where all changes are being made and is connected to GitHub
411+
412+
413+
Workflow
414+
------------
415+
416+
Your work will look like this:
417+
418+
1. Your work_dir contains master branch. This branch can be pushed to production (to go live) anywhen! So when you want to make change to your website, you need create new branch (correctly named based on the change you are doing - e.g. *hotfix_plugin*, *typo_css*...) and when you finish and test this branch, you merge it to master.
419+
2. You push master to your GitHub repository
420+
3. You push master to your production folder on your computer
421+
422+
Set it all up
423+
-------------
424+
425+
So how to do it? I suppose you have one working directory as we created in previous chapters.
426+
427+
Now go to the place where you websites are stored. Mine is in ``/var/www`` and create this structure::
428+
429+
mydomain
430+
├── mydomain.git
431+
├── production
432+
└── work_dir
433+
434+
Go to ``/var/www/mydomain.git`` and type this::
435+
436+
git init --bare
437+
438+
this will create just git repository with some special folders. You don't need to know anything about it. All you need to do is to create this file ``/var/www/mydomain/mydomain.git/hooks/post-receive`` and add this::
439+
440+
#!/bin/sh
441+
git --work-tree=/var/www/mydomain/production --git-dir=/var/www/mydomain/mydomain.git checkout -f
442+
443+
and make the script runable ``chmod +x /var/www/mydomain/mydomain.git/hooks/post-receive``
444+
445+
Go to work_dir and paste there you current *production* code (the one from previous chapters). Now you need to make a GitHub repository from that. The best guide is this one: `How to add existing folder to GitHub <https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/>`_. (Maybe you'll need to `generate SSH key <https://help.github.com/articles/generating-ssh-keys/>`_). Is it working? Great.
446+
447+
Note: It's very good to make git repositories as small as possible, so don't add to repository files which are not necessary or you backup them somewhere else. But virtualenv is a good thing to add there to IMHO.
448+
449+
Now just add another remote, which will point to our created git repository. Every time we'll want to go live with master, we'll push changes to this git repository and it will take care to transfer our files to production. So in work_dir type::
450+
451+
git remote add production file::///var/www/mydomain/mydomain.git``
452+
453+
and that's all. When you now want to push changes to production, type ``git push production master``. Congratulations!
454+
390455
Finalization
391456
============
392457
That's all! I hope this guide helped you and you has successfully start up your websites! :)
458+
459+

0 commit comments

Comments
 (0)