Agenda: lab1-fred-genzone-cron.md.html

File lab1-fred-genzone-cron.md.html, 3.2 KB (added by admin, 5 years ago)
Line 
1# Refresher on FRED
2
3Remember the prerequisites for creating objects in the Fred DB
4(from https://fred.nic.cz/page/2906/installation-ubuntu/ and
5https://fred.nic.cz/page/699/fred-client-how-to/
6
71. Make sure you have an existing contact, or create one
82. Make sure you have an NS-set, or create one, and associate it to
9   the contact
103. Once the above are fulfilled, you can create a domain, referencing
11   the contact and NS-set
12
13From the Ubuntu installation above, you remember running this command
14near the end:
15
16`genzone_client`
17
18... if you remember, this automatically generated (created and wrote
19the contents) all the zones to disk.
20
21Let's create a place where we can export our zones:
22
23~~~
24cd
25mkdir zones
26cd zones
27pwd
28~~~
29
30The 4 commands above make sure you that:
31
32- you are in your home directory (`cd`)
33- a directory "zones" exist (`mkdir zones`)
34- you change the current working directory to "zones" (`cd zones`)
35- you verify that you are indeed placed inside this directory (`pwd`)
36
37Once you've done this, let's run the `genzone_client`:
38
39~~~
40genzone_client
41~~~
42
43Then
44
45~~~
46ls -l
47~~~
48
49... you should see at list one file, for the zone of the domain
50for the TLD that was created when you installed FRED.
51
52For example, you may see:
53
54~~~
55-rw-rw-r-- 1 sysadm sysadm 719 Jun  1 07:19 db.dk
56~~~
57
58# Automate zone generation
59
60Now, we would like to have the above "zone generation" take place
61automatically, so we don't need to remember to do it manually every
62time we make changes in the zone.
63
64To do this, we're going to use `cron`. cron is an automated scheduling
65utility that will run jobs when you tell it to.
66
67Cron takes a very simple format, called a `crontab`, in this form:
68
69~~~
70Minute  Hour    Day-of-Month    Month   Day-of-Week             Command [params]
71~~~
72
73For example, if we wanted to say "hello" at 5 minute past the hour
74on every hour, Monday to Friday, we would write:
75
76~~~
775       *       *       *       *       1-5             echo "hello"
78~~~
79
80This reads as:
81
82At 5 minute past the hour, every hour, every day, every month, Mon-Fri, say
83hello.
84
85Let's create a `crontab` for the `genzone_client`, that will automate zone
86generation!
87
88To do this, run the `crontab -e` command:
89
90~~~
91crontab -e
92~~~
93
94You will probably be asked which editor you want to use the first time:
95
96~~~
97no crontab for sysadm - using an empty one
98
99Select an editor.  To change later, run 'select-editor'.
100  1. /usr/bin/vim.basic
101  2. /usr/bin/vim.tiny
102
103Choose 1-2 []:
104~~~
105
106Pick 1 or 2 -- and you will be brought into a `vi` editor, with some
107text. Go to the bottom, and add the following line:
108
109~~~
110*/5     *       *       *       *       cd /home/sysadm/zones && genzone_client
111~~~
112
113(Copy-pasting the above line is probably the easiest!)
114
115The above reads as:
116
117Every 5 minutes of every hour, every day, every month, all weekdays, run
118the commands "`cd /home/sysadm/zones && genzone_client`"
119
120Once you've added the line, save the file and exit. You should see:
121
122~~~
123crontab: installing new crontab
124~~~
125
126Now instead of waiting 5 minutes, let's start configure BIND!
127
128<!-- Markdeep: --><style class="fallback">body{visibility:hidden;white-space:pre;font-family:monospace}</style><script src="markdeep.min.js"></script><script src="https://casual-effects.com/markdeep/latest/markdeep.min.js"></script><script>window.alreadyProcessedMarkdeep||(document.body.style.visibility="visible")</script>